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) 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

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.

228{
229 int i,loaded = 0;
230 SDL_GestureTouch *touch = NULL;
231 if (src == NULL) return 0;
232 if (touchId >= 0) {
233 for (i = 0; i < SDL_numGestureTouches; i++) {
234 if (SDL_gestureTouch[i].id == touchId) {
235 touch = &SDL_gestureTouch[i];
236 }
237 }
238 if (touch == NULL) {
239 return SDL_SetError("given touch id not found");
240 }
241 }
242
243 while (1) {
244 SDL_DollarTemplate templ;
245
246 if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) {
247 if (loaded == 0) {
248 return SDL_SetError("could not read any dollar gesture from rwops");
249 }
250 break;
251 }
252
253#if SDL_BYTEORDER != SDL_LIL_ENDIAN
254 for (i = 0; i < DOLLARNPOINTS; i++) {
255 SDL_FloatPoint *p = &templ.path[i];
256 p->x = SDL_SwapFloatLE(p->x);
257 p->y = SDL_SwapFloatLE(p->y);
258 }
259#endif
260
261 if (touchId >= 0) {
262 /* printf("Adding loaded gesture to 1 touch\n"); */
263 if (SDL_AddDollarGesture(touch, templ.path) >= 0)
264 loaded++;
265 }
266 else {
267 /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */
268 for (i = 0; i < SDL_numGestureTouches; i++) {
269 touch = &SDL_gestureTouch[i];
270 /* printf("Adding loaded gesture to + touches\n"); */
271 /* TODO: What if this fails? */
272 SDL_AddDollarGesture(touch,templ.path);
273 }
274 loaded++;
275 }
276 }
277
278 return loaded;
279}
#define SDL_SetError
#define SDL_RWread
#define SDL_SwapFloatLE(X)
Definition: SDL_endian.h:235
#define DOLLARNPOINTS
Definition: SDL_gesture.c:39
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
Definition: SDL_gesture.c:209
static SDL_GestureTouch * SDL_gestureTouch
Definition: SDL_gesture.c:74
static int SDL_numGestureTouches
Definition: SDL_gesture.c:75
GLenum src
GLfloat GLfloat p
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
#define NULL
Definition: begin_code.h:167
SDL_FloatPoint path[DOLLARNPOINTS]
Definition: SDL_gesture.c:58

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.

91{
92 int i;
93 if (touchId < 0) recordAll = SDL_TRUE;
94 for (i = 0; i < SDL_numGestureTouches; i++) {
95 if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
97 if (touchId >= 0)
98 return 1;
99 }
100 }
101 return (touchId < 0);
102}
static SDL_bool recordAll
Definition: SDL_gesture.c:76
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_bool recording
Definition: SDL_gesture.c:71

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.

158{
159 int i,j,rtrn = 0;
160 for (i = 0; i < SDL_numGestureTouches; i++) {
162 for (j = 0; j < touch->numDollarTemplates; j++) {
163 rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
164 }
165 }
166 return rtrn;
167}
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
Definition: SDL_gesture.c:122
GLenum GLenum dst
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 * dollarTemplate
Definition: SDL_gesture.c:69

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.

170{
171 int i,j;
172 for (i = 0; i < SDL_numGestureTouches; i++) {
174 for (j = 0; j < touch->numDollarTemplates; j++) {
175 if (touch->dollarTemplate[j].hash == gestureId) {
176 return SaveTemplate(&touch->dollarTemplate[j], dst);
177 }
178 }
179 }
180 return SDL_SetError("Unknown gestureId");
181}
unsigned long hash
Definition: SDL_gesture.c:59

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