SDL  2.0
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)
int SDL_SaveAllDollarTemplates (SDL_RWops *dst)
 Save all currently loaded Dollar Gesture templates.
int SDL_SaveDollarTemplate (SDL_GestureID gestureId, SDL_RWops *dst)
 Save a currently loaded Dollar Gesture template.
int SDL_LoadDollarTemplates (SDL_TouchID touchId, SDL_RWops *src)
 Load Dollar Gesture templates from a file.

Detailed Description

Include file for SDL gesture event handling.

Definition in file SDL_gesture.h.

Typedef Documentation

Definition at line 44 of file SDL_gesture.h.

Function Documentation

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.

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

{
int i,loaded = 0;
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) {
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;
}
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.

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

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

Save all currently loaded Dollar Gesture templates.

Definition at line 157 of file SDL_gesture.c.

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

{
int i,j,rtrn = 0;
for (i = 0; i < SDL_numGestureTouches; i++) {
for (j = 0; j < touch->numDollarTemplates; j++) {
rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
}
}
return rtrn;
}
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.

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

{
int i,j;
for (i = 0; i < SDL_numGestureTouches; 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");
}