Gesture Library
gesturelib.c File Reference
#include "gesturelib.h"
#include "double.h"
#include "drag.h"
#include "hold.h"
#include "hold_and_drag.h"
#include "multidrag.h"
#include "multistroke.h"
#include "rotate.h"
#include "stroke.h"
#include "tap.h"
#include "utils.h"
#include "zoom.h"

Go to the source code of this file.

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(*recognize)(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

gesture_recognizer_t recognizers [MAX_RECOGNIZERS]
 
int num_recognizers = 0
 
touch_event_t latest_touch_events [MAX_TOUCHES]
 set containing most recent touch within finger group More...
 
touch_event_t empty_touch_event = {.type = TOUCH_EVENT_UP, .x = 0, .y = 0, .t = 0, .group = TOUCH_GROUP_UNDEFINED}
 

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

◆ empty_touch_event

touch_event_t empty_touch_event = {.type = TOUCH_EVENT_UP, .x = 0, .y = 0, .t = 0, .group = TOUCH_GROUP_UNDEFINED}

Definition at line 20 of file gesturelib.c.

◆ latest_touch_events

touch_event_t latest_touch_events[MAX_TOUCHES]

set containing most recent touch within finger group

Definition at line 19 of file gesturelib.c.

◆ num_recognizers

int num_recognizers = 0

Definition at line 16 of file gesturelib.c.

◆ recognizers

Definition at line 15 of file gesturelib.c.