On Thu Nov 28 18:58:25 2024 +0000, Paul Gofman wrote:
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.
I am not reproducing the results you describe here. Attach the full test patch (on top of this MR) so it can be compiled and executed (to be sure the same actual code is tested).
I am running it on real Win11 machine with driver signing enforcement disabled in boot options (choosable with reboot with Shift + Restart option in Start menu).
What it outputs here is: ``` joystick8.c:6097: Subtest hid joystick8.c:6097: Subtest driver joystick8.c:6097: Subtest driver_bus joystick8.c:6097: Subtest driver_hid joystick8.c:6097: Subtest driver_hid_poll joystick8.c:6022: ----1. joystick8.c:5942: L"Wine Test", id 0, inst {6b2c8080-ad8c-11ef-8001-444553540000}, path L"\\?\hid#vid_1209&pid_0001#2&2c33ed5d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:6030: ----2. joystick8.c:5942: L"Wine Test", id 2, inst {d69a7790-a842-11ef-8004-444553540000}, path L"\\?\hid#vid_1209&pid_0002#2&86033a3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:6036: ----3. joystick8.c:5942: L"Wine Test", id 0, inst {6b2c8080-ad8c-11ef-8001-444553540000}, path L"\\?\hid#vid_1209&pid_0001#2&2c33ed5d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:5942: L"Wine Test", id 2, inst {d69a7790-a842-11ef-8004-444553540000}, path L"\\?\hid#vid_1209&pid_0002#2&86033a3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 0004:driver_hid: 47 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 0004:driver_hid: 81 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 0004:driver_bus: 59 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 3504:joystick8: 341 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped.
```
So the second device is created with id 2 at once, even though device 1 is destroyed (probably index 1 is busy with something else).
Maybe your actual test is diffent in some ways, or something in machine setup which makes it always reset indexes, or you are using older Windows and that behaviour changed? FWIW I rebooted the machine before repeating this test to exclude some possible non-persistent leftover devices from previous test run.
[test.patch](/uploads/5c1644a9d0527df7659caf5b07ce1d0f/test.patch)