SDL/src/joystick
Sam Lantinga ddeaa6016c Fixed bug 3299 - DirectInput: Incorrect joystick mapping when attaching new joysticks
Jimb Esser

Note: This is using DirectInput, I have to disable XInput as that causes all but the first 4 controllers to be completely ignored by SDL (I can find no way to reconcile XInput devices with DirectInput devices, otherwise I would make a patch that accepts the fifth and later controllers with DirectInput...).  XInput does not seem to have the problem below, only DirectInput.

I plug in 3 identical wireless Xbox 360 controllers, call them J1, J2, J3.  Direct Input shows them as having GUIDs G1, G2, G3.  I unplug J1, then J2 and J3 show up as having GUIDs G1 and G2!  Not so "unique"...  I start my SDL app when just J2 and J3 are plugged in, and open J2 and J3.  Then I plug in a new controller, SDL sees that now G3 exists, assigns that a new SDL joystick instance ID, which I request to be opened, but G3 at this point is J3, which I already had opened!  So I end up with two instances of J3 opened, and none of J1.  "Re-"opening G1 would get the actual handle to the newly attached controller, but there's no current way to know this.  This is clearly a bug or poor design in DirectInput or my wireless receiver drivers, but is a showstopping bug for my 8-20 player games (as soon as any one controller runs out of battery or goes to sleep and gets turned back on, suddenly things are busted requiring a restart (or, at least, a reinitialization of all controllers - the game can't go on)).

The solution I found is to use HID paths instead of GUIDs to uniquely identify joysticks.  GUIDs are still needed to open a controller, however I have added code to re-find the GUIDs for all joysticks whenever a new joystick is attached or removed.  This does now require opening of all joysticks (instead of just enumerating them), though if your app, like mine, is opening all of them anyway so that any can press a button to join, that doesn't change much (although perhaps they joysticks should be kept open in this case, instead of closed and re-opened).  If your app only ever opens one joystick, this will do more work at startup than it did previously.
2017-08-13 20:42:41 -07:00
..
android Fixed bug 3191 - haptic system on android? 2017-08-12 08:15:09 -07:00
bsd Fixed binding the D-pad on some Super NES style controllers 2017-01-03 23:39:28 -08:00
darwin Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
dummy Updated copyright for 2017 2017-01-01 18:33:28 -08:00
emscripten Removed unused hint includes. 2017-06-08 22:40:09 +02:00
haiku haiku: Changed header paths to be more compatible. 2017-07-29 23:00:14 +02:00
iphoneos Fixed build on Apple TV 2017-02-02 16:56:02 -08:00
linux Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
psp Updated copyright for 2017 2017-01-01 18:33:28 -08:00
windows Fixed bug 3299 - DirectInput: Incorrect joystick mapping when attaching new joysticks 2017-08-13 20:42:41 -07:00
SDL_gamecontroller.c Added check for XBOX in addition to Xbox and X-Box 2017-08-13 20:39:00 -07:00
SDL_gamecontrollerdb.h Fixed bug 3672 - Add joystick to controllerdb 2017-08-09 20:20:35 -07:00
SDL_joystick.c Fixed bug 2950 - wrong axes values are set on joystick initialization 2017-08-12 17:41:59 -07:00
SDL_joystick_c.h Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
SDL_sysjoystick.h Implemented Linux joystick blacklist 2017-04-06 06:30:43 -07:00
sort_controllers.py Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00