Skip to content

Commit afd1e51

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.
1 parent 510126e commit afd1e51

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
@@ -764,11 +764,12 @@ bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoysti
764764

765765
++SDL_HIDAPI_numjoysticks;
766766

767-
SDL_PrivateJoystickAdded(joystickID);
768-
769767
if (pJoystickID) {
770768
*pJoystickID = joystickID;
771769
}
770+
771+
SDL_PrivateJoystickAdded(joystickID);
772+
772773
return true;
773774
}
774775

0 commit comments

Comments
 (0)