From c0da7f1065f77f6ae658f2919b65f6793f2d3cd1 Mon Sep 17 00:00:00 2001 From: di-ant Date: Tue, 23 Nov 2021 19:31:23 +0600 Subject: [PATCH] Android touch fix: check for POINTER_UP and UP events --- src/rcore.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index ec1601ca1..1dece1a09 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -5439,6 +5439,14 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) return 0; } + int32_t action = AMotionEvent_getAction(event); + unsigned int flags = action & AMOTION_EVENT_ACTION_MASK; + + // Don't register pointers lifted during this action, + // otherwise they get stuck until next pointer event + if (flags == AMOTION_EVENT_ACTION_POINTER_UP || flags == AMOTION_EVENT_ACTION_UP) + CORE.Input.Touch.pointCount -= 1; + // Register touch points count CORE.Input.Touch.pointCount = AMotionEvent_getPointerCount(event); @@ -5455,9 +5463,6 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) CORE.Input.Touch.position[i].y /= (float)GetScreenHeight(); } - int32_t action = AMotionEvent_getAction(event); - unsigned int flags = action & AMOTION_EVENT_ACTION_MASK; - if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1; else if (flags == AMOTION_EVENT_ACTION_UP) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;