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) 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.


Functions

GestureDetector:feedEvent (tevs)
Feeds touch events to state machine.

Parameters:

  • tevs
GestureDetector:getPath (slot)
Compares last_pan with first_tev in this slot.

Parameters:

  • slot

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.
generated by LDoc 1.4.6 Last updated 2017-10-08 14:57:40