From 0b9946d7bfa7931bee598176e3757e5112ccd7d9 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 22 Dec 2025 11:29:47 -0800
Subject: [PATCH] Fixed crash when using the NVIDIA Shield controller
---
src/joystick/hidapi/SDL_hidapi_shield.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c
index 10dcea36d93bd..647dea8d53b36 100644
--- a/src/joystick/hidapi/SDL_hidapi_shield.c
+++ b/src/joystick/hidapi/SDL_hidapi_shield.c
@@ -482,13 +482,13 @@ static bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
#ifdef DEBUG_SHIELD_PROTOCOL
HIDAPI_DumpPacket("NVIDIA SHIELD packet: size = %d", data, size);
#endif
+ if (!joystick) {
+ continue;
+ }
// Byte 0 is HID report ID
switch (data[0]) {
case k_ShieldReportIdControllerState:
- if (!joystick) {
- break;
- }
if (size == 16) {
HIDAPI_DriverShield_HandleStatePacketV103(joystick, ctx, data, size);
} else {
@@ -496,9 +496,6 @@ static bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
}
break;
case k_ShieldReportIdControllerTouch:
- if (!joystick) {
- break;
- }
HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size);
break;
case k_ShieldReportIdCommandResponse: