SDL: Ignore sensor delta values that look like they're out of range

From afa27243df76f61509d71041fcc8203b545c0388 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 26 Jun 2025 11:10:21 -0700
Subject: [PATCH] Ignore sensor delta values that look like they're out of
 range

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

diff --git a/src/joystick/hidapi/SDL_hidapi_8bitdo.c b/src/joystick/hidapi/SDL_hidapi_8bitdo.c
index e9410157ffb98..d1167586d0766 100644
--- a/src/joystick/hidapi/SDL_hidapi_8bitdo.c
+++ b/src/joystick/hidapi/SDL_hidapi_8bitdo.c
@@ -589,7 +589,10 @@ static void HIDAPI_Driver8BitDo_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
                 } else {
                     delta = (SDL_MAX_UINT32 - ctx->last_tick + tick + 1);
                 }
-                ctx->sensor_timestamp_interval = SDL_US_TO_NS(delta);
+                // Sanity check the delta value
+                if (delta < 100000) {
+                    ctx->sensor_timestamp_interval = SDL_US_TO_NS(delta);
+                }
             }
             ctx->last_tick = tick;
         }