From a66988621adf9dc8057222c07c0836a139becd8e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 7 Jan 2026 10:09:28 -0800
Subject: [PATCH] Added temporary workaround hint
"SDL_WINDOWS_DETECT_DEVICE_HOTPLUG"
Some devices with broken drivers hang when their name is queried, so added a workaround for applications that don't need input device details. The long term fix is to move the hotplug detection into a separate thread.
---
src/video/windows/SDL_windowsevents.c | 4 ++++
src/video/windows/SDL_windowsvideo.c | 2 ++
src/video/windows/SDL_windowsvideo.h | 2 ++
3 files changed, 8 insertions(+)
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 4f16b2de7d9a8..4be7bef794522 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -984,6 +984,10 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check
int new_mouse_count = 0;
SDL_MouseID *new_mice = NULL;
+ if (!_this->internal->detect_device_hotplug) {
+ return;
+ }
+
// Check to see if anything has changed
static Uint64 s_last_device_change;
Uint64 last_device_change = WIN_GetLastDeviceNotification();
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index 5659edaf5b7ee..b7e4991bee413 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -631,6 +631,8 @@ static bool WIN_VideoInit(SDL_VideoDevice *_this)
return false;
}
+ _this->internal->detect_device_hotplug = SDL_GetHintBoolean("SDL_WINDOWS_DETECT_DEVICE_HOTPLUG", true);
+
WIN_InitKeyboard(_this);
WIN_InitMouse(_this);
WIN_InitDeviceNotification();
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index 1773264b4d747..a09066b5620f3 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -583,6 +583,8 @@ struct SDL_VideoData
bool cleared;
+ bool detect_device_hotplug;
+
BYTE *rawinput;
UINT rawinput_offset;
UINT rawinput_size;