From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dinput/dinput.c | 6 ------ dlls/dinput/joystick_hid.c | 14 ++++++++------ dlls/dinput/keyboard.c | 9 +++++++-- dlls/dinput/mouse.c | 11 ++++++++--- 4 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/dlls/dinput/dinput.c b/dlls/dinput/dinput.c index db367e1f1ba..998573ad20d 100644 --- a/dlls/dinput/dinput.c +++ b/dlls/dinput/dinput.c @@ -299,12 +299,6 @@ static HRESULT WINAPI dinput7_CreateDeviceEx( IDirectInput7W *iface, const GUID
if (FAILED(hr)) return hr;
- if (FAILED(hr = dinput_device_init_device_format( device ))) - { - IDirectInputDevice8_Release( device ); - return hr; - } - hr = IDirectInputDevice8_QueryInterface( device, iid, out ); IDirectInputDevice8_Release( device ); return hr; diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index e8a554142f4..7efae608b5f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2022,12 +2022,6 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi list_init( &impl->effect_list );
hr = E_OUTOFMEMORY; - preparsed = (struct hid_preparsed_data *)impl->preparsed; - size = preparsed->input_caps_count * sizeof(struct object_properties); - if (!(object_properties = calloc( 1, size ))) goto failed; - impl->base.object_properties = object_properties; - enum_objects( impl, &filter, DIDFT_AXIS | DIDFT_POV, init_object_properties, NULL ); - size = impl->caps.InputReportByteLength; if (!(buffer = malloc( size ))) goto failed; impl->input_report_buf = buffer; @@ -2087,6 +2081,14 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi impl->base.caps.dwFFDriverVersion = 1; }
+ preparsed = (struct hid_preparsed_data *)impl->preparsed; + size = preparsed->input_caps_count * sizeof(struct object_properties); + if (!(object_properties = calloc( 1, size ))) goto failed; + impl->base.object_properties = object_properties; + enum_objects( impl, &filter, DIDFT_AXIS | DIDFT_POV, init_object_properties, NULL ); + + if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed; + *out = &impl->base.IDirectInputDevice8W_iface; return DI_OK;
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 0dfc909585a..cbcbf94f0f6 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -188,6 +188,7 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirectInputDevice8W **out ) { struct keyboard *impl; + HRESULT hr;
TRACE( "dinput %p, guid %s, out %p.\n", dinput, debugstr_guid( guid ), out );
@@ -202,12 +203,16 @@ HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirect impl->base.caps.dwDevType = impl->base.instance.dwDevType; impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwHardwareRevision = 100; + if (dinput->dwVersion >= 0x0800) impl->base.use_raw_input = TRUE;
- if (dinput->dwVersion >= 0x0800) - impl->base.use_raw_input = TRUE; + if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed;
*out = &impl->base.IDirectInputDevice8W_iface; return DI_OK; + +failed: + IDirectInputDevice_Release( &impl->base.IDirectInputDevice8W_iface ); + return hr; }
static HRESULT keyboard_poll( IDirectInputDevice8W *iface ) diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 9b1bf74b8d5..1c2a66e1bfa 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -107,6 +107,7 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp struct mouse *impl; HKEY hkey, appkey; WCHAR buffer[20]; + HRESULT hr;
TRACE( "dinput %p, guid %s, out %p\n", dinput, debugstr_guid( guid ), out );
@@ -122,6 +123,7 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwHardwareRevision = 100; impl->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; + if (dinput->dwVersion >= 0x0800) impl->base.use_raw_input = TRUE;
/* One object_properties per axis */ impl->base.object_properties = calloc( 3, sizeof(struct object_properties) ); @@ -132,6 +134,8 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp } IDirectInputDevice8_EnumObjects( &impl->base.IDirectInputDevice8W_iface, init_object_properties, impl, DIDFT_RELAXIS );
+ if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed; + get_app_key(&hkey, &appkey); if (!get_config_key( hkey, appkey, L"MouseWarpOverride", buffer, sizeof(buffer) )) { @@ -141,11 +145,12 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey);
- if (dinput->dwVersion >= 0x0800) - impl->base.use_raw_input = TRUE; - *out = &impl->base.IDirectInputDevice8W_iface; return DI_OK; + +failed: + IDirectInputDevice_Release( &impl->base.IDirectInputDevice8W_iface ); + return hr; }
void dinput_mouse_rawinput_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam, RAWINPUT *ri )