On Thu Nov 28 17:27:47 2024 +0000, Paul Gofman wrote:
Ah, if you mean the index passed to hid_joystick_device_open(), I think it is no go. It is based on setupapi current device enumeration and may change during lifetime of an open device, yielding opended _JOYSTICKID of open device changing after something else is plugged or unplugged. Or, if we store that id for joystick on creation, opening the same device once again without replugging it may lead a different index.
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.