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
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;
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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 )
......
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