Gesture Library
gesturelib.h File Reference
#include "gestureparams.h"
#include "stdint.h"

Go to the source code of this file.

Data Structures

struct  touch_event
 To use the gesture library, users create touch events and fill in the appropriate fields. More...
 
struct  gesture_recognizer
 The user may create their own gesture recognizer to add to the library. More...
 

Typedefs

typedef enum event_type event_type_t
 This is the type of touch event. There are only 3 supported types. More...
 
typedef struct touch_event touch_event_t
 To use the gesture library, users create touch events and fill in the appropriate fields. More...
 
typedef struct gesture_recognizer gesture_recognizer_t
 The user may create their own gesture recognizer to add to the library. More...
 

Enumerations

enum  event_type { TOUCH_EVENT_DOWN , TOUCH_EVENT_MOVE , TOUCH_EVENT_UP }
 This is the type of touch event. There are only 3 supported types. More...
 

Functions

int init_gesturelib ()
 This function should be called by the user before passing touch events to the library. Calling process_touch_event before library initialization results in undefined behavior. More...
 
void process_touch_event (touch_event_t *touch_event)
 Users call this function with a generated touch event to let the library process it. To obtain recognized gestures, users call the accessor function of their desired recognizer or register a listener to their desired recognizer before processing touch events. More...
 
int add_recognizer (void(*recognizer)(const touch_event_t *), void(*init)(void))
 Register a recognizer via a recognition function. More...
 
gesture_recognizer_t remove_recognizer (int recognizer)
 Remove a recognizer in the library. More...
 
int enable_recognizer (int recognizer)
 Enable a recognizer already in the library. More...
 
int disable_recognizer (int recognizer)
 Disable a recognizer already in the library. More...
 

Variables

int num_recognizers
 
touch_event_t latest_touch_events []
 set containing most recent touch within finger group More...
 

Typedef Documentation

◆ event_type_t

typedef enum event_type event_type_t

This is the type of touch event. There are only 3 supported types.

◆ gesture_recognizer_t

The user may create their own gesture recognizer to add to the library.

◆ touch_event_t

typedef struct touch_event touch_event_t

To use the gesture library, users create touch events and fill in the appropriate fields.

Enumeration Type Documentation

◆ event_type

enum event_type

This is the type of touch event. There are only 3 supported types.

Enumerator
TOUCH_EVENT_DOWN 
TOUCH_EVENT_MOVE 
TOUCH_EVENT_UP 

Definition at line 7 of file gesturelib.h.

Function Documentation

◆ add_recognizer()

int add_recognizer ( void(*)(const touch_event_t *)  recognizer,
void(*)(void)  init 
)

Register a recognizer via a recognition function.

Parameters
recognizeThe recognition function to add.
initRecognizer initialization function, pass 0 or NULL for none.
Returns
Which index the recognizer is saved to. -1 if the recognizer could not be saved.

Definition at line 111 of file gesturelib.c.

◆ disable_recognizer()

int disable_recognizer ( int  recognizer)

Disable a recognizer already in the library.

Parameters
recognizerIndex of the recognizer to disable.
Returns
0 if an invalid index is provided, 1 otherwise.

Definition at line 148 of file gesturelib.c.

◆ enable_recognizer()

int enable_recognizer ( int  recognizer)

Enable a recognizer already in the library.

Parameters
recognizerIndex of the recognizer to enable.
Returns
0 if an invalid index is provided, 1 otherwise.

Definition at line 137 of file gesturelib.c.

◆ init_gesturelib()

int init_gesturelib ( )

This function should be called by the user before passing touch events to the library. Calling process_touch_event before library initialization results in undefined behavior.

Definition at line 29 of file gesturelib.c.

◆ process_touch_event()

void process_touch_event ( touch_event_t touch_event)

Users call this function with a generated touch event to let the library process it. To obtain recognized gestures, users call the accessor function of their desired recognizer or register a listener to their desired recognizer before processing touch events.

Parameters
touch_eventThe user generated touch event to process.

Definition at line 51 of file gesturelib.c.

◆ remove_recognizer()

gesture_recognizer_t remove_recognizer ( int  recognizer)

Remove a recognizer in the library.

Parameters
recognizerIndex of the recognizer to remove.
Returns
The removed recognizer. If an invalid index is provided, will return an empty recognizer with null recognize and init functions.

Definition at line 123 of file gesturelib.c.

Variable Documentation

◆ latest_touch_events

touch_event_t latest_touch_events[]
extern

set containing most recent touch within finger group

Definition at line 19 of file gesturelib.c.

◆ num_recognizers

int num_recognizers
extern

Definition at line 16 of file gesturelib.c.