Fix for Win32 keyboard driver key states

This commit is contained in:
inmarket 2023-07-25 09:44:48 +10:00
parent 025cef93cc
commit f1a34c9852
2 changed files with 20 additions and 1 deletions

View File

@ -31,6 +31,7 @@ FIX: Minor code improvements
FEATURE: Add cmake support
FIX: Add missing driver.mk to SSD1322 driver.
FEATURE: LGDP4532 driver improvements.
FIX: Win32 Keyboard driver now retrieves lock key states on window activate
*** Release 2.9 ***

View File

@ -647,12 +647,30 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
#endif
#if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD
case WM_ACTIVATE:
// Copy the lock key states into the uGFX keyboard as it might have changed while we were away
// For simplicity we do this on both activate and deactivate.
if (keyboard && keyboard->pLayout) {
if (GetKeyState(VK_NUMLOCK) & 1)
keyboard->keystate |= GKEYSTATE_NUMLOCK;
else
keyboard->keystate &= ~GKEYSTATE_NUMLOCK;
if (GetKeyState(VK_CAPITAL) & 1)
keyboard->keystate |= GKEYSTATE_CAPSLOCK;
else
keyboard->keystate &= ~GKEYSTATE_CAPSLOCK;
if (GetKeyState(VK_SCROLL) & 1)
keyboard->keystate |= GKEYSTATE_SCROLLLOCK;
else
keyboard->keystate &= ~GKEYSTATE_SCROLLLOCK;
}
break;
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_KEYDOWN:
case WM_KEYUP:
// A layout is being used: Send scan codes to the keyboard buffer
if (keyboard && keyboard->pLayout && keypos < (int)sizeof(keybuffer)-1 && (wParam & 0xFF) > 0x01) {
if (keyboard && keyboard->pLayout && keypos < (int)sizeof(keybuffer)-1 && (wParam & 0xFF) >= VK_BACK) {
if (Msg == WM_KEYUP || Msg == WM_SYSKEYUP)
keybuffer[keypos++] = 0x00; // Keyup
else if (HIWORD(lParam) & KF_REPEAT)