Win32: Cleanup

This commit is contained in:
Camilla Löwy 2017-01-29 18:47:59 +01:00
parent 260dbf0a1d
commit 43c1910453

View File

@ -1413,28 +1413,24 @@ void _glfwPlatformPollEvents(void)
handle = GetActiveWindow();
if (handle)
{
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
// This is the only async event handling in GLFW, but it solves some
// nasty problems
// NOTE: Shift keys on Windows tend to "stick" when both are pressed as
// no key up message is generated by the first key release
// HACK: Query actual key state and synthesize release events as needed
window = GetPropW(handle, L"GLFW");
if (window)
{
const int mods = getAsyncKeyMods();
const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
// Get current state of left and right shift keys
const int lshiftDown = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;
const int rshiftDown = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;
// See if this differs from our belief of what has happened
// (we only have to check for lost key up events)
if (!lshiftDown && window->keys[GLFW_KEY_LEFT_SHIFT] == 1)
if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
{
const int mods = getAsyncKeyMods();
const int scancode = _glfw.win32.scancodes[GLFW_KEY_LEFT_SHIFT];
_glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);
}
if (!rshiftDown && window->keys[GLFW_KEY_RIGHT_SHIFT] == 1)
else if (!rshift && window->keys[GLFW_KEY_RIGHT_SHIFT] == GLFW_PRESS)
{
const int mods = getAsyncKeyMods();
const int scancode = _glfw.win32.scancodes[GLFW_KEY_RIGHT_SHIFT];
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);
}