Gesture Library
stroke.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gesturelib.h"
4 #include "recognizer.h"
5 
6 #ifndef STROKE_CACHE_SIZE
7 // needs to be at least 2 in order to calculate velocity
8 #define STROKE_CACHE_SIZE 30
9 #endif
10 
12 typedef struct stroke {
13  // recognizer state
15 
16  // touch event group
17  unsigned int group;
18  // user id
19  int uid;
20 
21  // initial position and time
22  float x0;
23  float y0;
24  float t0;
25 
26  // current position and time
27  float x;
28  float y;
29  float t;
30 
31  // moving average velocity
32  float vx;
33  float vy;
34 
35  // instantaneous velocity cache
41 
43 void init_stroke();
44 
47 void recognize_stroke(const touch_event_t* event);
48 
51 const stroke_t* get_stroke();
enum state state_t
This represents the state of individual gesture recognizers.
void init_stroke()
Initialize stroke data structures.
Definition: stroke.c:7
struct stroke stroke_t
Data structure for stroke gesture data.
#define STROKE_CACHE_SIZE
Definition: stroke.h:8
const stroke_t * get_stroke()
Access array of stroke_t of size MAX_TOUCHES.
Definition: stroke.c:47
void recognize_stroke(const touch_event_t *event)
Recognize stroke gesture.
Definition: stroke.c:33
Data structure for stroke gesture data.
Definition: stroke.h:12
float x0
Definition: stroke.h:22
state_t state
Definition: stroke.h:14
float vy
Definition: stroke.h:33
int uid
Definition: stroke.h:19
float t0
Definition: stroke.h:24
int cache_last
Definition: stroke.h:36
unsigned int group
Definition: stroke.h:17
float vx
Definition: stroke.h:32
float y
Definition: stroke.h:28
float cache_vy[STROKE_CACHE_SIZE]
Definition: stroke.h:38
float cache_vx[STROKE_CACHE_SIZE]
Definition: stroke.h:39
float x
Definition: stroke.h:27
int cache_size
Definition: stroke.h:37
float y0
Definition: stroke.h:23
float t
Definition: stroke.h:29
To use the gesture library, users create touch events and fill in the appropriate fields.
Definition: gesturelib.h:17