summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorOskari Timperi <[email protected]>2019-12-04 19:29:11 +0200
committerRay <[email protected]>2019-12-04 18:29:11 +0100
commit8a08a9b2251d7717a1277c2343fb92b36e129644 (patch)
tree9f85eb09c46403693af813374dc010b4611cc75f /src/core.c
parent1b7d136daaa1e82f2d5c9dbf84bd0f1bd4d043a6 (diff)
downloadraylib-8a08a9b2251d7717a1277c2343fb92b36e129644.tar.gz
raylib-8a08a9b2251d7717a1277c2343fb92b36e129644.zip
Fix `IsMouseButtonReleased()` when press/release events come too fast (#1032)
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 ```
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 7ee9cda8..e3303417 100644
--- a/src/core.c
+++ b/src/core.c
@@ -3907,6 +3907,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)