touch_dev_gestures.h
1 /*
2  * Copyright (C) 2023 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
145 #ifdef __cplusplus
146 extern "C" {
147 #endif
148 
149 #include <stddef.h>
150 #include <stdint.h>
151 #include <stdbool.h>
152 
153 #include "touch_dev.h"
154 
158 #define TOUCH_DEV_TOUCHES_MAX_NUMOF 2
159 
163 #ifndef CONFIG_TOUCH_DEV_SWIPE_TRESH
164 #define CONFIG_TOUCH_DEV_SWIPE_TRESH 5
165 #endif
166 
170 #ifndef CONFIG_TOUCH_DEV_PRESS_TIME_MS
171 #define CONFIG_TOUCH_DEV_PRESS_TIME_MS 600
172 #endif
173 
177 #ifndef CONFIG_TOUCH_DEV_DOUBLE_TIME_MS
178 #define CONFIG_TOUCH_DEV_DOUBLE_TIME_MS 400
179 #endif
180 
184 typedef enum {
191 
195 typedef enum {
209 
213 typedef struct {
215  uint32_t t_changed;
216  uint32_t t_prev_tap;
218  uint8_t prev_num;
221 
230 
241  touch_t *pos);
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
touch_dev_gesture_t
Touch gesture events.
void touch_dev_init_gesture(touch_dev_t *dev, touch_dev_gesture_ctx_t *ctx)
Initialize gesture recognition.
#define TOUCH_DEV_TOUCHES_MAX_NUMOF
Maximum number of touches supported by 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.
touch_dev_state_t
Touch device states used for gesture recognition.
@ TOUCH_DEV_GEST_PRESSED
Long press recognized at the given position.
@ TOUCH_DEV_GEST_ZOOM_OUT
Zoom out (pinch) recognized, no position is given.
@ TOUCH_DEV_GEST_DOUBLE_TAP
Double tap recognized at the given position.
@ TOUCH_DEV_GEST_NONE
No gesture recognized.
@ TOUCH_DEV_GEST_MOVE
Moving while pressed recognized, current position is given.
@ TOUCH_DEV_GEST_SINGLE_TAP
Single tap recognized at the given position.
@ TOUCH_DEV_GEST_SWIPE_RIGHT
Swipe right recognized, no position is given.
@ TOUCH_DEV_GEST_ZOOM_IN
Zoom in (spread) recognized, no position is given.
@ TOUCH_DEV_GEST_SWIPE_UP
Swipe up recognized, no position is given.
@ TOUCH_DEV_GEST_SWIPE_DOWN
Swipe down recognized, no position is given.
@ TOUCH_DEV_GEST_SWIPE_LEFT
Swipe left recognized, no position is given.
@ TOUCH_DEV_GEST_RELEASED
Release after a long press at given position.
@ TOUCH_DEV_STATE_WAIT_FOR_RELEASE
gesture detected, waiting for releasing touches
@ TOUCH_DEV_STATE_PRESSED
a long press is detected
@ TOUCH_DEV_STATE_RELEASED
no touches detected, default state
@ TOUCH_DEV_STATE_TAPPED_MULTIPLE
a second touch is detected
@ TOUCH_DEV_STATE_TAPPED_SINGLE
a single touch is detected
Context information for a touch device needed for gesture recognition.
uint8_t prev_num
Previous number of touches.
uint32_t t_prev_tap
Time of previous tap.
touch_dev_t * dev
Pointer to the touch device.
uint32_t t_changed
Time of last state change in ms.
touch_dev_state_t state
State of touch device.
Generic type for a touch device.
Definition: touch_dev.h:115
Touch coordinates.
Definition: touch_dev.h:43