Fixed bug 5493 - Hint to let the user opt out of having Switch controllers' Home button lit when opened

jibb

New hint to let the user opt out of having Switch controllers' Home button lit when opened.

This is more consistent with the Switch itself (which doesn't light the button normally) and may be preferred by users who may disconnect their controller without letting the application close it.

I think this warrants a Switch-specific hint because the default behaviour is unusual (inconsistent with using a Switch controller on a Switch itself or with some other programs on PC), and because of that it's distinct from other lights (the player number on Switch controllers and the player colour on PlayStation controllers).
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index 78173c3..bacfe17 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -696,6 +696,15 @@
  */
 #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH"
 
+/**
+ *  \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)
+ */
+#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED"
+
  /**
   *  \brief  A variable controlling whether Switch Joy-Cons should be treated the same as Switch Pro Controllers when using the HIDAPI driver.
   *
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 213344f..8a65853 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -876,7 +876,11 @@
 
         /* Set the LED state */
         if (ctx->m_bHasHomeLED) {
-            SetHomeLED(ctx, 100);
+            if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED, SDL_TRUE)) {
+                SetHomeLED(ctx, 100);
+            } else {
+                SetHomeLED(ctx, 0);
+            }
         }
         SetSlotLED(ctx, (joystick->instance_id % 4));