mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-06-16 22:01:14 +00:00
Fix OSC handling of touches outside the StreamView
This commit is contained in:
@@ -305,8 +305,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
// handle event depending on action
|
// handle event depending on action
|
||||||
switch (event.getActionMasked()) {
|
switch (event.getActionMasked()) {
|
||||||
// down event (touch event)
|
// down event (touch event)
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN: {
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
|
||||||
// set to dead zoned, will be corrected in update position if necessary
|
// set to dead zoned, will be corrected in update position if necessary
|
||||||
stick_state = STICK_STATE.MOVED_IN_DEAD_ZONE;
|
stick_state = STICK_STATE.MOVED_IN_DEAD_ZONE;
|
||||||
// check for double click
|
// check for double click
|
||||||
@@ -325,8 +324,7 @@ public class AnalogStick extends VirtualControllerElement {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// up event (revoke touch)
|
// up event (revoke touch)
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP: {
|
||||||
case MotionEvent.ACTION_POINTER_UP: {
|
|
||||||
setPressed(false);
|
setPressed(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,8 +200,7 @@ public class DigitalButton extends VirtualControllerElement {
|
|||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN: {
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
|
||||||
movingButton = null;
|
movingButton = null;
|
||||||
setPressed(true);
|
setPressed(true);
|
||||||
onClickCallback();
|
onClickCallback();
|
||||||
@@ -216,8 +215,7 @@ public class DigitalButton extends VirtualControllerElement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP: {
|
||||||
case MotionEvent.ACTION_POINTER_UP: {
|
|
||||||
setPressed(false);
|
setPressed(false);
|
||||||
onReleaseCallback();
|
onReleaseCallback();
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
// get masked (not specific to a pointer) action
|
// get masked (not specific to a pointer) action
|
||||||
switch (event.getActionMasked()) {
|
switch (event.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
case MotionEvent.ACTION_POINTER_DOWN:
|
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
direction = 0;
|
direction = 0;
|
||||||
|
|
||||||
@@ -184,8 +183,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP: {
|
||||||
case MotionEvent.ACTION_POINTER_UP: {
|
|
||||||
direction = 0;
|
direction = 0;
|
||||||
newDirectionCallback(direction);
|
newDirectionCallback(direction);
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|||||||
+11
-4
@@ -223,13 +223,21 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
// Ignore secondary touches on controls
|
||||||
|
//
|
||||||
|
// NB: We can get an additional pointer down if the user touches a non-StreamView area
|
||||||
|
// while also touching an OSC control, even if that pointer down doesn't correspond to
|
||||||
|
// an area of the OSC control.
|
||||||
|
if (event.getActionIndex() != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (virtualController.getControllerMode() == VirtualController.ControllerMode.Active) {
|
if (virtualController.getControllerMode() == VirtualController.ControllerMode.Active) {
|
||||||
return onElementTouchEvent(event);
|
return onElementTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event.getActionMasked()) {
|
switch (event.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN: {
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
|
||||||
position_pressed_x = event.getX();
|
position_pressed_x = event.getX();
|
||||||
position_pressed_y = event.getY();
|
position_pressed_y = event.getY();
|
||||||
startSize_x = getWidth();
|
startSize_x = getWidth();
|
||||||
@@ -267,8 +275,7 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP: {
|
||||||
case MotionEvent.ACTION_POINTER_UP: {
|
|
||||||
actionCancel();
|
actionCancel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user