Rémi Bernon (@rbernon) commented about dlls/dinput/joystick_hid.c:
+ for (UINT i = 0; !RegEnumKeyW( root_key, i, buf, ARRAY_SIZE(buf) ); i++) + { + HKEY dev_key; + + wcscat( buf, L"\\Calibration" ); + if (RegOpenKeyExW( root_key, buf, 0, KEY_ALL_ACCESS, &dev_key )) continue; + + for (UINT j = 0; !RegEnumKeyW( dev_key, j, buf, ARRAY_SIZE(buf) ); j++) + RegDeleteKeyValueW( dev_key, buf, L"DevicePath" ); + + RegCloseKey( dev_key ); + } + RegCloseKey( root_key ); +} + +static HKEY get_empty_joystick_instance_in_registry(WORD vid, WORD pid) I'm not completely sure to understand why this is needed. I was imagining something simple when enumerating devices:
1) delete local cache 2) populate it again from the registry 3) enumerate cfgmgr devices and find them in the cache or add new entries (flagging them as new if needed) 4) save the local cache to the registry (possibly just the new entries as an optimisation but doesn't matter much) There may be some logic needed to keep track of the Calibration subkey names but I think that's mostly a matter of keeping the local cache sorted by vid/pid when adding entries. Regarding sorting, I'm also not sure how stable the EnumDevices order needs to be (ie: does it sort by vid/pid? First seen time? Last plug time?). We might need to sort again the cache with a different order after the refresh. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10364#note_135650