Win: make sure SDL keyboard state reflects system capslock state at startup.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 27 Dec 2015 18:48:14 -0500
changeset 9969 be3d04927338
parent 9968 0a420ec24b6a
child 9970 41d6973a250f
Win: make sure SDL keyboard state reflects system capslock state at startup.
src/video/windows/SDL_windowskeyboard.c
--- a/src/video/windows/SDL_windowskeyboard.c	Sun Dec 27 17:55:45 2015 -0500
+++ b/src/video/windows/SDL_windowskeyboard.c	Sun Dec 27 18:48:14 2015 -0500
@@ -102,6 +102,20 @@
     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