Closed TempoLabGames closed 10 months ago
Point 3 has been addressed in 2.28.2 with SDL_HINT_JOYSTICK_WGI. Thanks!
Are you still seeing this in the latest version of SDL?
I've just retested on both my Windows 11 and Windows 10 machines with SDL 2.28.5 and reproduced issues 1 and 2 from my original report.
However, since the introduction of SDL_HINT_JOYSTICK_WGI, I've found disabling that by default using SDL_SetHintWithPriority(SDL_HINT_JOYSTICK_WGI, "0", SDL_HINT_DEFAULT)
to be an acceptable workaround.
Normally WGI will ignore controllers that are handled by XInput and raw input, but it looks like on your system WGI is seeing the controller before it's available to raw input.
The issue with events and device indices referring to the same device is inherent in referencing devices by index, which is redesigned in SDL3.
Given that you have a reasonable workaround and future versions of SDL will hopefully use GDK, I'll go ahead and close this for now.
Thanks!
Under some circumstances, Windows.Gaming.Input detects a duplicate joystick for an XBox controller. I have reproduced the bug on both Windows 10 and Windows 11, but it manifests differently.
Encountered in SDL version 2.28.1 (from https://github.com/libsdl-org/SDL/releases/download/release-2.28.1/SDL2-devel-2.28.1-VC.zip).
Test program:
On Windows 11, the duplicate controller is not detected on startup, but appears if the controller is unplugged and reconnected.
(For all below tests, the controller starts plugged in, then is unplugged, then reconnected.)
If all other backends are disabled, the Windows.Gaming.Input instance is detected on startup and functions as expected.
On Windows 10, this functions correctly with default settings:
However, disabling DirectInput appears to manifest the duplicate device, which sometimes collides with the existing device:
I also observed this collision problem rarely on Windows 11, but it does not reproduce as readily.
(Note that extending this sample to display input events won't show duplicated inputs because the Windows.Gaming.Input joystick doesn't appear to receive button presses when run from a console application. However, in my actual application, each button press is reported once per joystick object.)
This appears to show three separate problems:
The Windows.Gaming.Input driver can return duplicate devices when used in conjunction with other drivers. I've skimmed through the code but can't see how SDL ordinarily deduplicates controllers that are visible via multiple input drivers.
The joystick
device_index
may occasionally reference the wrong joystick object based on what seems to be a race condition.There is no SDL hint to disable the Windows.Gaming.Input subsystem. This was mentioned in #7068 but seems to have been missed amongst the other info. Currently the only way to remove these devices is to filter out devices without a path, or remove the subsystem entirely and recompile.