(Win32) Fix numlock/pause key release events

On Win32, the numlock and pause keys need special handling. But the existing code did only handle it correctly for pressing and not releasing. It separately called GetKeyState for the two keys which only returned true while pressing a key and not while releasing it. This then caused the releasing of the pause key to be treated as releasing the numlock key and vice versa. This fix handles releasing the two keys correctly.
This commit is contained in:
Bernhard Schelling 2024-05-19 23:56:54 +09:00 committed by LibretroAdmin
parent caeb3fafdc
commit e27fcf64a8

View File

@ -1091,16 +1091,14 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd,
unsigned keysym = (lparam >> 16) & 0xff;
bool extended = (lparam >> 24) & 0x1;
/* NumLock vs Pause correction */
if (keysym == 0x45 && (wparam == VK_NUMLOCK || wparam == VK_PAUSE))
extended = !extended;
/* extended keys will map to dinput if the high bit is set */
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);
if (GetKeyState(VK_SHIFT) & 0x80)
@ -1344,16 +1342,14 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd,
unsigned keysym = (lparam >> 16) & 0xff;
bool extended = (lparam >> 24) & 0x1;
/* NumLock vs Pause correction */
if (keysym == 0x45 && (wparam == VK_NUMLOCK || wparam == VK_PAUSE))
extended = !extended;
/* extended keys will map to dinput if the high bit is set */
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);
switch (keycode)
{