Rémi Bernon (@rbernon) commented about dlls/dinput/joystick_hid.c:
WCHAR device_path[MAX_PATH]; - GUID guid = GUID_NULL; HIDP_CAPS caps; HANDLE device; HRESULT hr;
TRACE( "type %#lx, flags %#lx, instance %p, version %#lx, index %d\n", type, flags, instance, version, index );
- hr = hid_joystick_device_open( index, &guid, instance, device_path, &device, &preparsed, - &attrs, &caps, version ); + EnterCriticalSection( &joystick_cache_cs ); + if ((inst = joystick_cache_get_instance_from_index( index ))) + hr = hid_joystick_instance_try_open( inst, &device, &preparsed, &attrs, &caps, instance, device_path, version ); + else + hr = DIERR_DEVICENOTREG; + LeaveCriticalSection( &joystick_cache_cs );
Won't this fail to find a new device unless EnumDevices is called to refresh the cache? I think you need to refresh the cache on failure too, it's only done later in the series and it needs to be done earlier. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10364#note_137240