From: Paul Gofman pgofman@codeweavers.com
--- dlls/dinput/joystick_hid.c | 16 ++++++++++++++++ dlls/dinput/tests/joystick8.c | 13 +++++-------- 2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 17067539a66..18d77af032d 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -274,6 +274,15 @@ static unsigned int get_joystick_index( const WCHAR *device_path ) return i; }
+static BOOL get_default_joystick_device_path( WCHAR *device_path ) +{ + BOOL ret; + + EnterCriticalSection( &joystick_devices_crit ); + if ((ret = !!joystick_device_count)) wcscpy( device_path, joystick_devices[0].device_path ); + LeaveCriticalSection( &joystick_devices_crit ); + return ret; +}
static inline struct hid_joystick_effect *impl_from_IDirectInputEffect( IDirectInputEffect *iface ) { @@ -2056,8 +2065,15 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi impl->base.read_event = CreateEventW( NULL, TRUE, FALSE, NULL );
if (memcmp( device_path_guid.Data4, guid->Data4, sizeof(device_path_guid.Data4) )) + { + /* Let hid_joystick_device_open() populate joystick devices before checking for default joystick GUID. */ hr = hid_joystick_device_open( -1, guid, &impl->base.instance, impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, dinput->dwVersion ); + if (hr == DIERR_DEVICENOTREG && IsEqualGUID( guid, &GUID_Joystick ) + && get_default_joystick_device_path( impl->device_path )) + hr = hid_joystick_device_try_open( impl->device_path, &impl->device, &impl->preparsed, &attrs, + &impl->caps, &impl->base.instance, dinput->dwVersion ); + } else { wcscpy( impl->device_path, *(const WCHAR **)guid ); diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 2e3a1ffcf56..b5ec94f4876 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -6023,14 +6023,11 @@ static void test_joystick_id(void) hr = IDirectInput8_CreateDevice( di8, &GUID_Joystick, &device, NULL ); if (d.default_instance_found) { - todo_wine ok( hr == DI_OK, "got %#lx.\n", hr ); - if (hr == DI_OK) - { - hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph ); - ok( hr == DI_OK, "got hr %#lx.\n", hr ); - ok( !prop_dword.dwData, "got %lu.\n", prop_dword.dwData ); - IDirectInputDevice8_Release( device ); - } + ok( hr == DI_OK, "got %#lx.\n", hr ); + hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph ); + ok( hr == DI_OK, "got hr %#lx.\n", hr ); + ok( !prop_dword.dwData, "got %lu.\n", prop_dword.dwData ); + IDirectInputDevice8_Release( device ); } else {