Skip to content

Fix multi-finger gestures on touchpads that report several fingers per HID report - #1

Open
SABERBIRD wants to merge 1 commit into
SumirSeth:mainfrom
SABERBIRD:claude/dazzling-brahmagupta-p7ztyj
Open

SABERBIRD wants to merge 1 commit into
SumirSeth:mainfrom
SABERBIRD:claude/dazzling-brahmagupta-p7ztyj

Conversation

@SABERBIRD

Copy link
Copy Markdown

Problem

On my laptop only one-finger gestures (edges, corners) worked. 3-, 4- and 5-finger swipes, taps, twists and pinches never fired.

The touchpad sends every finger in a single HID report: one report has five link collections (L1–L5) and the contact count says how many of them are in use. Device::report only ever read link collection 1. A frame with N fingers therefore never collected N contacts, pending was reset by the next report, and the recognizer only ever saw one-finger frames.

Fix

  • When the device is loaded, collect every link collection that has an X value cap (HidP_GetSpecificValueCaps with LinkCollection = 0). Each of them is one finger slot.
  • In report, read the slots in order until the frame's contact count is reached. Slots past the count are padding and are skipped.
  • Axis size and scale come from the first X/Y cap found, instead of the hard-coded collection 1.

Touchpads that send one finger per report have a single slot ([1]), so they make exactly the same HID calls as before.

What changed and where

Two files, +50 / −16. Only HID report parsing changed. The gesture recognizers, config and UI are untouched.

crates/engine/src/platform.rs, all inside struct Device:

Where Change
struct Device New field fingers: Vec<u16>: the link collections that hold one finger each, in descriptor order.
Device::load Fills fingers from the X value caps (duplicates removed). Width/height and scale are computed from the first X and Y caps.
Device::value_caps (new) Returns every input value cap for a Generic Desktop usage across all link collections. The buffer is sized from HIDP_CAPS::NumberInputValueCaps.
Device::axis Now takes a &HIDP_VALUE_CAPS instead of looking it up in link collection 1. The unit and extent maths is unchanged.
Device::report Replaces the single read of link collection 1 with a loop over fingers. The loop stops once pending reaches the contact count. Lifted contacts (no tip switch) are still counted and then dropped, as before.

CHANGELOG.md: an Unreleased → Fixed entry.

Testing

Hardware

  • Laptop: ASUS Zenbook 14 (UX3405CA)
  • Touchpad: ASUS Precision Touchpad, I2C HID (ACPI\ASUP1415), 127 × 71 mm, 5 finger slots in report ID 84
  • Windows: Windows 11 Pro, 10.0.26300

Results

  • Before: only edges and corners worked.
  • After: 3/4-finger swipes and taps, 4-finger twist, 5-finger pinch and twist all fire. Edges, corners, pointer movement, scrolling and clicks are unchanged.
  • I checked this with a temporary log of raw reports and frames (not part of this PR). With three fingers down, frames now contain n=3 with three distinct contacts. Before the fix they never got past one contact.

Checks

  • cargo fmt --check passes.
  • cargo test --workspace passes.
  • cargo clippy -p gestures_engine -- -D warnings passes. For the workspace-wide clippy run, see the CI note below.
  • No new tests were added. The recognizers in gestures.rs didn't change, and Device parses live HID reports through the Windows HID API, so the existing tests can't exercise it without hardware.

CI note: an existing clippy failure, not caused by this PR

cargo clippy --workspace --locked -- -D warnings (the second CI step) fails on current main with the latest stable Rust (1.100):

error: the loop variable `i` is used to index `self.fields`
   --> app\src\ui.rs:181:18
    |
181 |         for i in 0..3 {
    = note: `-D clippy::needless-range-loop` implied by `-D warnings`

The needless_range_loop lint now reports this loop in app/src/ui.rs (the settings window), which this PR doesn't touch. Because that step fails, CI skips cargo test and cargo build as well. I left it out to keep this PR focused, and I'm happy to add the fix here or open a separate PR, whichever you prefer.

Investigated and fixed together with Claude Code (Opus 5.5)

Precision Touchpads may pack several contacts into one HID report, each
in its own link collection. The parser only read link collection 1, so
a frame with N fingers never collected N contacts and multi-finger
gestures never fired. Discover the finger collections from the X value
caps and read each slot up to the report's contact count. Pads that
send one finger per report behave as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vqgg7FJDUhFB9QhMgod1Ht
@SumirSeth

Copy link
Copy Markdown
Owner

hey. thanks for the PR. for some reason this project has gotten several stars without any promotion and i did not receive any notification about it.

@SABERBIRD

Copy link
Copy Markdown
Author

GPT (or Claude, i dont remember) told me about that project. Nice work, hope u keep improving it ❤️

@SumirSeth

SumirSeth commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Appreciate it and yes, seems like I'm gonna be maintaining it along side wisp, which is my other popular system utility.

@SABERBIRD

Copy link
Copy Markdown
Author

The link is wrong. I was scratching my head trying to figure out what the connection was 😄

Do you mean this one https://github.com/SumirSeth/wisp⁠ and not that one https://github.com/wisp, right?⁠

@SumirSeth

Copy link
Copy Markdown
Owner

The link is wrong. I was scratching my head trying to figure out what the connection was 😄

Do you mean this one https://github.com/SumirSeth/wisp⁠ and not that one https://github.com/wisp, right?⁠

Ah yes! Problems of being on a phone :p

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