User Tools

Site Tools


api_reference

API Reference

Overview

The GestureWorks Core API consists of a series of methods, functions and data structures which are used to connect applications to GestureWorks, prompt the core to analyze and process gestures, then return structured gesture event data to the application layer.


Core Functions

The functions available through GestureWorks are as follows:

GestureWorks* initializeGestureWorks(int screen_width, int screen_height)

Initializes GestureWorks with a default set of gestures. This returns an instance of GestureWorks to use on future function calls.

GestureWorks* initializeGestureWorksScreenGestures(int screen_width, int screen_height)

Initializes GestureWorks with default options and a default set of gestures. This is used for screen mode, where gestures are global and not attached to individual touch objects.

GestureWorks* initializeGestureWorksGML(int screen_width, int screen_height, const char *gml_file_path)

Initializes GestureWorks with a custom gml file.

void destroyGestureWorks(GestureWorks *gesture_works)

Deletes an instance of GestureWorks.

bool removeTouchObject(const char *name)

Removes a touch object from GestureWorks.

bool addGesture(GestureWorks *gesture_works, const char *object_id, const char *gesture_id)

Adds a gesture to an object. This passes in the name of the object and the gesture to associate.

void addTouchEvent(GestureWorks *gesture_works, int touch_event_id, int touch_status, float x, float y)

Associates a touch event with a TouchObject. The touch_event_id is the point id, x and y are the coordinates for the point, and touch_status is one of:

	const int GW_TOUCHUPDATE = 0;
	const int GW_TOUCHADDED = 1;
	const int GW_TOUCHREMOVED = 2;

int getPointEvents(GestureWorks *gesture_works, PointInfo **points)

Retrieves the current touch events GestureWorks has. These points are retrieved and then addTouchPointToObject is called to associate a touch event with a GestureWorks TouchObject. The PointInfo structure is:

struct PointInfo
{
	int point_id;
	int status;
	float position_x;
	float position_y;
	int timestamp;
};

bool addTouchPointToObject(GestureWorks *gesture_works, const char *object_id, int point_id)

Associates a touch event with a TouchObject.

bool objectHasTouchPoint(GestureWorks *gesture_works, int point_id)

Tests to see if any current TouchObject already has the touch event.

void updateFrame(GestureWorks *gesture_works)

Updates a frame of GestureWorks.

void updateScreenFrame(GestureWorks *gesture_works)

Updates a frame of GestureWorks running in screen mode.

int getGestureEvents(GestureWorks *gesture_works, GestureInfo **gestures)

Retrieves all of the gestures for a frame.

static const int MAX_GESTURES_FRAME = 100;
static const int MAX_GESTURE_VALUES = 25;
static const int MAX_GESTURE_NAME = 100;
struct GestureInfo
{
	int id;
	char gesture_type[MAX_GESTURE_NAME];
	char gesture_id[MAX_GESTURE_NAME];
	char target[MAX_GESTURE_NAME];
	int source;
	int n;
	int hold_n;
	float x;
	float y;
	int timestamp;
	int phase;
	struct GestureValue
	{
		char name[MAX_GESTURE_NAME];
		float value;
	};
	GestureValue values[MAX_GESTURE_VALUES];
	int gesture_values_count;
};
api_reference.txt ยท Last modified: 2017/05/02 17:04 by curtisb