瀏覽代碼

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.
Joe [ReRezd] 3 月之前
父節點
當前提交
afd1e51023
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/joystick/hidapi/SDL_hidapijoystick.c

+ 3 - 2
src/joystick/hidapi/SDL_hidapijoystick.c

@@ -764,11 +764,12 @@ bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJoysti
 
     ++SDL_HIDAPI_numjoysticks;
 
-    SDL_PrivateJoystickAdded(joystickID);
-
     if (pJoystickID) {
         *pJoystickID = joystickID;
     }
+
+    SDL_PrivateJoystickAdded(joystickID);
+
     return true;
 }