From 72f3d69a7854ecb5bcd8a5fefe9696e51572ff26 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 21 Apr 2014 21:24:49 -0400 Subject: [PATCH 1/4] Android: Allow finger movement while pressing button --- .../dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index cd00dc09a6..6d0f4667b4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -116,7 +116,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // // TODO: Refactor this so we detect either Axis movements or button presses so we don't run two loops all the time. // - int buttonState = (event.getAction() == MotionEvent.ACTION_DOWN) ? ButtonState.PRESSED : ButtonState.RELEASED; + int buttonState = (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) + ? ButtonState.PRESSED : ButtonState.RELEASED; // Check if there was a touch within the bounds of a drawable. for (InputOverlayDrawableButton button : overlayButtons) { From f489e30cd854fe57c1400cb28f5c4534d8086934 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 21 Apr 2014 22:59:08 -0400 Subject: [PATCH 2/4] Release button after touch leaves boundaries Now, your finger can still move around, but as soon as it leaves the button boundaries the button is released. --- .../dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index 6d0f4667b4..27cf902ea4 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -123,6 +123,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { if (button.getBounds().contains((int)event.getX(), (int)event.getY())) NativeLibrary.onTouchEvent(0, button.getId(), buttonState); + else // Release button after touch leaves boundaries + NativeLibrary.onTouchEvent(0, button.getId(), ButtonState.RELEASED); } From c81ac090c93feba427ee65469aa7d4ed57b38742 Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 22 Apr 2014 18:34:16 -0400 Subject: [PATCH 3/4] Clarify code with comments --- .../dolphinemu/emulation/overlay/InputOverlay.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index 27cf902ea4..9dffa00f5b 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -123,7 +123,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener { if (button.getBounds().contains((int)event.getX(), (int)event.getY())) NativeLibrary.onTouchEvent(0, button.getId(), buttonState); - else // Release button after touch leaves boundaries + else + // Because the above code only changes the state for the button that is being touched, sliding off the + // button does not allow for it to be released. Release the button as soon as the touch coordinates leave + // the button bounds. NativeLibrary.onTouchEvent(0, button.getId(), ButtonState.RELEASED); } From 4edb0a313403d8c82ad0a3c3fec14d0bd57750aa Mon Sep 17 00:00:00 2001 From: Sean Date: Tue, 22 Apr 2014 18:40:53 -0400 Subject: [PATCH 4/4] Add braces --- .../dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index 9dffa00f5b..5df8841814 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -122,12 +122,16 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener for (InputOverlayDrawableButton button : overlayButtons) { if (button.getBounds().contains((int)event.getX(), (int)event.getY())) + { NativeLibrary.onTouchEvent(0, button.getId(), buttonState); + } else + { // Because the above code only changes the state for the button that is being touched, sliding off the // button does not allow for it to be released. Release the button as soon as the touch coordinates leave // the button bounds. NativeLibrary.onTouchEvent(0, button.getId(), ButtonState.RELEASED); + } }