From 20f7cd72175be1bbb8bf171a922a3749129d2f9c Mon Sep 17 00:00:00 2001 From: Certainty Witch Date: Wed, 17 Mar 2021 14:35:18 +0200 Subject: [PATCH] More QoL changes for touch gliding --- .../duckstation/TouchscreenControllerView.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java index 5cb341cd7..cd55d6d65 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java @@ -461,11 +461,11 @@ public class TouchscreenControllerView extends FrameLayout { final int y = (int) event.getY(i); if (rect.contains(x, y)) { buttonView.setPressed(true); - int pointerID = event.getPointerId(i); - if (!mGlidePairs.containsKey(pointerID) && !mGlidePairs.containsValue(buttonView)) { + final int pointerId = event.getPointerId(i); + if (!mGlidePairs.containsKey(pointerId) && !mGlidePairs.containsValue(buttonView)) { if (buttonView.getIsGlidable()) - mGlidePairs.put(pointerID, buttonView); - else { mGlidePairs.put(pointerID, null); } + mGlidePairs.put(pointerId, buttonView); + else { mGlidePairs.put(pointerId, null); } } pressed = true; break; @@ -494,6 +494,7 @@ public class TouchscreenControllerView extends FrameLayout { (axisView.isPressed() && axisView.getPointerId() == pointerId)) { axisView.setPressed(pointerId, x, y); pressed = true; + mGlidePairs.put(pointerId, null); break; } } @@ -526,9 +527,9 @@ public class TouchscreenControllerView extends FrameLayout { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_UP: { - int pointerID = event.getPointerId(event.getActionIndex()); - if (mGlidePairs.containsKey(pointerID)) - mGlidePairs.remove(pointerID); + final int pointerId = event.getPointerId(event.getActionIndex()); + if (mGlidePairs.containsKey(pointerId)) + mGlidePairs.remove(pointerId); return updateTouchButtonsFromEvent(event); }