Module device.gesturedetector
This module detects gestures.
Current detectable gestures:
touch
(user touched screen)tap
(touch action detected as single tap)pan
hold
swipe
pinch
spread
rotate
hold_pan
double_tap
inward_pan
outward_pan
pan_release
hold_release
two_finger_tap
two_finger_pan
two_finger_swipe
two_finger_pan_release
You change the state machine by feeding it touch events, i.e. calling GestureDetector:feedEvent(tev).
a touch event should have following format:
tev = { slot = 1, id = 46, x = 0, y = 1, timev = time.s(123.23), }
Don't confuse tev
with raw evs from kernel, tev
is built according to ev.
GestureDetector:feedEvent(tev) will return a detection result when you feed a touch release event to it.
Functions
GestureDetector:feedEvent (tevs) | Feeds touch events to state machine. |
GestureDetector:getPath (slot, simple, diagonal, first_tev) | Compares last_pan with first_tev in this slot. |
GestureDetector:probeClockSource (timev) | Attempts to figure out which clock source tap events are using... |
GestureDetector:tapState (tev) | Handles both single and double tap. |
GestureDetector:adjustGesCoordinate (ges) | Changes gesture's x and y coordinates according to screen view mode. |
Issues
GestureDetector:getPath-todo1 | Do we need to check whether state is valid? (houqp) |
GestureDetector:tapState-todo2 | dirty hack for some weird devices, replace it with better solution |
Functions
- GestureDetector:feedEvent (tevs)
-
Feeds touch events to state machine.
Parameters:
- tevs
- GestureDetector:getPath (slot, simple, diagonal, first_tev)
-
Compares
last_pan
withfirst_tev
in this slot.The second boolean argument
simple
results in only four directions if true.Parameters:
- slot
- simple
- diagonal
- first_tev
Returns:
-
(direction, distance) pan direction and distance
- GestureDetector:probeClockSource (timev)
-
Attempts to figure out which clock source tap events are using...
Parameters:
- timev We'll check if that timestamp is +/- 2.5s away from the three potential clock sources supported by evdev. We have bigger issues than this if we're parsing events more than 3s late ;).
- GestureDetector:tapState (tev)
-
Handles both single and double tap.
Parameters:
- tev Attempt to detect the clock source for these events (we reset it on suspend to discriminate MONOTONIC from BOOTTIME).
- GestureDetector:adjustGesCoordinate (ges)
-
Changes gesture's
x
andy
coordinates according to screen view mode.Parameters:
- ges gesture that you want to adjust
Returns:
-
adjusted gesture.