On Tue Mar 31 11:24:05 2026 +0000, Connor McAdams wrote:
I've rebased on top of your changes, thanks for doing that. :) So yeah, I think it could be improved. First it would be nice to split the change in at least two parts: first part could simply update the module local cache and registry, and second part would pivot to using the cached data to enumerate / open joysticks.
To that end I think moving the error cases to `dinput.c`, would be nicer. You would have one `hid_joystick_refresh_device` in two places, one when `hid_joystick_create_device` returns `DIERR_DEVICENOTREG` then call it again, and another in `EnumDevices` before enumerating HID joysticks. This would match nicely with the `hid_joystick_cleanup_devices` call in `dinput.c` as well. Then regarding the cache update I don't think it has to reuse the existing enumeration loop. It doesn't need all the complicated filtering and checks, and it's mostly just a matter of, within the global mutex, 1) reading the registry to get an up to date current device list, 2) enumerating the HID devices, 3) adding anything that's missing from the list, then 4) saving it back to the registry. I think it could also be a good opportunity to switch the device enumeration to `cfgmgr32` which is simpler to use. In the second part, `hid_joystick_device_open` could just be switched over to using the local list instead of setupapi. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10364#note_134688