On Thu Mar 19 13:34:52 2026 +0000, Connor McAdams wrote:
This is a bit tricky, and IMO comes down to how closely we want to match native's behavior. A `guidInstance` value can represent a different device path in separate processes, it has to do with device enumeration order. Enumeration order is determined by the time of when a process first sees a joystick's device instance ID. I have tests for this in my branch [here](https://gitlab.winehq.org/cmcadams/wine/-/commits/WIP/dinput-instance-guid-v...), under `dinput/tests: Add tests for joystick enumeration order.` This is also why I chose to use an array instead of a list, to make it easier to reorder things after populating the array. Our enumeration code uses setupapi, which enumerates by `VID/PID` pairs, and within `VID/PID` pairs it enumerates based on the device instance ID string in ascending order. I have code in that branch to sort the array based on connection order after populating it. So, the registry only stores `guidInstance` and `DIPROP_JOYSTICKID` values for a particular VID/PID/device index pair, and that VID/PID/device index pair can represent a different device path per-process. Beyond that the device path for a pairing can change depending on if a device is connected/disconnected, which is why I think a local cache is necessary. Does that make sense? The whole thing is kind of a mess, and I may have misunderstood what you're proposing :) I'm not convinced that it is like that. From your branch, I believe this patch: [dinput-processes.patch](/uploads/6daf552644835699012fbf57f7dcdf4b/dinput-processes.patch) shows that every process has the same view of enumerated devices as soon as they have been enumerated once.
The `test_joystick_order_process` function (executed from `run_in_process( "test_joystick_order" )`) clears the system-wide registry, plugs devices in some order, enumerates them, then unplug the devices and plugs them back in reverse order, then enumerates them again. It shows that from a given process, the device enumeration is stable wrt plugging order as soon as devices have been enumerated. The patch adds extra checks, in `test_joystick_order_check_process` (executed from `run_in_process( "test_joystick_order_check" )`) with dinput device enumeration only (no registry reset or device changes) done in a separate process, each time the process enumerates its devices, and it shows that from a separate process, the order is the same as from the parent process, indicating that the device enumeration is also stable system-wide and not only per-process. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10364#note_133528