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 229 of file SDL_gesture.c.

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

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 92 of file SDL_gesture.c.

93 {
94  int i;
95  if (touchId < 0) recordAll = SDL_TRUE;
96  for (i = 0; i < SDL_numGestureTouches; i++) {
97  if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) {
99  if (touchId >= 0)
100  return 1;
101  }
102  }
103  return (touchId < 0);
104 }

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 159 of file SDL_gesture.c.

160 {
161  int i,j,rtrn = 0;
162  for (i = 0; i < SDL_numGestureTouches; i++) {
164  for (j = 0; j < touch->numDollarTemplates; j++) {
165  rtrn += SaveTemplate(&touch->dollarTemplate[j], dst);
166  }
167  }
168  return rtrn;
169 }

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 171 of file SDL_gesture.c.

172 {
173  int i,j;
174  for (i = 0; i < SDL_numGestureTouches; i++) {
176  for (j = 0; j < touch->numDollarTemplates; j++) {
177  if (touch->dollarTemplate[j].hash == gestureId) {
178  return SaveTemplate(&touch->dollarTemplate[j], dst);
179  }
180  }
181  }
182  return SDL_SetError("Unknown gestureId");
183 }

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:59
SDL_FloatPoint::x
float x
Definition: SDL_gesture.c:49
SDL_DollarTemplate::hash
unsigned long hash
Definition: SDL_gesture.c:61
NULL
#define NULL
Definition: begin_code.h:167
SDL_GestureTouch::dollarTemplate
SDL_DollarTemplate * dollarTemplate
Definition: SDL_gesture.c:71
SaveTemplate
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
Definition: SDL_gesture.c:124
SDL_RWread
#define SDL_RWread
Definition: SDL_dynapi_overrides.h:723
dst
GLenum GLenum dst
Definition: SDL_opengl_glext.h:1740
SDL_GestureTouch::recording
SDL_bool recording
Definition: SDL_gesture.c:73
SDL_FloatPoint
Definition: SDL_gesture.c:48
p
GLfloat GLfloat p
Definition: SDL_opengl_glext.h:11093
SDL_gestureTouch
static SDL_GestureTouch * SDL_gestureTouch
Definition: SDL_gesture.c:76
SDL_SwapFloatLE
#define SDL_SwapFloatLE(X)
Definition: SDL_endian.h:247
SDL_numGestureTouches
static int SDL_numGestureTouches
Definition: SDL_gesture.c:77
SDL_GestureTouch
Definition: SDL_gesture.c:64
DOLLARNPOINTS
#define DOLLARNPOINTS
Definition: SDL_gesture.c:41
SDL_GestureTouch::numDollarTemplates
int numDollarTemplates
Definition: SDL_gesture.c:70
src
GLenum src
Definition: SDL_opengl_glext.h:1740
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
recordAll
static SDL_bool recordAll
Definition: SDL_gesture.c:78
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:60
SDL_AddDollarGesture
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
Definition: SDL_gesture.c:211
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