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