Преглед изворни кода

Fixed crash when using the NVIDIA Shield controller

Sam Lantinga пре 4 месеци
родитељ
комит
0b9946d7bf
1 измењених фајлова са 3 додато и 6 уклоњено
  1. 3 6
      src/joystick/hidapi/SDL_hidapi_shield.c

+ 3 - 6
src/joystick/hidapi/SDL_hidapi_shield.c

@@ -482,13 +482,13 @@ static bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
 #ifdef DEBUG_SHIELD_PROTOCOL
 #ifdef DEBUG_SHIELD_PROTOCOL
         HIDAPI_DumpPacket("NVIDIA SHIELD packet: size = %d", data, size);
         HIDAPI_DumpPacket("NVIDIA SHIELD packet: size = %d", data, size);
 #endif
 #endif
+        if (!joystick) {
+            continue;
+        }
 
 
         // Byte 0 is HID report ID
         // Byte 0 is HID report ID
         switch (data[0]) {
         switch (data[0]) {
         case k_ShieldReportIdControllerState:
         case k_ShieldReportIdControllerState:
-            if (!joystick) {
-                break;
-            }
             if (size == 16) {
             if (size == 16) {
                 HIDAPI_DriverShield_HandleStatePacketV103(joystick, ctx, data, size);
                 HIDAPI_DriverShield_HandleStatePacketV103(joystick, ctx, data, size);
             } else {
             } else {
@@ -496,9 +496,6 @@ static bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
             }
             }
             break;
             break;
         case k_ShieldReportIdControllerTouch:
         case k_ShieldReportIdControllerTouch:
-            if (!joystick) {
-                break;
-            }
             HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size);
             HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size);
             break;
             break;
         case k_ShieldReportIdCommandResponse:
         case k_ShieldReportIdCommandResponse: