Gesture recognition for touch devices. More...
Gesture recognition for touch devices.
This driver implements a simple gesture recognition with a maximum of two touches for touch devices that use the generic touch device API.
The application that receives the events from the touch device via the callback function registered with touch_dev_set_touch_event_callback must first create and initialize a touch device gesture context of type touch_dev_gesture_ctx_t. For each touch event received from the touch device, it then calls touch_dev_recognize_gesture function with this context so that the gesture recognition fetches the data from the touch device to detect the gestures, for example:
If the event-driven approach cannot be used because either the touch device does not support all these touch events or the application wants to use the touch device in polling mode, the application must call the touch_dev_recognize_gesture function with the gesture context of the touch device at regular intervals, for example:
The following gestures are supported by the driver:
Data Structures | |
struct | touch_dev_gesture_ctx_t |
Context information for a touch device needed for gesture recognition. More... | |
Macros | |
#define | TOUCH_DEV_TOUCHES_MAX_NUMOF 2 |
Maximum number of touches supported by gesture recognition. | |
#define | CONFIG_TOUCH_DEV_SWIPE_TRESH 5 |
Minimum distance in one direction to recognize a swipe gesture. | |
#define | CONFIG_TOUCH_DEV_PRESS_TIME_MS 600 |
Minimum touch time in milliseconds to detect a long press gesture. | |
#define | CONFIG_TOUCH_DEV_DOUBLE_TIME_MS 400 |
Maximum time in milliseconds between two taps to detect a double tap. | |
Enumerations | |
enum | touch_dev_state_t { TOUCH_DEV_STATE_RELEASED , TOUCH_DEV_STATE_TAPPED_SINGLE , TOUCH_DEV_STATE_TAPPED_MULTIPLE , TOUCH_DEV_STATE_PRESSED , TOUCH_DEV_STATE_WAIT_FOR_RELEASE } |
Touch device states used for gesture recognition. More... | |
enum | touch_dev_gesture_t { TOUCH_DEV_GEST_NONE , TOUCH_DEV_GEST_SINGLE_TAP , TOUCH_DEV_GEST_DOUBLE_TAP , TOUCH_DEV_GEST_PRESSED , TOUCH_DEV_GEST_RELEASED , TOUCH_DEV_GEST_MOVE , TOUCH_DEV_GEST_SWIPE_LEFT , TOUCH_DEV_GEST_SWIPE_RIGHT , TOUCH_DEV_GEST_SWIPE_UP , TOUCH_DEV_GEST_SWIPE_DOWN , TOUCH_DEV_GEST_ZOOM_IN , TOUCH_DEV_GEST_ZOOM_OUT } |
Touch gesture events. More... | |
Functions | |
void | touch_dev_init_gesture (touch_dev_t *dev, touch_dev_gesture_ctx_t *ctx) |
Initialize gesture recognition. | |
touch_dev_gesture_t | touch_dev_recognize_gesture (touch_dev_gesture_ctx_t *ctx, touch_t *pos) |
Recognize gestures by handling next touch device event. | |
#define CONFIG_TOUCH_DEV_DOUBLE_TIME_MS 400 |
Maximum time in milliseconds between two taps to detect a double tap.
Definition at line 179 of file touch_dev_gestures.h.
#define CONFIG_TOUCH_DEV_PRESS_TIME_MS 600 |
Minimum touch time in milliseconds to detect a long press gesture.
Definition at line 172 of file touch_dev_gestures.h.
#define CONFIG_TOUCH_DEV_SWIPE_TRESH 5 |
Minimum distance in one direction to recognize a swipe gesture.
Definition at line 165 of file touch_dev_gestures.h.
#define TOUCH_DEV_TOUCHES_MAX_NUMOF 2 |
Maximum number of touches supported by gesture recognition.
Definition at line 159 of file touch_dev_gestures.h.
enum touch_dev_gesture_t |
Touch gesture events.
Definition at line 196 of file touch_dev_gestures.h.
enum touch_dev_state_t |
Touch device states used for gesture recognition.
Definition at line 185 of file touch_dev_gestures.h.
void touch_dev_init_gesture | ( | touch_dev_t * | dev, |
touch_dev_gesture_ctx_t * | ctx | ||
) |
Initialize gesture recognition.
[in] | dev | Pointer to the touch device |
[in] | ctx | Pointer to the context information for the touch device |
touch_dev_gesture_t touch_dev_recognize_gesture | ( | touch_dev_gesture_ctx_t * | ctx, |
touch_t * | pos | ||
) |
Recognize gestures by handling next touch device event.
[in] | ctx | Pointer to the context information for the touch device |
[out] | pos | Position of the gesture if interested in it (can be NULL) |
return the gesture of type touch_dev_gesture_t if one was recognized or TOUCH_DEV_GEST_NONE