SDL: Update the sensors before the joysticks so the gamepad code gets fresh sensor readings

From 329e1b8b6aba88fe7271a112fc90cf2bdc10f4ca Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 19 Jun 2023 19:42:01 -0700
Subject: [PATCH] Update the sensors before the joysticks so the gamepad code
 gets fresh sensor readings

---
 src/events/SDL_events.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index f9b8dca3e1a7..7e1130b0cf1e 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -854,13 +854,6 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel)
         _this->PumpEvents(_this);
     }
 
-#ifndef SDL_JOYSTICK_DISABLED
-    /* Check for joystick state change */
-    if (SDL_update_joysticks) {
-        SDL_UpdateJoysticks();
-    }
-#endif
-
 #ifndef SDL_SENSOR_DISABLED
     /* Check for sensor state change */
     if (SDL_update_sensors) {
@@ -868,6 +861,13 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel)
     }
 #endif
 
+#ifndef SDL_JOYSTICK_DISABLED
+    /* Check for joystick state change */
+    if (SDL_update_joysticks) {
+        SDL_UpdateJoysticks();
+    }
+#endif
+
     SDL_SendPendingSignalEvents(); /* in case we had a signal handler fire, etc. */
 
     if (push_sentinel && SDL_EventEnabled(SDL_EVENT_POLL_SENTINEL)) {