Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIN32) Fix Pause vs NumLock in dinput/sdl2 #15533

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions gfx/common/win32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,9 +1081,16 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
uint16_t mod = 0;
unsigned keycode = 0;
unsigned keysym = (lparam >> 16) & 0xff;
bool extended = (lparam >> 24) & 0x1;

/* extended keys will map to dinput if the high bit is set */
if ((lparam >> 24 & 0x1))
if (extended)
keysym |= 0x80;

/* NumLock vs Pause correction */
if (GetKeyState(VK_NUMLOCK) & 0x80 && extended)
keysym &= ~0x80;
else if (GetKeyState(VK_PAUSE) & 0x80 && !extended)
keysym |= 0x80;

keycode = input_keymaps_translate_keysym_to_rk(keysym);
Expand Down Expand Up @@ -1327,9 +1334,16 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
uint16_t mod = 0;
unsigned keycode = 0;
unsigned keysym = (lparam >> 16) & 0xff;
bool extended = (lparam >> 24) & 0x1;

/* extended keys will map to dinput if the high bit is set */
if ((lparam >> 24 & 0x1))
if (extended)
keysym |= 0x80;

/* NumLock vs Pause correction */
if (GetKeyState(VK_NUMLOCK) & 0x80 && extended)
keysym &= ~0x80;
else if (GetKeyState(VK_PAUSE) & 0x80 && !extended)
keysym |= 0x80;

keycode = input_keymaps_translate_keysym_to_rk(keysym);
Expand Down
Loading