SDL: Don't update the report mode until the related hint is set

From 66ecdc69acb1399331f8988e3995763e7345ee8a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 26 Feb 2025 10:40:03 -0800
Subject: [PATCH] Don't update the report mode until the related hint is set

Fixes https://github.com/libsdl-org/SDL/issues/12404
---
 src/joystick/hidapi/SDL_hidapi_switch.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 6e09865df5176..c1bc6d0abfbd3 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -869,33 +869,22 @@ static void SetEnhancedModeAvailable(SDL_DriverSwitch_Context *ctx)
     }
 }
 
-static void SetEnhancedMode(SDL_DriverSwitch_Context *ctx, bool bEnabled)
-{
-    if (bEnabled) {
-        SetEnhancedModeAvailable(ctx);
-    }
-
-    if (bEnabled != ctx->m_bEnhancedMode) {
-        ctx->m_bEnhancedMode = bEnabled;
-
-        UpdateInputMode(ctx);
-    }
-}
-
 static void SetEnhancedReportHint(SDL_DriverSwitch_Context *ctx, HIDAPI_Switch_EnhancedReportHint eEnhancedReportHint)
 {
+    ctx->m_eEnhancedReportHint = eEnhancedReportHint;
+
     switch (eEnhancedReportHint) {
     case SWITCH_ENHANCED_REPORT_HINT_OFF:
-        SetEnhancedMode(ctx, false);
+        ctx->m_bEnhancedMode = false;
         break;
     case SWITCH_ENHANCED_REPORT_HINT_ON:
-        SetEnhancedMode(ctx, true);
+        SetEnhancedModeAvailable(ctx);
+        ctx->m_bEnhancedMode = true;
         break;
     case SWITCH_ENHANCED_REPORT_HINT_AUTO:
         SetEnhancedModeAvailable(ctx);
         break;
     }
-    ctx->m_eEnhancedReportHint = eEnhancedReportHint;
 
     UpdateInputMode(ctx);
 }