Go to the documentation of this file.
22 #include "../SDL_internal.h"
37 #define MAXPATHSIZE 1024
39 #define DOLLARNPOINTS 64
40 #define DOLLARSIZE 256
44 #define PHI 0.618033989
101 return (touchId < 0);
112 unsigned long hash = 5381;
115 hash = ((hash<<5) + hash) + (
unsigned long)
points[
i].
x;
116 hash = ((hash<<5) + hash) + (
unsigned long)
points[
i].
y;
131 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
196 if (!dollarTemplate) {
213 if (inTouch ==
NULL) {
248 return SDL_SetError(
"could not read any dollar gesture from rwops");
253 #if SDL_BYTEORDER != SDL_LIL_ENDIAN
292 (
p.y-templ[
i].
y)*(
p.y-templ[
i].
y)));
307 float x1 = (float)(
PHI*ta + (1-
PHI)*tb);
309 float x2 = (float)((1-
PHI)*ta +
PHI*tb);
344 float xmin,xmax,ymin,ymax;
351 for (
i=1;
i <
path->numPoints;
i++) {
362 centroid.
x = 0;centroid.
y = 0;
365 for (
i = 1;
i <
path->numPoints;
i++) {
369 while (dist +
d > interval) {
374 centroid.
x +=
points[numPoints].x;
375 centroid.
y +=
points[numPoints].y;
390 centroid.
x /= numPoints;
391 centroid.
y /= numPoints;
403 for (
i = 0;
i<numPoints;
i++) {
407 (py - centroid.
y)*
SDL_sin(ang) + centroid.
x);
409 (py - centroid.
y)*
SDL_cos(ang) + centroid.
y);
422 for (
i=0;
i<numPoints;
i++) {
433 float bestDiff = 10000;
443 if (diff < bestDiff) {bestDiff = diff; *bestTempl =
i;}
503 event.mgesture.touchId = touch->
id;
506 event.mgesture.dTheta = dTheta;
507 event.mgesture.dDist = dDist;
517 event.dgesture.touchId = touch->
id;
520 event.dgesture.gestureId = gestureId;
521 event.dgesture.error = error;
532 event.dgesture.touchId = touch->
id;
533 event.dgesture.gestureId = gestureId;
543 float pathDx, pathDy;
557 if (inTouch ==
NULL)
return;
559 x =
event->tfinger.x;
560 y =
event->tfinger.y;
611 float dx =
event->tfinger.dx;
612 float dy =
event->tfinger.dy;
622 path->length += (float)
SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
637 lv.
x = lastP.
x - lastCentroid.
x;
638 lv.
y = lastP.
y - lastCentroid.
y;
654 dDist = (Dist - lDist);
655 if (lDist == 0) {dDist = 0;dtheta = 0;}
GLfixed GLfixed GLint GLint GLfixed points
#define SDL_RWwrite(ctx, ptr, size, n)
static float dollarRecognize(const SDL_DollarPath *path, int *bestTempl, SDL_GestureTouch *touch)
SDL_DollarTemplate * dollarTemplate
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
void SDL_GestureProcessEvent(SDL_Event *event)
GLsizei const GLchar *const * path
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst)
Save a currently loaded Dollar Gesture template.
GLuint GLfloat GLfloat GLfloat x1
GLfloat GLfloat GLfloat GLfloat h
#define SDL_RWread(ctx, ptr, size, n)
GLuint GLsizei GLsizei * length
static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ)
SDL_DollarPath dollarPath
static int dollarNormalize(const SDL_DollarPath *path, SDL_FloatPoint *points)
GLint GLint GLint GLint GLint x
int SDL_GestureDelTouch(SDL_TouchID touchId)
static SDL_GestureTouch * SDL_gestureTouch
#define SDL_SwapFloatLE(X)
static int SDL_numGestureTouches
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
int SDL_GestureAddTouch(SDL_TouchID touchId)
SDL_FloatPoint p[MAXPATHSIZE]
static int SDL_SendGestureMulti(SDL_GestureTouch *touch, float dTheta, float dDist)
int SDL_RecordGesture(SDL_TouchID touchId)
Begin Recording a gesture on the specified touch, or all touches (-1)
static SDL_bool recordAll
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)
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
Load Dollar Gesture templates from a file.
static int SDL_SendDollarRecord(SDL_GestureTouch *touch, SDL_GestureID gestureId)
SDL_FloatPoint path[DOLLARNPOINTS]
static float dollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang)
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
static int SDL_SendGestureDollar(SDL_GestureTouch *touch, SDL_GestureID gestureId, float error)
static unsigned long SDL_HashDollar(SDL_FloatPoint *points)
int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
Save all currently loaded Dollar Gesture templates.
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)
static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
GLubyte GLubyte GLubyte GLubyte w
static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)