Merge pull request #295 from SeannyM/button-holding
Android: Allow finger movement while pressing button
This commit is contained in:
commit
9f12d02328
|
@ -116,13 +116,23 @@ 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (InputOverlayDrawableJoystick joystick : overlayJoysticks)
|
||||
|
|
Loading…
Reference in New Issue