Skip to content

Commit 0f2c570

Browse files
committed
extend rawkb hint with nohotkey & appkey options
1 parent 510c7ed commit 0f2c570

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/SDL3/SDL_hints.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,12 +4115,14 @@ extern "C" {
41154115
#define SDL_HINT_WINDOWS_GAMEINPUT "SDL_WINDOWS_GAMEINPUT"
41164116

41174117
/**
4118-
* A variable controlling whether raw keyboard events are used on Windows.
4118+
* A variable controlling if and how raw keyboard events are used on Windows.
41194119
*
41204120
* The variable can be set to the following values:
41214121
*
4122-
* - "0": The Windows message loop is used for keyboard events. (default)
4123-
* - "1": Low latency raw keyboard events are used.
4122+
* - "0": Raw keyboard events are not used (default)
4123+
* - "1": Raw keyboard events are used.
4124+
* - "2": Raw keyboard events are used, with RIDEV_NOHOTKEYS. (available since SDL 3.4.0)
4125+
* - "2": Raw keyboard events are used, with RIDEV_NOHOTKEYS and RIDEV_APPKEYS. (available since SDL 3.4.0)
41244126
*
41254127
* This hint can be set anytime.
41264128
*

src/video/windows/SDL_windowsrawinput.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param)
7878
devices[count].usUsagePage = USB_USAGEPAGE_GENERIC_DESKTOP;
7979
devices[count].usUsage = USB_USAGE_GENERIC_KEYBOARD;
8080
devices[count].dwFlags = 0;
81+
int rawmode = 3 & SDL_atoi(SDL_GetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD));
82+
if (rawmode > 1) {
83+
devices[count].dwFlags |= RIDEV_NOHOTKEYS;
84+
if (rawmode == 3) {
85+
devices[count].dwFlags |= RIDEV_APPKEYS;
86+
}
87+
}
8188
devices[count].hwndTarget = window;
8289
++count;
8390
}

0 commit comments

Comments
 (0)