Fix #1112: simultaneous key presses being dropped

This improves the mechanism to check for duplicate key press events, by
checking if the event with the same time code actually corresponds to
the same key.

This will correctly process any key known to GLFW, handling simultanous
presses of different keys, while still filtering out duplicate presses
of the same key.

Note that this still does not properly handle keys that are
GLFW_KEY_UNKNOWN, as I am not aware of a good way to check for previous
events on those keys.
This commit is contained in:
Luca Rood 2019-04-21 16:28:42 +02:00
parent 599fb3de34
commit 4ea7ed07ff
2 changed files with 3 additions and 2 deletions

View File

@ -118,7 +118,7 @@ information on what to include when reporting a bug.
## Changelog ## Changelog
User-visible changes since the last release. - [X11] Bugfix: Simultanous key presses were being ignored (#1112)
## Contact ## Contact

View File

@ -1258,7 +1258,8 @@ static void processEvent(XEvent *event)
// These have the same timestamp as the original event // These have the same timestamp as the original event
// Corresponding release events are filtered out // Corresponding release events are filtered out
// implicitly by the GLFW key repeat logic // implicitly by the GLFW key repeat logic
if (window->x11.lastKeyTime < event->xkey.time) if (window->x11.lastKeyTime < event->xkey.time ||
(key != GLFW_KEY_UNKNOWN && window->keys[key] != GLFW_PRESS))
{ {
if (keycode) if (keycode)
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods); _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);