SDL: Make sure we don't try to use the XInput DLL after it's unloaded (a9fdb)

From a9fdbf7f2100a7249172c1345e27af2910445050 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 26 Jun 2024 15:42:06 -0700
Subject: [PATCH] Make sure we don't try to use the XInput DLL after it's
 unloaded

Steam ran into a crash SDL_XINPUT_JoystickDetect() with XINPUTGETCAPABILITIES being NULL. I'm not sure how that happened, and there may still be a race condition if this is a multi-threaded issue, but at least this is more correct.

(cherry picked from commit 0ae4fd0ec9e2d6b048cde926653b7895b380232b)
(cherry picked from commit ee3b2b7de1000be07339a967385614aa13fcad60)
---
 src/joystick/windows/SDL_xinputjoystick.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c
index 1ae7fb489957e..38c27d80de2ad 100644
--- a/src/joystick/windows/SDL_xinputjoystick.c
+++ b/src/joystick/windows/SDL_xinputjoystick.c
@@ -458,6 +458,7 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
 void SDL_XINPUT_JoystickQuit(void)
 {
     if (s_bXInputEnabled) {
+        s_bXInputEnabled = SDL_FALSE;
         WIN_UnloadXInputDLL();
     }
 }