On Thu Nov 28 18:45:54 2024 +0000, Rémi Bernon wrote:
Fwiw, device that were created before the enumerated ID change still keep the ID they had at the time of creation, so if you create a IDirectInputDevice from device 1 after first enumeration, it gets ID 0 whenever you query it (including after it's been unplugged). Similarly, if you create a IDirectInputDevice from device 2 after second enumeration, it returns ID 0 whenever you query it, even after the third enumeration when the enumerated device 2 has changed to ID 1, and device 1 gets its ID 0 back (so all the created devices are with ID 0, even though they are targeting different hardware devices).
That may work this way (I am still trying to run this test so it doesn't crash) with synthetic driver which just get removed, but if you plug / unplug real controllers they keep indexes, and that what happens in real life with controller replugging outside of synthetic test driver which gets removed completely during the test. Anyway, if you think this doesn't matter I am not up for arguing, that probably doesn't matter for this specific game (mostly because it is utterly broken with multiple controllers anyway, at least if those are not Xbox controllers). The only thing is, hid_joystick_create_device also supports opening device by path, determining the index in this case will need some ugly enumeration but I will figure something out once reproduce these test results locally.