fix trackpad three finger tap as mid button#409
Conversation
|
Ah ok, I can revert that commit and you can work on this PR for a better version |
|
这个提交的内容基本可用,主要的更改是改了不属于trackpad类的TouchContext接口(加了有默认实现的方法setActualPointerCount)和在game类里加了好多个setActualPointerCount,应该不会影响其他功能 |
|
我在我的三星tab10 fe上进行了测试,在多数情况下能够正确的触发鼠标中键的,失败的情形不确定是否是我的触控板的问题还是代码的问题 |
|
我现在没设备用来测试触摸板了。。。 之前买的一加平板Pro触摸板在升级coloros15以后就用不了了,系统直接没发送motion event过来,联系客服也没结果,后来干脆卖掉了 触摸板这块挺头大的,不同厂商不同系统版本都有细微不同的表现,非捕获模式问题更多。。。所以我放弃了。。。 目前Android平板这块最不值得购买的就是官方键盘套,又贵又broken,真不如单买个蓝牙折叠键盘 |
|
以及第三方键盘带的触摸板把自己报告成鼠标反而是好用的。。。 |
|
我也没有其他设备能测试这个实现到底能不能用了 悲,三星的触摸板也有好多的毛病而且xy轴还是反的,并且大概只支持到三点触控。 |
There was a problem hiding this comment.
Pull request overview
Fixes trackpad three-finger tap behavior to more reliably generate a middle mouse click by tracking the “actual” pointer count across gesture transitions (especially during pointer-up/down events).
Changes:
- Add
actualPointerCountplumbing viaTouchContextandGame.handleTouchInput(), and adjustTrackpadContextclick/scroll logic accordingly. - Add a new
Debughelper and surface some debug state in the performance overlay / input paths. - Modify keyboard-related behavior (PrintScreen mapping, additional accessibility blacklist keys, and disconnect on HOME).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java | Prints new debug state into the perf overlay. |
| app/src/main/java/com/limelight/binding/input/touch/TrackpadContext.java | Tracks actual/max pointer counts and updates middle/right click detection logic. |
| app/src/main/java/com/limelight/binding/input/touch/TouchContext.java | Adds setActualPointerCount() hook for contexts that need it. |
| app/src/main/java/com/limelight/binding/input/touch/Debug.java | Introduces global debug state used by overlay/input code. |
| app/src/main/java/com/limelight/binding/input/KeyboardTranslator.java | Changes PrintScreen VK code and adds debug logging in translation path. |
| app/src/main/java/com/limelight/KeyboardAccessibilityService.java | Blacklists brightness keys in accessibility service. |
| app/src/main/java/com/limelight/Game.java | Wires actualPointerCount into touch contexts; adds HOME disconnect behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| Debug.format("keycode {0}", keycode); | ||
| // If a device ID was provided, look up the keylllboard mapping |
There was a problem hiding this comment.
translate() is typically a hot path; calling Debug.format() (MessageFormat + allocation) on every key translation can add avoidable overhead. Consider gating this behind a debug flag (e.g., BuildConfig.DEBUG and/or a runtime setting) or removing it from production code paths.
|
|
||
| // 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 |
There was a problem hiding this comment.
Corrected spelling of 'keylllboard' to 'keyboard'.
| // If a device ID was provided, look up the keylllboard mapping | |
| // If a device ID was provided, look up the keyboard mapping |
| sb.append("max count: ").append(Debug.maxCount).append("\n"); | ||
| sb.append(Debug.actions); | ||
| Debug.maxCount = 0; | ||
| Debug.actions = ""; |
There was a problem hiding this comment.
Debug.maxCount is printed and reset here, but in the changes shown there is no code that ever updates Debug.maxCount, so the overlay will likely always show 0. Either (a) wire the real trackpad max pointer count into this field, or (b) remove maxCount from the overlay to avoid misleading output.
| sb.append("max count: ").append(Debug.maxCount).append("\n"); | |
| sb.append(Debug.actions); | |
| Debug.maxCount = 0; | |
| Debug.actions = ""; | |
| sb.append(Debug.actions); | |
| Debug.actions = ""; |
| public static int maxCount = 0; | ||
| public static String actions = ""; | ||
|
|
||
| public static void format(String pattern, Object... arguments) { | ||
| actions = MessageFormat.format(pattern, arguments); |
There was a problem hiding this comment.
Debug.maxCount and Debug.actions are mutable static globals accessed from multiple subsystems (input, decoder/overlay). As written, updates are not thread-safe and can be torn/lost across threads. Use thread-safe primitives (e.g., AtomicInteger / AtomicReference<String> or synchronization) and consider bounding/accumulating actions in a controlled way (the current format() overwrites the entire string).
| 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); | |
| } |
| private int maxCount = 0; | ||
| private int actualPointerCount = 0; |
There was a problem hiding this comment.
maxCount and actualPointerCount are ambiguous in meaning, especially alongside the existing maxPointerCountInGesture. Consider renaming to something explicit (e.g., maxActualPointerCountInGesture and actualPointerCountIncludingLiftingFinger) and/or consolidating with maxPointerCountInGesture to reduce confusion and future bugs.
| if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) { | ||
| disconnect(); | ||
| } |
There was a problem hiding this comment.
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.
i accidently included a commit(use trackpad 3 finger click as middle button) in fix touchpad scroll support when swap axis. This implementation was broken, i fixed it in this commit.
This implementation is still broken and the quality of the code was not quite good, but this works better than the old implementation and works for most of the times.