SDL: SDL_XINPUT_Enabled() returns false until XInput DLL is successfully loaded (f5ed1)

From f5ed158d1f59d0d3bfe65f6c3603c5082c560797 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 6 Sep 2024 11:19:19 -0700
Subject: [PATCH] SDL_XINPUT_Enabled() returns false until XInput DLL is
 successfully loaded

We make sure we initialize XInput first, so that anything checking whether it's enabled gets a valid result based on whether we were able to load it or not.

(cherry picked from commit 8f46cb771c7c5e8aa4193b01f14f63e3ab7b4d8f)
---
 src/joystick/windows/SDL_windowsjoystick.c | 6 +++---
 src/joystick/windows/SDL_xinputjoystick.c  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c
index 49e4c59757ce0..634c81bb89389 100644
--- a/src/joystick/windows/SDL_windowsjoystick.c
+++ b/src/joystick/windows/SDL_windowsjoystick.c
@@ -377,7 +377,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
 #ifdef SDL_JOYSTICK_XINPUT
             /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
             SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
-            if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
+            if (SDL_XINPUT_Enabled()) {
                 /* scan for any change in XInput devices */
                 Uint8 userId;
                 for (userId = 0; userId < XUSER_MAX_COUNT; userId++) {
@@ -473,12 +473,12 @@ void WINDOWS_JoystickQuit(void);
  */
 static int WINDOWS_JoystickInit(void)
 {
-    if (SDL_DINPUT_JoystickInit() < 0) {
+    if (SDL_XINPUT_JoystickInit() < 0) {
         WINDOWS_JoystickQuit();
         return -1;
     }
 
-    if (SDL_XINPUT_JoystickInit() < 0) {
+    if (SDL_DINPUT_JoystickInit() < 0) {
         WINDOWS_JoystickQuit();
         return -1;
     }
diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 59c60835335b9..02cb445cc4109 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -39,7 +39,7 @@ extern "C" {
 /*
  * Internal stuff.
  */
-static SDL_bool s_bXInputEnabled = SDL_TRUE;
+static SDL_bool s_bXInputEnabled = SDL_FALSE;
 
 static SDL_bool SDL_XInputUseOldJoystickMapping(void)
 {