diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2019-12-04 19:13:43 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2019-12-04 19:13:43 +0200 |
| commit | 8470767bc9a51ae73b2b70b4a5ed57f666fdc024 (patch) | |
| tree | 5e5eb9f169bdb5a6103ec77918422459de56c73c | |
| parent | 3d936061c8a39e4918399a805aac6b33ed97310a (diff) | |
| download | raylib-fix-mouse-released.tar.gz raylib-fix-mouse-released.zip | |
Fix `IsMouseButtonReleased()` when press/release events come too fastfix-mouse-released
If press/release events for a mouse button come too fast, then using
`IsMouseButtonReleased()` does not work. This has been noticed when
using a touchpad on Linux when tapping with two fingers two emulate
right mouse button click.
The situation looks like this:
```
BeginDrawing <-- current==released, previous==released
Pressed <-- current=pressed
Released <-- current=released
IsMouseButtonReleased <-- returns false because current==previous
EndDrawing <-- previous=released
```
The fix is to update the previous mouse button state in addition to
current mouse button state when `MouseButtonCallback()` is called by
glfw. Now the situation is as follows:
```
BeginDrawing <-- current==released, previous==released
Pressed <-- current=pressed, previous=released
Released <-- current=released, previous=pressed
IsMouseButtonReleased <-- returns true because current!=previous
EndDrawing <-- previous=released
```
| -rw-r--r-- | src/core.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -3903,6 +3903,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i // GLFW3 Mouse Button Callback, runs on mouse button pressed static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods) { + previousMouseState[button] = currentMouseState[button]; currentMouseState[button] = action; #if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) |
