From b96b95dd2baeb87cf854f2a13cdd7587139f8931 Mon Sep 17 00:00:00 2001 From: expikr <77922942+expikr@users.noreply.github.com> Date: Sun, 18 May 2025 04:22:11 +0800 Subject: [PATCH] Add hint for blocking win key when using raw keyboard --- include/SDL3/SDL_hints.h | 14 ++++++++++++++ src/video/windows/SDL_windowsrawinput.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h index 9f1685de76993..2ed8bfe68a278 100644 --- a/include/SDL3/SDL_hints.h +++ b/include/SDL3/SDL_hints.h @@ -4128,6 +4128,20 @@ extern "C" { */ #define SDL_HINT_WINDOWS_RAW_KEYBOARD "SDL_WINDOWS_RAW_KEYBOARD" +/** + * A variable controlling whether to block hotkeys when raw keyboard events are enabled. + * + * The variable can be set to the following values: + * + * - "0": Hotkeys are not blocked. (default) + * - "1": Hotkeys are blocked. + * + * This hint must be set before SDL is initialized. + * + * \since This hint is available since SDL 3.2.16. + */ +#define SDL_HINT_WINDOWS_RAW_KEYBOARD_NOHOTKEY "SDL_WINDOWS_RAW_KEYBOARD_NOHOTKEY" + /** * A variable controlling whether SDL uses Kernel Semaphores on Windows. * diff --git a/src/video/windows/SDL_windowsrawinput.c b/src/video/windows/SDL_windowsrawinput.c index fa249914d0f49..e11787047ca14 100644 --- a/src/video/windows/SDL_windowsrawinput.c +++ b/src/video/windows/SDL_windowsrawinput.c @@ -77,7 +77,7 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param) if (data->flags & ENABLE_RAW_KEYBOARD_INPUT) { devices[count].usUsagePage = USB_USAGEPAGE_GENERIC_DESKTOP; devices[count].usUsage = USB_USAGE_GENERIC_KEYBOARD; - devices[count].dwFlags = 0; + devices[count].dwFlags = SDL_GetHintBoolean(SDL_HINT_WINDOWS_RAW_KEYBOARD_NOHOTKEY) ? 0x200 : 0; devices[count].hwndTarget = window; ++count; }