diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index b2d7a040..374f951b 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -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()); } } diff --git a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java index 2f794208..ce9de9bf 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -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()); diff --git a/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java b/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java index c6764ee0..4e932f49 100644 --- a/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java +++ b/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java @@ -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; diff --git a/app/src/main/jni/moonlight-core/moonlight-common-c b/app/src/main/jni/moonlight-core/moonlight-common-c index 70a2e305..0f17b4d0 160000 --- a/app/src/main/jni/moonlight-core/moonlight-common-c +++ b/app/src/main/jni/moonlight-core/moonlight-common-c @@ -1 +1 @@ -Subproject commit 70a2e305bc7170eccbd48d8c49b64a814e64ecb7 +Subproject commit 0f17b4d0c5f40842bb81fec0f2f6b5afbf182d04