mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 15:55:31 +01:00
Merge pull request #198 from Sonicadvance1/Android-onscreenconfigure
Make configuring the onscreen controls less annoying.
This commit is contained in:
commit
c7335dc48f
@ -41,6 +41,10 @@ public final class OverlayConfigButton extends Button implements OnTouchListener
|
|||||||
// float buttonY = sPrefs.getFloat(buttonId+"-Y", -1f);
|
// float buttonY = sPrefs.getFloat(buttonId+"-Y", -1f);
|
||||||
//
|
//
|
||||||
private final String buttonId;
|
private final String buttonId;
|
||||||
|
|
||||||
|
// The offset of the press while moving the button
|
||||||
|
private float moveOffsetX, moveOffsetY;
|
||||||
|
|
||||||
private Drawable resizeDrawable(Drawable image, float scale)
|
private Drawable resizeDrawable(Drawable image, float scale)
|
||||||
{
|
{
|
||||||
// Retrieve screen dimensions.
|
// Retrieve screen dimensions.
|
||||||
@ -97,11 +101,20 @@ public final class OverlayConfigButton extends Button implements OnTouchListener
|
|||||||
{
|
{
|
||||||
switch(event.getAction())
|
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.
|
// Only change the X/Y coordinates when we move the button.
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
{
|
{
|
||||||
setX(getX() + event.getX());
|
setX(getX() + event.getX() - moveOffsetX);
|
||||||
setY(getY() + event.getY());
|
setY(getY() + event.getY() - moveOffsetY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user