From 6a2e8a7a9086ac7f0b45897b1944779c98382ac8 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 27 Dec 2015 18:48:14 -0500 Subject: [PATCH] Win: make sure SDL keyboard state reflects system capslock state at startup. --- src/video/windows/SDL_windowskeyboard.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index d56f4042a..2169601e9 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -102,6 +102,20 @@ WIN_InitKeyboard(_THIS) SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows"); + + /* Are system caps/num/scroll lock active? Set our state to match. */ + if (GetKeyState(VK_CAPITAL) & 0x0001) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); + } + if (GetKeyState(VK_NUMLOCK) & 0x0001) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); + } + if (GetKeyState(VK_SCROLL) & 0x0001) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK); + } } void