Commit 256f35dc authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Initialize device object format when creating devices.

parent b75bd86e
...@@ -299,12 +299,6 @@ static HRESULT WINAPI dinput7_CreateDeviceEx( IDirectInput7W *iface, const GUID ...@@ -299,12 +299,6 @@ static HRESULT WINAPI dinput7_CreateDeviceEx( IDirectInput7W *iface, const GUID
if (FAILED(hr)) return hr; 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 ); hr = IDirectInputDevice8_QueryInterface( device, iid, out );
IDirectInputDevice8_Release( device ); IDirectInputDevice8_Release( device );
return hr; return hr;
......
...@@ -2022,12 +2022,6 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi ...@@ -2022,12 +2022,6 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi
list_init( &impl->effect_list ); list_init( &impl->effect_list );
hr = E_OUTOFMEMORY; 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; size = impl->caps.InputReportByteLength;
if (!(buffer = malloc( size ))) goto failed; if (!(buffer = malloc( size ))) goto failed;
impl->input_report_buf = buffer; impl->input_report_buf = buffer;
...@@ -2087,6 +2081,14 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi ...@@ -2087,6 +2081,14 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi
impl->base.caps.dwFFDriverVersion = 1; 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; *out = &impl->base.IDirectInputDevice8W_iface;
return DI_OK; return DI_OK;
......
...@@ -188,6 +188,7 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan ...@@ -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 ) HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirectInputDevice8W **out )
{ {
struct keyboard *impl; struct keyboard *impl;
HRESULT hr;
TRACE( "dinput %p, guid %s, out %p.\n", dinput, debugstr_guid( guid ), out ); 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 ...@@ -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.dwDevType = impl->base.instance.dwDevType;
impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwFirmwareRevision = 100;
impl->base.caps.dwHardwareRevision = 100; impl->base.caps.dwHardwareRevision = 100;
if (dinput->dwVersion >= 0x0800) impl->base.use_raw_input = TRUE;
if (dinput->dwVersion >= 0x0800) if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed;
impl->base.use_raw_input = TRUE;
*out = &impl->base.IDirectInputDevice8W_iface; *out = &impl->base.IDirectInputDevice8W_iface;
return DI_OK; return DI_OK;
failed:
IDirectInputDevice_Release( &impl->base.IDirectInputDevice8W_iface );
return hr;
} }
static HRESULT keyboard_poll( IDirectInputDevice8W *iface ) static HRESULT keyboard_poll( IDirectInputDevice8W *iface )
......
...@@ -107,6 +107,7 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp ...@@ -107,6 +107,7 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp
struct mouse *impl; struct mouse *impl;
HKEY hkey, appkey; HKEY hkey, appkey;
WCHAR buffer[20]; WCHAR buffer[20];
HRESULT hr;
TRACE( "dinput %p, guid %s, out %p\n", dinput, debugstr_guid( guid ), out ); 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 ...@@ -122,6 +123,7 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp
impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwFirmwareRevision = 100;
impl->base.caps.dwHardwareRevision = 100; impl->base.caps.dwHardwareRevision = 100;
impl->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; impl->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
if (dinput->dwVersion >= 0x0800) impl->base.use_raw_input = TRUE;
/* One object_properties per axis */ /* One object_properties per axis */
impl->base.object_properties = calloc( 3, sizeof(struct object_properties) ); 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 ...@@ -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 ); 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); get_app_key(&hkey, &appkey);
if (!get_config_key( hkey, appkey, L"MouseWarpOverride", buffer, sizeof(buffer) )) 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 ...@@ -141,11 +145,12 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp
if (appkey) RegCloseKey(appkey); if (appkey) RegCloseKey(appkey);
if (hkey) RegCloseKey(hkey); if (hkey) RegCloseKey(hkey);
if (dinput->dwVersion >= 0x0800)
impl->base.use_raw_input = TRUE;
*out = &impl->base.IDirectInputDevice8W_iface; *out = &impl->base.IDirectInputDevice8W_iface;
return DI_OK; 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 ) void dinput_mouse_rawinput_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam, RAWINPUT *ri )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment