SDL: Reset enhanced mode state when closing a controller

https://github.com/libsdl-org/SDL/commit/21cc1878f177f1df28c2b3409a06d6250481b086

From 21cc1878f177f1df28c2b3409a06d6250481b086 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 12 Jan 2025 10:45:54 -0800
Subject: [PATCH] Reset enhanced mode state when closing a controller

Fixes https://github.com/libsdl-org/SDL/issues/11912
---
 src/joystick/hidapi/SDL_hidapi_ps4.c    | 4 ++++
 src/joystick/hidapi/SDL_hidapi_ps5.c    | 4 ++++
 src/joystick/hidapi/SDL_hidapi_switch.c | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index b1dd6d047a56d..8f65b954e7cb7 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -1353,6 +1353,10 @@ static void HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joysti
                         SDL_PS4EnhancedReportsChanged, ctx);
 
     ctx->joystick = NULL;
+
+    ctx->report_sensors = false;
+    ctx->enhanced_mode = false;
+    ctx->enhanced_mode_available = false;
 }
 
 static void HIDAPI_DriverPS4_FreeDevice(SDL_HIDAPI_Device *device)
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 688136878e0b6..3fff18e956d05 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -1587,6 +1587,10 @@ static void HIDAPI_DriverPS5_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joysti
                         SDL_PS5PlayerLEDHintChanged, ctx);
 
     ctx->joystick = NULL;
+
+    ctx->report_sensors = false;
+    ctx->enhanced_mode = false;
+    ctx->enhanced_mode_available = false;
 }
 
 static void HIDAPI_DriverPS5_FreeDevice(SDL_HIDAPI_Device *device)
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index b25ae969d0a1e..6d1e0b81c5fc6 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -2766,6 +2766,10 @@ static void HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joy
                         SDL_PlayerLEDHintChanged, ctx);
 
     ctx->joystick = NULL;
+
+    ctx->m_bReportSensors = false;
+    ctx->m_bEnhancedMode = false;
+    ctx->m_bEnhancedModeAvailable = false;
 }
 
 static void HIDAPI_DriverSwitch_FreeDevice(SDL_HIDAPI_Device *device)