From: Connor McAdams <cmcadams@codeweavers.com> Signed-off-by: Connor McAdams <cmcadams@codeweavers.com> --- dlls/dinput/joystick_hid.c | 10 ++++++++++ dlls/dinput/tests/joystick8.c | 13 ++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 53c055ceb89..8eedc9b57b9 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -245,8 +245,10 @@ static void load_registry_instances( HKEY root ) static HRESULT get_instance_from_guid( const GUID *guid, DIDEVICEINSTANCEW *instance, DWORD *joy_id, WCHAR *path ) { + BOOL is_guid_joystick = FALSE; struct cache_entry *entry; HRESULT hr = DI_OK; + GUID tmp = *guid; if (!memcmp( device_path_guid.Data4, guid->Data4, sizeof(device_path_guid.Data4) )) { @@ -254,11 +256,19 @@ static HRESULT get_instance_from_guid( const GUID *guid, DIDEVICEINSTANCEW *inst return S_OK; } + tmp.Data1 &= 0xfffffff0; + is_guid_joystick = IsEqualGUID( &tmp, &GUID_Joystick); + EnterCriticalSection( &joystick_cache_cs ); LIST_FOR_EACH_ENTRY( entry, &joystick_cache, struct cache_entry, entry ) { if (!*entry->path) continue; + if (is_guid_joystick) + { + if (entry->joy_id == (guid->Data1 & 0xf)) break; + continue; + } if (IsEqualGUID( &entry->instance.guidProduct, guid )) break; if (IsEqualGUID( &entry->instance.guidInstance, guid )) break; } diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index d52a53792d6..48a7e6ebc0d 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -6824,13 +6824,12 @@ static void test_joystick_id( DWORD version ) joystick_id_guid.Data1 += i; hr = dinput_create_device( &di, &joystick_id_guid, &device ); - todo_wine ok( hr == DI_OK, "Unexpected hr %#lx.\n", hr ); - if (device) - { - check_device_hid_serial( device, descs_bulk[i].serial_str ); - check_device_joystick_id( device, i, TRUE ); - IDirectInputDevice8_Release(device); - } + ok( hr == DI_OK, "Unexpected hr %#lx.\n", hr ); + + check_device_hid_serial( device, descs_bulk[i].serial_str ); + check_device_joystick_id( device, i, FALSE ); + + IDirectInputDevice8_Release(device); } winetest_pop_context(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10755