data-niklas / gestures

Gesture recognition in C
MIT License
3 stars 2 forks source link
c gesture-recognition library mouse-gestures

Gestures - A simple gesture recognition C library

Use Case

How to use

Gesture *right = gesture_create(); right->id = 0; right->action = some_function;

GestureVector *vector = gesture_vector_create(); vector->x = 200; vector->y = 0; // More points? // vector->next = somenewvector;

right->vector = vector;

gesture_register(right);

Gesture *complex = gesture_create(); complex->id = 1; complex->action = some_function;

// Quick create list of vectors, no need to set vector->next manually int points[] = {50, -100, 100, 0, 0, 0}; GestureVector *vector = gesture_vector_create_from_array(points, 3); complex->vector = vector;

gesture_register(complex);

gesture_start(startx, starty);

//feed it coordinates several times gesture_track(x, y); // gesture_stop();

// On programm finish gesture_unregister(right); gesture_unregister(complex); gesture_destroy(right); gesture_destroy(complex); gesture_finish();



- The tolerance can be changed
- e.g.: `GESTURE_TOLERANCE = 100;`
- The action is called with the id of the gesture