SDL: Prevent GameInput from picking up controllers when SDL_HINT_JOYSTICK_GAMEINPUT is disabled

From c4cfb739ae66dd256ea1c16273a93994a51225db Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 21 Sep 2026 09:07:28 -0700
Subject: [PATCH] Prevent GameInput from picking up controllers when
 SDL_HINT_JOYSTICK_GAMEINPUT is disabled

---
 src/joystick/gdk/SDL_gameinputjoystick.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/joystick/gdk/SDL_gameinputjoystick.cpp b/src/joystick/gdk/SDL_gameinputjoystick.cpp
index 7ee50c06c7c2c..a92ef06ab3cf8 100644
--- a/src/joystick/gdk/SDL_gameinputjoystick.cpp
+++ b/src/joystick/gdk/SDL_gameinputjoystick.cpp
@@ -283,7 +283,11 @@ static void GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
     }
 #endif
 
-    if (!GAMEINPUT_InternalIsGamepad(info) && raw_type == SDL_GAMEINPUT_RAWTYPE_NONE) {
+    if (GAMEINPUT_InternalIsGamepad(info)) {
+        if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_GAMEINPUT_DEFAULT)) {
+            goto done;
+        }
+    } else if (raw_type == SDL_GAMEINPUT_RAWTYPE_NONE) {
 #if defined(SDL_JOYSTICK_DINPUT)
         // Let other backends handle non-gamepad controllers to possibly avoid bugs and/or regressions.
         if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_DIRECTINPUT, true)) {