Skip to content

Commit 4b4f6b3

Browse files
ReRezdslouken
authored andcommitted
Fix: GameCube controller adapter hotplug not working
SDL_PrivateJoystickAdded was called before setting the InstanceId in the adapters ctx->joysticks array. This would eventually broadcast the SDL_EVENT_JOYSTICK_ADDED event with the new InstanceId, if your program listens for the added events and opens joysticks at that point it would always fail because there would be no matching InstanceId in the ctx->joysticks array. (cherry picked from commit afd1e51)
1 parent 2163887 commit 4b4f6b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/joystick/hidapi/SDL_hidapijoystick.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,12 @@ SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJo
822822

823823
++SDL_HIDAPI_numjoysticks;
824824

825-
SDL_PrivateJoystickAdded(joystickID);
826-
827825
if (pJoystickID) {
828826
*pJoystickID = joystickID;
829827
}
828+
829+
SDL_PrivateJoystickAdded(joystickID);
830+
830831
return SDL_TRUE;
831832
}
832833

0 commit comments

Comments
 (0)