From 6bba68207ddc4cb60ed969374f1d88046ba66384 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 16 Jun 2018 15:57:44 -0700 Subject: [PATCH] Ignore spurious ACTION_HOVER_ENTER with wrong coordinates and KEYCODE_BACK repeats. Fixes #554 --- app/src/main/java/com/limelight/Game.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 093e804e..3149a533 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -834,10 +834,12 @@ public class Game extends Activity implements SurfaceHolder.Callback, } // Handle a synthetic back button event that some Android OS versions - // create as a result of a right-click. + // create as a result of a right-click. This event WILL repeat if + // the right mouse button is held down, so we ignore those. if ((event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == InputDevice.SOURCE_MOUSE_RELATIVE) && - event.getKeyCode() == KeyEvent.KEYCODE_BACK) { + event.getKeyCode() == KeyEvent.KEYCODE_BACK && + event.getRepeatCount() == 0) { conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_RIGHT); return true; } @@ -973,6 +975,13 @@ public class Game extends Activity implements SurfaceHolder.Callback, byte vScrollClicks = (byte) event.getAxisValue(MotionEvent.AXIS_VSCROLL); conn.sendMouseScroll(vScrollClicks); } + else if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER || + event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) { + // On some devices (Galaxy S8 without Oreo pointer capture), we can + // get spurious ACTION_HOVER_ENTER events when right clicking with + // incorrect X and Y coordinates. Just eat this event without processing it. + return true; + } if ((changedButtons & MotionEvent.BUTTON_PRIMARY) != 0) { if ((event.getButtonState() & MotionEvent.BUTTON_PRIMARY) != 0) {