1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Win32: Use non-async key state for modifier hack

The synchronous key state seems to make more sense in context.

(cherry picked from commit a491b0698c)
This commit is contained in:
Camilla Löwy 2020-01-15 16:26:29 +01:00
parent 8552152f80
commit 0af3bf3b36

View File

@ -448,28 +448,6 @@ static int getKeyMods(void)
return mods; return mods;
} }
// Retrieves and translates modifier keys
//
static int getAsyncKeyMods(void)
{
int mods = 0;
if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
mods |= GLFW_MOD_SHIFT;
if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
mods |= GLFW_MOD_CONTROL;
if (GetAsyncKeyState(VK_MENU) & 0x8000)
mods |= GLFW_MOD_ALT;
if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000)
mods |= GLFW_MOD_SUPER;
if (GetAsyncKeyState(VK_CAPITAL) & 1)
mods |= GLFW_MOD_CAPS_LOCK;
if (GetAsyncKeyState(VK_NUMLOCK) & 1)
mods |= GLFW_MOD_NUM_LOCK;
return mods;
}
// Translates a Windows key to the corresponding GLFW key // Translates a Windows key to the corresponding GLFW key
// //
static int translateKey(WPARAM wParam, LPARAM lParam) static int translateKey(WPARAM wParam, LPARAM lParam)
@ -1951,12 +1929,12 @@ void _glfwPlatformPollEvents(void)
const int key = keys[i][1]; const int key = keys[i][1];
const int scancode = _glfw.win32.scancodes[key]; const int scancode = _glfw.win32.scancodes[key];
if ((GetAsyncKeyState(vk) & 0x8000)) if ((GetKeyState(vk) & 0x8000))
continue; continue;
if (window->keys[key] != GLFW_PRESS) if (window->keys[key] != GLFW_PRESS)
continue; continue;
_glfwInputKey(window, key, scancode, GLFW_RELEASE, getAsyncKeyMods()); _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods());
} }
} }
} }