-
Notifications
You must be signed in to change notification settings - Fork 237
fix trackpad three finger tap as mid button #409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: moonlight-noir
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |||||
| import android.view.KeyEvent; | ||||||
|
|
||||||
| import com.limelight.LimeLog; | ||||||
| import com.limelight.binding.input.touch.Debug; | ||||||
| import com.limelight.nvstream.input.KeyboardPacket; | ||||||
| import com.limelight.preferences.PreferenceConfiguration; | ||||||
| import com.limelight.utils.KeyMapper; | ||||||
|
|
@@ -52,7 +53,8 @@ public class KeyboardTranslator implements InputManager.InputDeviceListener { | |||||
| public static final int VK_SEMICOLON = 59; | ||||||
| public static final int VK_SLASH = 47; | ||||||
| public static final int VK_SPACE = 32; | ||||||
| public static final int VK_PRINTSCREEN = 154; | ||||||
| // public static final int VK_PRINTSCREEN = 154; why??? | ||||||
| public static final int VK_PRINTSCREEN = 44; | ||||||
| public static final int VK_TAB = 9; | ||||||
| public static final int VK_LEFT = 37; | ||||||
| public static final int VK_RIGHT = 39; | ||||||
|
|
@@ -182,8 +184,8 @@ public boolean hasNormalizedMapping(int keycode, int deviceId) { | |||||
| */ | ||||||
| public short translate(int keycode, int scancode, int deviceId) { | ||||||
| int translated; | ||||||
|
|
||||||
| // If a device ID was provided, look up the keyboard mapping | ||||||
| Debug.format("keycode {0}", keycode); | ||||||
| // If a device ID was provided, look up the keylllboard mapping | ||||||
|
Comment on lines
+187
to
+188
|
||||||
| // If a device ID was provided, look up the keylllboard mapping | |
| // If a device ID was provided, look up the keyboard mapping |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||
| package com.limelight.binding.input.touch; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import java.text.MessageFormat; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public class Debug { | ||||||||||||||||||||||||||||
| public static int maxCount = 0; | ||||||||||||||||||||||||||||
| public static String actions = ""; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public static void format(String pattern, Object... arguments) { | ||||||||||||||||||||||||||||
| actions = MessageFormat.format(pattern, arguments); | ||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+10
|
||||||||||||||||||||||||||||
| public static int maxCount = 0; | |
| public static String actions = ""; | |
| public static void format(String pattern, Object... arguments) { | |
| actions = MessageFormat.format(pattern, arguments); | |
| public static volatile int maxCount = 0; | |
| public static volatile String actions = ""; | |
| private static final Object LOCK = new Object(); | |
| public static void format(String pattern, Object... arguments) { | |
| synchronized (LOCK) { | |
| actions = MessageFormat.format(pattern, arguments); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ public class TrackpadContext implements TouchContext { | |
| private double distanceMoved; | ||
| private int pointerCount; | ||
| private boolean clickedMiddle = false; | ||
| private int maxCount = 0; | ||
| private int actualPointerCount = 0; | ||
|
Comment on lines
+25
to
+26
|
||
| private int maxPointerCountInGesture; | ||
| private boolean isClickPending; | ||
| private boolean isDblClickPending; | ||
|
|
@@ -168,11 +170,11 @@ private boolean isTap(long eventTime) { | |
| } | ||
|
|
||
| private byte getMouseButtonIndex() { | ||
| if (pointerCount == 2) { | ||
| return MouseButtonPacket.BUTTON_RIGHT; | ||
| } else if (pointerCount == 3) { | ||
| if (maxCount == 3) { | ||
| clickedMiddle = true; | ||
| return MouseButtonPacket.BUTTON_MIDDLE; | ||
| } else if (pointerCount == 2) { | ||
| return MouseButtonPacket.BUTTON_RIGHT; | ||
| } else { | ||
| return MouseButtonPacket.BUTTON_LEFT; | ||
| } | ||
|
|
@@ -198,26 +200,30 @@ public boolean touchDownEvent(int eventX, int eventY, long eventTime, boolean is | |
| isScrollTransitioning = false; | ||
| maxPointerCountInGesture = pointerCount; | ||
| originalTouchTime = eventTime; | ||
| maxCount = pointerCount; | ||
| cancelled = confirmedMove = confirmedScroll = false; | ||
| distanceMoved = 0; | ||
| velocityX = 0; | ||
| velocityY = 0; | ||
| lastMoveTime = eventTime; | ||
| if (pointerCount == 3){ | ||
| clickedMiddle = true; | ||
| } | ||
| if (isClickPending) { | ||
| isClickPending = false; | ||
| isDblClickPending = true; | ||
| confirmedDrag = true; | ||
| } | ||
| } else { | ||
| if (pointerCount == 2 && !confirmedMove) { | ||
| if ((actualPointerCount == 3) && !confirmedMove) { | ||
| conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_MIDDLE); | ||
| conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_MIDDLE); | ||
| isClickPending = false; | ||
| isDblClickPending = false; | ||
| confirmedDrag = false; | ||
| clickedMiddle = true; | ||
| // Second finger released, should trigger right click immediately | ||
| } else if (pointerCount == 1 && !confirmedMove && !clickedMiddle) { | ||
| } else if (pointerCount == 1 && actualPointerCount == 2 && !confirmedMove && !clickedMiddle && maxCount == 2) { | ||
| conn.sendMouseButtonDown(MouseButtonPacket.BUTTON_RIGHT); | ||
| conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_RIGHT); | ||
| isClickPending = false; | ||
|
|
@@ -385,7 +391,7 @@ public boolean touchMoveEvent(int eventX, int eventY, long eventTime) { | |
| if (sendDeltaX != 0 || sendDeltaY != 0) { | ||
| conn.sendMouseMove(sendDeltaX, sendDeltaY); | ||
| } | ||
| } else if (pointerCount == 2) { | ||
| } else if (pointerCount == 2 && maxCount == 2 && actualPointerCount == 2) { | ||
| checkForConfirmedScroll(); | ||
| if (confirmedScroll) { | ||
| if (absDeltaX > absDeltaY) { | ||
|
|
@@ -430,6 +436,13 @@ public boolean isCancelled() { | |
| return cancelled; | ||
| } | ||
|
|
||
| @Override | ||
| public void setActualPointerCount(int pointerCount){ | ||
| // Debug.format("Set pointerCount {0}", pointerCount); | ||
| actualPointerCount = pointerCount; | ||
| maxCount = Math.max(maxCount, pointerCount); | ||
| } | ||
|
|
||
| @Override | ||
| public void setPointerCount(int pointerCount) { | ||
| if (this.pointerCount == 2 && pointerCount == 1) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||||||||
| import com.limelight.BuildConfig; | ||||||||||||||
| import com.limelight.LimeLog; | ||||||||||||||
| import com.limelight.R; | ||||||||||||||
| import com.limelight.binding.input.touch.Debug; | ||||||||||||||
| import com.limelight.nvstream.av.video.VideoDecoderRenderer; | ||||||||||||||
| import com.limelight.nvstream.jni.MoonBridge; | ||||||||||||||
| import com.limelight.preferences.PreferenceConfiguration; | ||||||||||||||
|
|
@@ -1791,6 +1792,10 @@ public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int dec | |||||||||||||
| float decodeTimeMs = (float)lastTwo.decoderTimeMs / lastTwo.totalFramesReceived; | ||||||||||||||
| long rttInfo = MoonBridge.getEstimatedRttInfo(); | ||||||||||||||
| StringBuilder sb = new StringBuilder(); | ||||||||||||||
| sb.append("max count: ").append(Debug.maxCount).append("\n"); | ||||||||||||||
| sb.append(Debug.actions); | ||||||||||||||
| Debug.maxCount = 0; | ||||||||||||||
| Debug.actions = ""; | ||||||||||||||
|
Comment on lines
+1795
to
+1798
|
||||||||||||||
| sb.append("max count: ").append(Debug.maxCount).append("\n"); | |
| sb.append(Debug.actions); | |
| Debug.maxCount = 0; | |
| Debug.actions = ""; | |
| sb.append(Debug.actions); | |
| Debug.actions = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change adds a new behavior (disconnecting on HOME) that isn’t described in the PR title/description about trackpad three-finger tap. If this is intentional, it should be in a separate PR or at least documented/guarded (e.g., behind a setting) since HOME/Guide keys on some controllers/remotes may be pressed unintentionally and cause unexpected disconnects.