From 0c72910eb7e9369e11f1c5e68f26856048e9682f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 22 Apr 2020 22:00:25 -0700 Subject: [PATCH] Fix tap location for styluses without hover support --- app/src/main/java/com/limelight/Game.java | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index e448fd4d..c7030b02 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -1176,6 +1176,23 @@ public class Game extends Activity implements SurfaceHolder.Callback, return true; } + // Always update the position before sending any button events. If we're + // dealing with a stylus without hover support, our position might be + // significantly different than before. + if (inputCaptureProvider.eventHasRelativeMouseAxes(event)) { + // Send the deltas straight from the motion event + short deltaX = (short)inputCaptureProvider.getRelativeAxisX(event); + short deltaY = (short)inputCaptureProvider.getRelativeAxisY(event); + + if (deltaX != 0 || deltaY != 0) { + conn.sendMouseMove(deltaX, deltaY); + } + } + else if (view != null) { + // Otherwise send absolute position + updateMousePosition(view, event); + } + if (event.getActionMasked() == MotionEvent.ACTION_SCROLL) { // Send the vertical scroll packet byte vScrollClicks = (byte) event.getAxisValue(MotionEvent.AXIS_VSCROLL); @@ -1271,17 +1288,6 @@ public class Game extends Activity implements SurfaceHolder.Callback, } } - // Get relative axis values if we can - if (inputCaptureProvider.eventHasRelativeMouseAxes(event)) { - // Send the deltas straight from the motion event - conn.sendMouseMove((short) inputCaptureProvider.getRelativeAxisX(event), - (short) inputCaptureProvider.getRelativeAxisY(event)); - } - else if (view != null) { - // Otherwise send absolute position - updateMousePosition(view, event); - } - lastButtonState = event.getButtonState(); } // This case is for fingers