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 = TimeVal:new{...},
}

Don't confuse tev with raw evs from kernel, tev is build 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: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 with first_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:tapState (tev)
Handles both single and double tap.

Parameters:

  • tev
GestureDetector:adjustGesCoordinate (ges)
Changes gesture's x and y coordinates according to screen view mode.

Parameters:

  • ges gesture that you want to adjust

Returns:

    adjusted gesture.

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
generated by LDoc 1.4.6 Last updated 2020-07-05 22:54:19