Skip to main content

classify_gesture

Function classify_gesture 

Source
pub fn classify_gesture(dx: i32, dy: i32, min_travel: u32) -> GestureDirection
Expand description

Classify an accumulated raw-XY swipe — the summed dx/dy the device reports while the gesture button is held — into one of the five GestureDirection slots.

Returns GestureDirection::Click when the total travel is shorter than min_travel (a press with no meaningful movement). Otherwise the dominant axis decides: larger |dx| ⇒ Left/Right, larger |dy| ⇒ Up/Down, with ties favouring the horizontal axis. Coordinates follow the device’s raw-XY convention (+x = right, +y = down), so an upward swipe (negative dy) maps to GestureDirection::Up; flip the sign at the call site for a device that reports an inverted axis.