diff options
| author | Ryan Houdek <ryan.houdek@codethink.co.uk> | 2014-03-22 23:27:21 -0500 |
|---|---|---|
| committer | Ryan Houdek <ryan.houdek@codethink.co.uk> | 2014-03-22 23:32:46 -0500 |
| commit | b76351e2d3566e515116bd81507e59804b7604b5 (patch) | |
| tree | 0e2e4733cb1191882053fcbd3d81fcd1e232f823 /Source/Android/src | |
| parent | bf5f485a2c97cf38a9cbaa0677af850838de397f (diff) | |
Make configuring the onscreen controls less annoying.
Now instead of the top left corner of the button snapping to your finger.
Remember where we clicked on the button initially so it moves from the same location you touched.
This is more intuitive than before of course.
Diffstat (limited to 'Source/Android/src')
| -rw-r--r-- | Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java index c450837df6..30288179ef 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java @@ -41,6 +41,10 @@ public final class OverlayConfigButton extends Button implements OnTouchListener // float buttonY = sPrefs.getFloat(buttonId+"-Y", -1f); // private final String buttonId; + + // The offset of the press while moving the button + private float moveOffsetX, moveOffsetY; + private Drawable resizeDrawable(Drawable image, float scale) { // Retrieve screen dimensions. @@ -97,11 +101,20 @@ public final class OverlayConfigButton extends Button implements OnTouchListener { switch(event.getAction()) { + // Get the offset of the press within the button + // The event X and Y locations are the offset within the button, not the screen + case MotionEvent.ACTION_DOWN: + { + moveOffsetX = event.getX(); + moveOffsetY = event.getY(); + return true; + } + // Only change the X/Y coordinates when we move the button. case MotionEvent.ACTION_MOVE: { - setX(getX() + event.getX()); - setY(getY() + event.getY()); + setX(getX() + event.getX() - moveOffsetX); + setY(getY() + event.getY() - moveOffsetY); return true; } |
