diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java index c1fbdbc3ba..bc5dd33558 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java @@ -133,23 +133,22 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: - case MotionEvent.ACTION_MOVE: // If a pointer enters the bounds of a button, press that button. if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) { button.setPressedState(true); + button.setTrackId(event.getPointerId(pointerIndex)); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.PRESSED); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: // If a pointer ends, release the button it was pressing. - if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) + if (button.getTrackId() == event.getPointerId(pointerIndex)) { + button.setPressedState(false); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED); } - - button.setPressedState(false); break; } } @@ -161,7 +160,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: - case MotionEvent.ACTION_MOVE: // If a pointer enters the bounds of a button, press that button. if (dpad.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) { @@ -191,19 +189,20 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener } setDpadState(dpad, up, down, left, right); + dpad.setTrackId(event.getPointerId(pointerIndex)); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: // If a pointer ends, release the buttons. - if (dpad.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) + if (dpad.getTrackId() == event.getPointerId(pointerIndex)) { for(int i = 0; i < 4; i++) { + dpad.setState(InputOverlayDrawableDpad.STATE_DEFAULT); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, dpad.getId(i), ButtonState.RELEASED); } } - dpad.setState(InputOverlayDrawableDpad.STATE_DEFAULT); break; } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableButton.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableButton.java index 4d557b5f28..249634df88 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableButton.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableButton.java @@ -21,6 +21,7 @@ public final class InputOverlayDrawableButton { // The ID identifying what type of button this Drawable represents. private int mButtonType; + private int mTrackId; private int mPreviousTouchX, mPreviousTouchY; private int mControlPositionX, mControlPositionY; private int mWidth; @@ -57,6 +58,16 @@ public final class InputOverlayDrawableButton return mButtonType; } + public void setTrackId(int trackId) + { + mTrackId = trackId; + } + + public int getTrackId() + { + return mTrackId; + } + public boolean onConfigureTouch(MotionEvent event) { int pointerIndex = event.getActionIndex(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableDpad.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableDpad.java index cd76ce8e87..fa5fbb059f 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableDpad.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableDpad.java @@ -21,6 +21,7 @@ public final class InputOverlayDrawableDpad { // The ID identifying what type of button this Drawable represents. private int[] mButtonType = new int[4]; + private int mTrackId; private int mPreviousTouchX, mPreviousTouchY; private int mControlPositionX, mControlPositionY; private int mWidth; @@ -135,6 +136,16 @@ public final class InputOverlayDrawableDpad return mButtonType[direction]; } + public void setTrackId(int trackId) + { + mTrackId = trackId; + } + + public int getTrackId() + { + return mTrackId; + } + public boolean onConfigureTouch(MotionEvent event) { int pointerIndex = event.getActionIndex();