fix: discard first raw-XY sample for all gesture sources - #765
fix: discard first raw-XY sample for all gesture sources#765HoneyTyagii wants to merge 1 commit into
Conversation
The HID++ raw-XY divert buffer accumulates deltas from the moment diversion is activated, not from when the user starts moving. The first sample after any gesture source press carries this buffered noise and must be discarded for ALL gesture sources, not just the haptic panel. Previously, only the HapticPanel (CID 0x01A0) discarded its first raw-XY sample. The GestureButton (CID 0x00C3) did not, causing the SwipeAccumulator to be poisoned with spurious deltas that resulted in wrong-direction commits. Fixes AprilNEA#752
Greptile SummaryThis PR extends first-sample raw-XY filtering from the haptic panel to every gesture source to prevent buffered motion from selecting the wrong swipe direction.
Confidence Score: 4/5The overlap transition should be fixed before merging because it can discard genuine dedicated-button movement after the buffered sample was already ignored. The new skip assignment extends a stale-flag state transition to the dedicated gesture button: overlap drops the buffered report without consuming the flag, so the resumed holder loses its next real report as well. Files Needing Attention: crates/openlogi-hid/src/session/gesture.rs
|
| Filename | Overview |
|---|---|
| crates/openlogi-hid/src/session/gesture.rs | Extends first-report filtering to all gesture sources but can double-discard around an overlap transition. |
| crates/openlogi-hid/src/session/gesture/tests.rs | Updates the dedicated-button first-sample test but does not cover press, overlap, and resume behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Fresh gesture-button press] --> B[Set skip_first_raw_xy]
B --> C[Second source overlaps]
C --> D[Raw-XY report dropped]
D --> E[Skip flag remains set]
E --> F[Second source released]
F --> G[Next genuine report also dropped]
Reviews (1): Last reviewed commit: "fix: discard first raw-XY sample for all..." | Re-trigger Greptile
| // The first sample after any gesture source press carries this | ||
| // buffered noise and must be discarded for all gesture sources, | ||
| // not just the haptic panel. | ||
| acc.skip_first_raw_xy = !acc.gestures_down.contains(&cid); |
There was a problem hiding this comment.
Skip flag survives source overlap
When a dedicated gesture-button press overlaps with a second gesture source, the overlap branch discards the buffered raw-XY report without clearing skip_first_raw_xy; after the second source is released, the pending flag discards the next genuine movement report, causing a short swipe to commit late or be emitted as a click.
Knowledge Base Used: openlogi-hid: device inventory, pairing, and HID++ feature control
Summary
Fixes #752
The HID++ raw-XY divert buffer accumulates deltas from the moment diversion is activated, not from when the user starts moving. The first sample after any gesture source press carries this buffered noise and must be discarded for ALL gesture sources, not just the haptic panel.
Problem
Previously, only the HapticPanel (CID 0x01A0) discarded its first raw-XY sample via
skip_first_raw_xy. The GestureButton (CID 0x00C3), the primary gesture source on most MX mice, did not, causing the SwipeAccumulator to be poisoned with spurious deltas, resulting in wrong-direction commits.Example from the issue:
All deltas after the first are dx>0, dy=0 (clear rightward swipe), but dy=598 from the first sample dominates the accumulator and forces Down.
Root Cause
In
openlogi-hid/src/session/gesture.rs, theskip_first_raw_xylogic was:Only the HapticPanel got the discard, despite the GestureButton exhibiting the same first-sample noise from the HID++ raw-XY divert buffer.
Fix
Changed the logic to apply to ALL gesture sources:
Now any newly-pressed gesture source will have its first raw-XY sample discarded, preventing buffered noise from poisoning the SwipeAccumulator.
Testing
Updated the test
the_dedicated_buttons_first_sample_is_also_discarded(formerlythe_dedicated_buttons_first_sample_is_not_discarded) to verify the new behavior: the first sample is now discarded and the second sample commits the swipe correctly.Devices Affected