pub struct SwipeAccumulator { /* private fields */ }Expand description
The mid-swipe state machine shared by both gesture-capture paths: the HID++
thumb pad (openlogi-hid’s 0x1b04 raw-XY divert) and the OS-hook
Middle/Back/Forward buttons (openlogi-agent-core’s CGEventTap). A gesture
button’s hold accumulates travel; the instant the dominant axis commits a
direction — after the button has been held GESTURE_HOLD_FOR_SWIPE, so a
quick click whose cursor drifted doesn’t count — Self::accumulate returns
that direction exactly once, like Logitech Options+. A hold that never
commits is a plain click, reported by Self::end.
The two paths differ only in what identifies the held control (a
ButtonId for the OS hook, a diverted CID for the thumb pad), so each owns
that and embeds this for the shared travel logic. Keeping the logic in one
place is deliberate: the two copies it replaced had already drifted apart
(one resolved a swipe only on release), which mis-fired the click.
Implementations§
Source§impl SwipeAccumulator
impl SwipeAccumulator
Sourcepub fn is_holding(&self) -> bool
pub fn is_holding(&self) -> bool
Whether a hold is in progress (between Self::begin and Self::end),
so callers can do rising/falling-edge detection without a second flag.
Sourcepub fn accumulate(&mut self, dx: i32, dy: i32) -> Option<GestureDirection>
pub fn accumulate(&mut self, dx: i32, dy: i32) -> Option<GestureDirection>
Feed a pointer-move / raw-XY delta into the current hold. Returns
Some(direction) exactly once per hold — the instant travel commits, and
only after the hold passes GESTURE_HOLD_FOR_SWIPE — and None while
still too short, already committed, or not holding.