SDL: Ignore spurious reply packets when reading Nintendo Switch controller reports

From 5ee9a840b1b5f8f1dc60cb831d0a1143153ce51d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 12 Jun 2024 23:03:50 -0700
Subject: [PATCH] Ignore spurious reply packets when reading Nintendo Switch
 controller reports

---
 src/joystick/hidapi/SDL_hidapi_switch.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 7f5e04f256680..73967e7378d1c 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -2525,6 +2525,10 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
             continue;
         }
 
+        if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_SubcommandReply) {
+            continue;
+        }
+
         if (ctx->m_bInputOnly) {
             HandleInputOnlyControllerState(joystick, ctx, (SwitchInputOnlyControllerStatePacket_t *)&ctx->m_rgucReadBuffer[0]);
         } else {