From 3fb7b4274c88df2b99cd541ae6ea60c8b4a23885 Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:52:02 +0200 Subject: [PATCH] Fix `GetMouseDelta()` issue for Android --- src/rcore_android.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rcore_android.c b/src/rcore_android.c index 7cc71bbca806..5f6f34bab352 100644 --- a/src/rcore_android.c +++ b/src/rcore_android.c @@ -1178,6 +1178,16 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1; else CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0; + // Stores the previous position of touch[0] only while it's active to calculate the delta. + if (flags == AMOTION_EVENT_ACTION_MOVE) + { + CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; + } + else + { + CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0]; + } + // Map touch[0] as mouse input for convenience CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0]; CORE.Input.Mouse.currentWheelMove = (Vector2){ 0.0f, 0.0f };