On Thu Nov 28 17:49:00 2024 +0000, Paul Gofman wrote:
The only alternative (maybe still better?) that I see so far is to have that index somewhere in hidclass.sys queryable by IOCTL_HID_GET_WINE_JOYSTICK_INDEX (similar to IOCTL_HID_GET_WINE_RAWINPUT_HANDLE), but then this index has to be persisted in some (somewhat similar?) way there too so it is not subject to spurious change. It doesn't seem to be a problem for joystick ids to change, as far as I can tell Windows does it as well (although it keeps some sort of a cache but given the details below, it also seems quite futile).
With this test: ```c desc.attributes.ProductID = 1; if (!hid_device_start( &desc, 1 )) goto done; hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_GAMECTRL, select_default_instance, &d, DIEDFL_ALLDEVICES ); ok( hr == DI_OK, "got hr %#lx.\n", hr ); hid_device_stop( &desc, 1 ); desc.attributes.ProductID = 2; if (!hid_device_start( &desc, 1 )) goto done; hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_GAMECTRL, select_default_instance, &d, DIEDFL_ALLDEVICES ); ok( hr == DI_OK, "got hr %#lx.\n", hr ); desc.attributes.ProductID = 1; if (!hid_device_start( &desc, 1 )) goto done; hr = IDirectInput8_EnumDevices( di8, DI8DEVCLASS_GAMECTRL, select_default_instance, &d, DIEDFL_ALLDEVICES ); ok( hr == DI_OK, "got hr %#lx.\n", hr ); hid_device_stop( &desc, 1 ); desc.attributes.ProductID = 2; hid_device_stop( &desc, 1 ); ``` First enumeration shows one device 1 with ID 0. Second enumeration shows one device 2 also with ID 0. Third enumeration, which is done after plugging device 1 back and without unplugging device 2, shows that device 2 ID changes to 1 to avoid collision. It seems to me that using the device enumeration index as joystick ID is just good enough. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/6878#note_89149