Commit 545febcf21023c87276d105a8567ca2c962f0684

Sam Lantinga 2018-10-25T13:22:34

Fixed initializing XInput user index

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index c68dbfd..8fa4674 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -307,6 +307,7 @@ SDL_JoystickOpen(int device_index)
     joystick->driver = driver;
     joystick->instance_id = instance_id;
     joystick->attached = SDL_TRUE;
+    joystick->userid = -1;
 
     if (driver->Open(joystick, device_index) < 0) {
         SDL_free(joystick);
@@ -322,7 +323,6 @@ SDL_JoystickOpen(int device_index)
     }
 
     joystick->guid = driver->GetDeviceGUID(device_index);
-    joystick->userid = -1;
 
     if (joystick->naxes > 0) {
         joystick->axes = (SDL_JoystickAxisInfo *) SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo));