mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 02:20:55 +00:00
Fix handling of ACTION_CANCEL for multi-pointer gestures
This commit is contained in:
@@ -1491,7 +1491,11 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
return MoonBridge.LI_TOUCH_EVENT_MOVE;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
return MoonBridge.LI_TOUCH_EVENT_CANCEL;
|
||||
// ACTION_CANCEL applies to *all* pointers in the gesture, so it maps to CANCEL_ALL
|
||||
// rather than CANCEL. For a single pointer cancellation, that's indicated via
|
||||
// FLAG_CANCELED on a ACTION_POINTER_UP.
|
||||
// https://developer.android.com/develop/ui/views/touch-and-input/gestures/multi
|
||||
return MoonBridge.LI_TOUCH_EVENT_CANCEL_ALL;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_ENTER:
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
@@ -1690,8 +1694,14 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
}
|
||||
return handledStylusEvent;
|
||||
}
|
||||
else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
|
||||
// Cancel impacts all active pointers
|
||||
return conn.sendPenEvent(MoonBridge.LI_TOUCH_EVENT_CANCEL_ALL, MoonBridge.LI_TOOL_TYPE_UNKNOWN, (byte)0,
|
||||
0, 0, 0, 0, 0,
|
||||
MoonBridge.LI_ROT_UNKNOWN, MoonBridge.LI_TILT_UNKNOWN) != MoonBridge.LI_ERR_UNSUPPORTED;
|
||||
}
|
||||
else {
|
||||
// Up, Down, Hover, and Cancel events are specific to the action index
|
||||
// Up, Down, and Hover events are specific to the action index
|
||||
byte toolType = convertToolTypeToStylusToolType(event, event.getActionIndex());
|
||||
if (toolType == MoonBridge.LI_TOOL_TYPE_UNKNOWN) {
|
||||
// Not a stylus event
|
||||
@@ -1726,8 +1736,14 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
|
||||
// Cancel impacts all active pointers
|
||||
return conn.sendTouchEvent(MoonBridge.LI_TOUCH_EVENT_CANCEL_ALL, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
MoonBridge.LI_ROT_UNKNOWN) != MoonBridge.LI_ERR_UNSUPPORTED;
|
||||
}
|
||||
else {
|
||||
// Up, Down, Hover, and Cancel events are specific to the action index
|
||||
// Up, Down, and Hover events are specific to the action index
|
||||
return sendTouchEventForPointer(view, event, eventType, event.getActionIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1548,7 +1548,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
touchType = MoonBridge.LI_TOUCH_EVENT_CANCEL;
|
||||
// ACTION_CANCEL applies to *all* pointers in the gesture, so it maps to CANCEL_ALL
|
||||
// rather than CANCEL. For a single pointer cancellation, that's indicated via
|
||||
// FLAG_CANCELED on a ACTION_POINTER_UP.
|
||||
// https://developer.android.com/develop/ui/views/touch-and-input/gestures/multi
|
||||
touchType = MoonBridge.LI_TOUCH_EVENT_CANCEL_ALL;
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_BUTTON_PRESS:
|
||||
@@ -1595,6 +1599,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
|
||||
// Cancel impacts all active pointers
|
||||
return conn.sendControllerTouchEvent((byte)context.controllerNumber, MoonBridge.LI_TOUCH_EVENT_CANCEL_ALL,
|
||||
0, 0, 0, 0) != MoonBridge.LI_ERR_UNSUPPORTED;
|
||||
}
|
||||
else {
|
||||
// Down and Up events impact the action index pointer
|
||||
return sendTouchpadEventForPointer(context, event, touchType, event.getActionIndex());
|
||||
|
||||
@@ -89,6 +89,7 @@ public class MoonBridge {
|
||||
public static final byte LI_TOUCH_EVENT_CANCEL = 0x04;
|
||||
public static final byte LI_TOUCH_EVENT_BUTTON_ONLY = 0x05;
|
||||
public static final byte LI_TOUCH_EVENT_HOVER_LEAVE = 0x06;
|
||||
public static final byte LI_TOUCH_EVENT_CANCEL_ALL = 0x07;
|
||||
|
||||
public static final byte LI_TOOL_TYPE_UNKNOWN = 0x00;
|
||||
public static final byte LI_TOOL_TYPE_PEN = 0x01;
|
||||
|
||||
Reference in New Issue
Block a user