Gestures Library

Touch events are events generated by the touch controller. Touch events are represented by the data structure mtouch_event_t, which contains various types of information about the touch event, such as the type of touch event (touch, move, or release), the timestamp of the event, the coordinates of the touch, and so on. See the file input/event_types.h for more information.

What are touch events?

Touch events are events generated by the touch controller. Touch events are represented by the data structure mtouch_event_t, which contains various types of information about the touch event, such as the type of touch event (touch, move, or release), the timestamp of the event, the coordinates of the touch, and so on. See the file input/event_types.h for more information.

What are gestures?

Gestures are self contained state machines that need not be aware of any other gesture. Inter-gesture relationships and dependencies are to be managed by the gesture set. This makes individual gestures relatively simple to implement and allows the application to customize the desired gesture relationships for its own needs. It also means applications only interested in a small subset of gestures can pick and choose its gestures of interest.

There are two classes of gestures:

  • Composite

  • Discrete

Once a composite (also called transform or continuous) gesture is recognized, it may send further updates to the application as the user keeps touching or moving his/her fingers on the screen. Examples of composite gestures include pinch, rotate and two finger pan.

Conversely, discrete gestures only send a single notification to the application. Examples of discrete gestures include tap, double tap and long press.

What are gesture sets?

You can think of a gesture set as the interface between gestures and the application. The application sends touch events to a gesture set, not to individual gestures. Individual gestures must belong to a gesture set to be able to receive touch events and invoke callback functions when gesture state transitions happen.

Gestures provide a list of callbacks to the gesture set. One of these is the process_event() callback; this is how a gesture receives touch events. This callback returns the new (or unchanged) state for the gesture, and the gesture set takes care of any handling required as part of the state transition, for example:

  • Invoking the set callback (gesture recognized or updated)

  • Resetting all gestures in the set when they've all completed or failed

  • Managing failure dependencies between gestures

  • Timer handling for gestures needing time events (as opposed to touch events)

  • Failure notification when all gestures in a set have failed

What's in the gestures library?

The gestures library contains the following public header files: