Skip to content

fix trackpad three finger tap as mid button#409

Open
wefcdse wants to merge 2 commits into
ClassicOldSong:moonlight-noirfrom
wefcdse:moonlight-noir
Open

fix trackpad three finger tap as mid button#409
wefcdse wants to merge 2 commits into
ClassicOldSong:moonlight-noirfrom
wefcdse:moonlight-noir

Conversation

@wefcdse

@wefcdse wefcdse commented Sep 17, 2025

Copy link
Copy Markdown

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.

@ClassicOldSong

Copy link
Copy Markdown
Owner

Ah ok, I can revert that commit and you can work on this PR for a better version

@wefcdse

wefcdse commented Sep 17, 2025

Copy link
Copy Markdown
Author

这个提交的内容基本可用,主要的更改是改了不属于trackpad类的TouchContext接口(加了有默认实现的方法setActualPointerCount)和在game类里加了好多个setActualPointerCount,应该不会影响其他功能

@wefcdse

wefcdse commented Sep 17, 2025

Copy link
Copy Markdown
Author

我在我的三星tab10 fe上进行了测试,在多数情况下能够正确的触发鼠标中键的,失败的情形不确定是否是我的触控板的问题还是代码的问题

@ClassicOldSong

Copy link
Copy Markdown
Owner

我现在没设备用来测试触摸板了。。。

之前买的一加平板Pro触摸板在升级coloros15以后就用不了了,系统直接没发送motion event过来,联系客服也没结果,后来干脆卖掉了

触摸板这块挺头大的,不同厂商不同系统版本都有细微不同的表现,非捕获模式问题更多。。。所以我放弃了。。。

目前Android平板这块最不值得购买的就是官方键盘套,又贵又broken,真不如单买个蓝牙折叠键盘

@ClassicOldSong

Copy link
Copy Markdown
Owner

以及第三方键盘带的触摸板把自己报告成鼠标反而是好用的。。。

@wefcdse

wefcdse commented Sep 17, 2025

Copy link
Copy Markdown
Author

我也没有其他设备能测试这个实现到底能不能用了 悲,三星的触摸板也有好多的毛病而且xy轴还是反的,并且大概只支持到三点触控。
这个pr的代码我可能不会再改了,感觉没什么意义了(安卓的触摸板大概用的也很少)。而且sunshine的触摸板支持好像也不太好。这段代码应该不会破坏其他的功能,应该可以凑合着用大概,如果写的丑的话就关掉吧,并且最好删一下use trackpad 3 finger click as middle button这个commit,这个的实现问题比较大基本不能用,是之前不小心合到那个pr里的实在不好意思。
无论如何谢谢你做了这个版本的moonlight!

Copilot AI review requested due to automatic review settings March 12, 2026 04:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 actualPointerCount plumbing via TouchContext and Game.handleTouchInput(), and adjust TrackpadContext click/scroll logic accordingly.
  • Add a new Debug helper 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.

Comment on lines +187 to +188
Debug.format("keycode {0}", keycode);
// If a device ID was provided, look up the keylllboard mapping

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

// 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

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'keylllboard' to 'keyboard'.

Suggested change
// If a device ID was provided, look up the keylllboard mapping
// If a device ID was provided, look up the keyboard mapping

Copilot uses AI. Check for mistakes.
Comment on lines +1795 to +1798
sb.append("max count: ").append(Debug.maxCount).append("\n");
sb.append(Debug.actions);
Debug.maxCount = 0;
Debug.actions = "";

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
sb.append("max count: ").append(Debug.maxCount).append("\n");
sb.append(Debug.actions);
Debug.maxCount = 0;
Debug.actions = "";
sb.append(Debug.actions);
Debug.actions = "";

Copilot uses AI. Check for mistakes.
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);

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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);
}

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +26
private int maxCount = 0;
private int actualPointerCount = 0;

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +2081 to +2083
if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) {
disconnect();
}

Copilot AI Mar 12, 2026

Copy link

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants