SDL_gesture.h File Reference
`#include "SDL_stdinc.h"`
`#include "SDL_error.h"`
`#include "SDL_video.h"`
`#include "SDL_touch.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_gesture.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Typedefs

typedef Sint64 | SDL_GestureID

## Functions

int | SDL_RecordGesture (SDL_TouchID touchId)
| Begin Recording a gesture on the specified touch, or all touches (-1) More...
int | SDL_SaveAllDollarTemplates (SDL_RWops *dst)
| Save all currently loaded Dollar Gesture templates. More...
int | SDL_SaveDollarTemplate (SDL_GestureID gestureId, SDL_RWops *dst)
| Save a currently loaded Dollar Gesture template. More...
int | SDL_LoadDollarTemplates (SDL_TouchID touchId, SDL_RWops *src)
| Load Dollar Gesture templates from a file. More...

## Detailed Description

Include file for SDL gesture event handling.

Definition in file SDL_gesture.h.

## Typedef Documentation

## SDL_GestureID

typedef Sint64 SDL_GestureID

Definition at line 44 of file SDL_gesture.h.

## Function Documentation

## SDL_LoadDollarTemplates()

int SDL_LoadDollarTemplates | ( | SDL_TouchID | touchId,
|  | SDL_RWops * | src
| ) |  |

Load Dollar Gesture templates from a file.

Definition at line 227 of file SDL_gesture.c.

{
int i,loaded = 0;
SDL_GestureTouch *touch = NULL;
if (src == NULL) return 0;
if (touchId >= 0) {
for (i = 0; i < SDL_numGestureTouches; i++) {
if (SDL_gestureTouch[i].id == touchId) {
touch = &SDL_gestureTouch[i];
}
}
if (touch == NULL) {
return SDL_SetError("given touch id not found");
}
}
while (1) {
SDL_DollarTemplate templ;
if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) {
if (loaded == 0) {
return SDL_SetError("could not read any dollar gesture from rwops");
}
break;
}
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
for (i = 0; i < DOLLARNPOINTS; i++) {
SDL_FloatPoint *p = &templ.path[i];
p->x = SDL_SwapFloatLE(p->x);
p->y = SDL_SwapFloatLE(p->y);
}
#endif
if (touchId >= 0) {
/* printf("Adding loaded gesture to 1 touch\n"); */
if (SDL_AddDollarGesture(touch, templ.path) >= 0)
loaded++;
}
else {
/* printf("Adding to: %i touches\n",SDL_numGestureTouches); */
for (i = 0; i < SDL_numGestureTouches; i++) {
touch = &SDL_gestureTouch[i];
/* printf("Adding loaded gesture to + touches\n"); */
/* TODO: What if this fails? */
SDL_AddDollarGesture(touch,templ.path);
}
loaded++;
}
}
return loaded;
}

References DOLLARNPOINTS, i, NULL, SDL_DollarTemplate::path, SDL_AddDollarGesture(), SDL_gestureTouch, SDL_numGestureTouches, SDL_RWread, SDL_SetError, SDL_SwapFloatLE, and SDL_FloatPoint::x.

## SDL_RecordGesture()

int SDL_RecordGesture | ( | SDL_TouchID | touchId | ) |

Begin Recording a gesture on the specified touch, or all touches (-1)

Definition at line 90 of file SDL_gesture.c.

{
int i;
if (touchId < 0) recordAll = SDL_TRUE;
for (i = 0; i < SDL_numGestureTouches; i++) {
if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
SDL_gestureTouch[i].recording = SDL_TRUE;
if (touchId >= 0)
return 1;
}
}
return (touchId < 0);
}

References i, recordAll, SDL_GestureTouch::recording, SDL_gestureTouch, SDL_numGestureTouches, and SDL_TRUE.

## SDL_SaveAllDollarTemplates()

int SDL_SaveAllDollarTemplates | ( | SDL_RWops * | dst | ) |

Save all currently loaded Dollar Gesture templates.

Definition at line 157 of file SDL_gesture.c.

{
int i,j,rtrn = 0;
for (i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for (j = 0; j < touch->numDollarTemplates; j++) {
rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
}
}
return rtrn;
}

References SDL_GestureTouch::dollarTemplate, i, j, SDL_GestureTouch::numDollarTemplates, SaveTemplate(), SDL_gestureTouch, and SDL_numGestureTouches.

## SDL_SaveDollarTemplate()

int SDL_SaveDollarTemplate | ( | SDL_GestureID | gestureId,
|  | SDL_RWops * | dst
| ) |  |

Save a currently loaded Dollar Gesture template.

Definition at line 169 of file SDL_gesture.c.

{
int i,j;
for (i = 0; i < SDL_numGestureTouches; i++) {
SDL_GestureTouch* touch = &SDL_gestureTouch[i];
for (j = 0; j < touch->numDollarTemplates; j++) {
if (touch->dollarTemplate[j].hash == gestureId) {
return SaveTemplate(&touch->dollarTemplate[j], dst);
}
}
}
return SDL_SetError("Unknown gestureId");
}

References SDL_GestureTouch::dollarTemplate, SDL_DollarTemplate::hash, i, j, SDL_GestureTouch::numDollarTemplates, SaveTemplate(), SDL_gestureTouch, SDL_numGestureTouches, and SDL_SetError.

SDL_DollarTemplate
Definition: SDL_gesture.c:57
SDL_FloatPoint::x
float x
Definition: SDL_gesture.c:47
SDL_DollarTemplate::hash
unsigned long hash
Definition: SDL_gesture.c:59
NULL
#define NULL
Definition: begin_code.h:167
SDL_GestureTouch::dollarTemplate
SDL_DollarTemplate * dollarTemplate
Definition: SDL_gesture.c:69
SaveTemplate
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
Definition: SDL_gesture.c:122
SDL_RWread
#define SDL_RWread
Definition: SDL_dynapi_overrides.h:723
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1737
SDL_GestureTouch::recording
SDL_bool recording
Definition: SDL_gesture.c:71
SDL_FloatPoint
Definition: SDL_gesture.c:46
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11090
SDL_gestureTouch
static SDL_GestureTouch * SDL_gestureTouch
Definition: SDL_gesture.c:74
SDL_SwapFloatLE
#define SDL_SwapFloatLE(X)
Definition: SDL_endian.h:244
SDL_numGestureTouches
static int SDL_numGestureTouches
Definition: SDL_gesture.c:75
SDL_GestureTouch
Definition: SDL_gesture.c:62
DOLLARNPOINTS
#define DOLLARNPOINTS
Definition: SDL_gesture.c:39
SDL_GestureTouch::numDollarTemplates
int numDollarTemplates
Definition: SDL_gesture.c:68
src
GLenum src
Definition: SDL_opengl_glext.h:1737
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
recordAll
static SDL_bool recordAll
Definition: SDL_gesture.c:76
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
j
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
SDL_DollarTemplate::path
SDL_FloatPoint path[DOLLARNPOINTS]
Definition: SDL_gesture.c:58
SDL_AddDollarGesture
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
Definition: SDL_gesture.c:209
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50