Browse Source

Fixed a crash when unplugging a Steam Controller dongle

Sam Lantinga 1 năm trước cách đây
mục cha
commit
184da780f5
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      src/joystick/hidapi/SDL_hidapi_steam.c

+ 3 - 1
src/joystick/hidapi/SDL_hidapi_steam.c

@@ -1250,7 +1250,9 @@ static void ControllerDisconnected(SDL_HIDAPI_Device *device, SDL_Joystick **joy
 {
     SDL_DriverSteam_Context *ctx = (SDL_DriverSteam_Context *)device->context;
 
-    HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
+    if (device->joysticks) {
+        HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
+    }
     ctx->connected = false;
     *joystick = NULL;
 }