From 394f52a725446755b53a59f14c8c1d339a929e39 Mon Sep 17 00:00:00 2001 From: Arjun Balgovind <32061677+arjunbalgovind@users.noreply.github.com> Date: Tue, 21 Apr 2020 13:43:52 -0700 Subject: [PATCH] Fix issue where key list would change based on keyboard state (#2221) --- src/common/keyboard_layout.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/keyboard_layout.cpp b/src/common/keyboard_layout.cpp index bf8c24d20d..08c29dd2b1 100644 --- a/src/common/keyboard_layout.cpp +++ b/src/common/keyboard_layout.cpp @@ -62,8 +62,9 @@ void LayoutMap::LayoutMapImpl::UpdateLayout() unknownKeys.clear(); } - unsigned char* btKeys = new unsigned char[256]{ 0 }; - GetKeyboardState(btKeys); + BYTE* btKeys = new BYTE[256]{ 0 }; + // Only set the Caps Lock key to on for the key names in uppercase + btKeys[VK_CAPITAL] = 1; // Iterate over all the virtual key codes. virtual key 0 is not used for (int i = 1; i < 256; i++) @@ -72,7 +73,7 @@ void LayoutMap::LayoutMapImpl::UpdateLayout() UINT scanCode = MapVirtualKeyExW(i, MAPVK_VK_TO_VSC, layout); // Get the unicode representation from the virtual key code and scan code pair to wchar_t szBuffer[3] = { 0 }; - int result = ToUnicodeEx(i, scanCode, (BYTE*)btKeys, szBuffer, 3, 0, layout); + int result = ToUnicodeEx(i, scanCode, btKeys, szBuffer, 3, 0, layout); // If a representation is returned if (result > 0) {