22#include "../SDL_internal.h"
37#define MAXPATHSIZE 1024
39#define DOLLARNPOINTS 64
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
282#if defined(ENABLE_DOLLAR)
293 (
p.y-templ[
i].
y)*(
p.y-templ[
i].
y)));
308 float x1 = (float)(
PHI*ta + (1-
PHI)*tb);
310 float x2 = (float)((1-
PHI)*ta +
PHI*tb);
345 float xmin,xmax,ymin,ymax;
352 for (
i=1;
i <
path->numPoints;
i++) {
363 centroid.
x = 0;centroid.
y = 0;
366 for (
i = 1;
i <
path->numPoints;
i++) {
370 while (dist +
d > interval) {
375 centroid.
x +=
points[numPoints].x;
376 centroid.
y +=
points[numPoints].y;
391 centroid.
x /= numPoints;
392 centroid.
y /= numPoints;
404 for (
i = 0;
i<numPoints;
i++) {
408 (py - centroid.
y)*
SDL_sin(ang) + centroid.
x);
410 (py - centroid.
y)*
SDL_cos(ang) + centroid.
y);
423 for (
i=0;
i<numPoints;
i++) {
434 float bestDiff = 10000;
444 if (diff < bestDiff) {bestDiff = diff; *bestTempl =
i;}
505 event.mgesture.touchId = touch->
id;
508 event.mgesture.dTheta = dTheta;
509 event.mgesture.dDist = dDist;
514#if defined(ENABLE_DOLLAR)
520 event.dgesture.touchId = touch->
id;
523 event.dgesture.gestureId = gestureId;
524 event.dgesture.error = error;
535 event.dgesture.touchId = touch->
id;
536 event.dgesture.gestureId = gestureId;
545#if defined(ENABLE_DOLLAR)
548 float pathDx, pathDy;
563 if (inTouch ==
NULL)
return;
565 x =
event->tfinger.x;
566 y =
event->tfinger.y;
570#if defined(ENABLE_DOLLAR)
576#if defined(ENABLE_DOLLAR)
619 float dx =
event->tfinger.dx;
620 float dy =
event->tfinger.dy;
621#if defined(ENABLE_DOLLAR)
630 path->length += (float)
SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
645 lv.
x = lastP.
x - lastCentroid.
x;
646 lv.
y = lastP.
y - lastCentroid.
y;
662 dDist = (Dist - lDist);
663 if (lDist == 0) {dDist = 0;dtheta = 0;}
698#if defined(ENABLE_DOLLAR)
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
#define SDL_SwapFloatLE(X)
#define SDL_OutOfMemory()
static int SDL_SendGestureDollar(SDL_GestureTouch *touch, SDL_GestureID gestureId, float error)
static unsigned long SDL_HashDollar(SDL_FloatPoint *points)
static float dollarRecognize(const SDL_DollarPath *path, int *bestTempl, SDL_GestureTouch *touch)
int SDL_GestureAddTouch(SDL_TouchID touchId)
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
int SDL_GestureDelTouch(SDL_TouchID touchId)
int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
Save all currently loaded Dollar Gesture templates.
static float dollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ, float ang)
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.
static int SDL_SendDollarRecord(SDL_GestureTouch *touch, SDL_GestureID gestureId)
static int SDL_SendGestureMulti(SDL_GestureTouch *touch, float dTheta, float dDist)
static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
void SDL_GestureProcessEvent(SDL_Event *event)
static SDL_bool recordAll
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
static int dollarNormalize(const SDL_DollarPath *path, SDL_FloatPoint *points)
static SDL_GestureTouch * SDL_gestureTouch
static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ)
int SDL_RecordGesture(SDL_TouchID touchId)
Begin Recording a gesture on the specified touch, or all touches (-1)
static int SDL_numGestureTouches
GLint GLint GLint GLint GLint GLint y
GLint GLint GLint GLint GLint x
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLfloat GLfloat GLfloat x1
GLsizei const GLchar *const * path
GLuint GLsizei GLsizei * length
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
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)
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)
SDL_FloatPoint p[MAXPATHSIZE]
SDL_FloatPoint path[DOLLARNPOINTS]
SDL_DollarTemplate * dollarTemplate
SDL_DollarPath dollarPath