SDL: Fix updating SDL_update_joysticks and SDL_update_sensors in response to hint changes

From d9bda89fcec321e2dc99b5d0e5148ee710aa4d56 Mon Sep 17 00:00:00 2001
From: diddily <[EMAIL REDACTED]>
Date: Mon, 25 Jul 2022 10:03:36 -0400
Subject: [PATCH] Fix updating SDL_update_joysticks and SDL_update_sensors in
 response to hint changes

Hint callbacks are called before the actual value in the hint is changed, so the functions SDL_AutoUpdateJoysticksChanged and SDL_AutoUpdateSensorsChanged were not actually properly updating their respective variables in repsonse to their auto update hint changing.

Instead, we pull the new hint value out of the value passed into the callback and use that to update the variables. Assume true on a null value as that was the previous behavior and it matches with the default values of SDL_update_joysticks/SDL_update_sensors.
---
 src/events/SDL_events.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 6e5ee319f46..fa58ed1461f 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -102,9 +102,9 @@ static struct
 static SDL_bool SDL_update_joysticks = SDL_TRUE;
 
 static void
-SDL_CalculateShouldUpdateJoysticks()
+SDL_CalculateShouldUpdateJoysticks(SDL_bool hint_value)
 {
-    if (SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_TRUE) &&
+    if (hint_value &&
         (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) {
         SDL_update_joysticks = SDL_TRUE;
     } else {
@@ -115,7 +115,7 @@ SDL_CalculateShouldUpdateJoysticks()
 static void SDLCALL
 SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
 {
-    SDL_CalculateShouldUpdateJoysticks();
+    SDL_CalculateShouldUpdateJoysticks(SDL_GetStringBoolean(hint, SDL_TRUE));
 }
 
 #endif /* !SDL_JOYSTICK_DISABLED */
@@ -126,9 +126,9 @@ SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *old
 static SDL_bool SDL_update_sensors = SDL_TRUE;
 
 static void
-SDL_CalculateShouldUpdateSensors()
+SDL_CalculateShouldUpdateSensors(SDL_bool hint_value)
 {
-    if (SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_TRUE) &&
+    if (hint_value &&
         !SDL_disabled_events[SDL_SENSORUPDATE >> 8]) {
         SDL_update_sensors = SDL_TRUE;
     } else {
@@ -139,7 +139,7 @@ SDL_CalculateShouldUpdateSensors()
 static void SDLCALL
 SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
 {
-    SDL_CalculateShouldUpdateSensors();
+    SDL_CalculateShouldUpdateSensors(SDL_GetStringBoolean(hint, SDL_TRUE));
 }
 
 #endif /* !SDL_SENSOR_DISABLED */
@@ -1306,10 +1306,10 @@ SDL_EventState(Uint32 type, int state)
         }
 
 #if !SDL_JOYSTICK_DISABLED
-        SDL_CalculateShouldUpdateJoysticks();
+        SDL_CalculateShouldUpdateJoysticks(SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_TRUE));
 #endif
 #if !SDL_SENSOR_DISABLED
-        SDL_CalculateShouldUpdateSensors();
+        SDL_CalculateShouldUpdateSensors(SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_TRUE));
 #endif
     }