Commit 3e114872e842879c048b2a7808f2cdbfeb2228fe

Cameron Gutman 2022-06-30T20:36:45

joystick: Fix redetection of HIDAPI joysticks after reinitializing The HIDAPI joystick driver doesn't properly reset the change counter it uses to track if re-enumeration is needed when the joystick subsystem is quit and then reinitialized. The first SDL_Init(SDL_INIT_JOYSTICK) will result in the expected HIDAPI joysticks appearing, but subsequent calls will result in no joysticks being enumerated until another HIDAPI joystick is added or removed from the system.

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index b0b9a50..cf35538 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -1076,6 +1076,7 @@ HIDAPI_JoystickQuit(void)
 
     SDL_hid_exit();
 
+    SDL_HIDAPI_change_count = 0;
     shutting_down = SDL_FALSE;
     initialized = SDL_FALSE;
 }