SDL: Don't modify the Nintendo Switch home LED state by default

From 503ea8e89f519e79f44451af945bf00df9d6cad0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 25 Aug 2021 14:41:58 -0700
Subject: [PATCH] Don't modify the Nintendo Switch home LED state by default

---
 include/SDL_hints.h                     |  6 ++++--
 src/joystick/hidapi/SDL_hidapi_switch.c | 11 +++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index c18c14f8db..f07ee19e49 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -711,8 +711,10 @@ extern "C" {
  *  \brief  A variable controlling whether the Home button LED should be turned on when a Nintendo Switch controller is opened
  *
  *  This variable can be set to the following values:
- *    "0"       - home button LED is left off
- *    "1"       - home button LED is turned on (the default)
+ *    "0"       - home button LED is turned off
+ *    "1"       - home button LED is turned on
+ *
+ *  By default the Home button LED state is not changed.
  */
 #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED"
 
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 150fde6f2b..610bf35dd6 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -936,10 +936,13 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti
 
         /* Set the LED state */
         if (ctx->m_bHasHomeLED) {
-            if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED, SDL_TRUE)) {
-                SetHomeLED(ctx, 100);
-            } else {
-                SetHomeLED(ctx, 0);
+            const char *hint = SDL_GetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED);
+            if (hint && *hint) {
+                if (SDL_GetStringBoolean(hint, SDL_TRUE)) {
+                    SetHomeLED(ctx, 100);
+                } else {
+                    SetHomeLED(ctx, 0);
+                }
             }
         }
         SetSlotLED(ctx, (joystick->instance_id % 4));