22 #include "../SDL_internal.h"
37 #define MAXPATHSIZE 1024
41 #define DOLLARNPOINTS 64
43 #if defined(ENABLE_DOLLAR)
44 # define DOLLARSIZE 256
45 # define PHI 0.618033989
103 return (touchId < 0);
114 unsigned long hash = 5381;
117 hash = ((hash<<5) + hash) + (
unsigned long)
points[
i].
x;
118 hash = ((hash<<5) + hash) + (
unsigned long)
points[
i].
y;
133 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
198 if (!dollarTemplate) {
215 if (inTouch ==
NULL) {
250 return SDL_SetError(
"could not read any dollar gesture from rwops");
255 #if SDL_BYTEORDER != SDL_LIL_ENDIAN
284 #if defined(ENABLE_DOLLAR)
295 (
p.y-templ[
i].
y)*(
p.y-templ[
i].
y)));
310 float x1 = (float)(
PHI*ta + (1-
PHI)*tb);
312 float x2 = (float)((1-
PHI)*ta +
PHI*tb);
347 float xmin,xmax,ymin,ymax;
354 for (
i=1;
i <
path->numPoints;
i++) {
365 centroid.
x = 0;centroid.
y = 0;
368 for (
i = 1;
i <
path->numPoints;
i++) {
372 while (dist +
d > interval) {
377 centroid.
x +=
points[numPoints].x;
378 centroid.
y +=
points[numPoints].y;
395 centroid.
x /= numPoints;
396 centroid.
y /= numPoints;
408 for (
i = 0;
i<numPoints;
i++) {
412 (py - centroid.
y)*
SDL_sin(ang) + centroid.
x);
414 (py - centroid.
y)*
SDL_cos(ang) + centroid.
y);
427 for (
i=0;
i<numPoints;
i++) {
438 float bestDiff = 10000;
448 if (diff < bestDiff) {bestDiff = diff; *bestTempl =
i;}
510 event.mgesture.touchId = touch->
id;
513 event.mgesture.dTheta = dTheta;
514 event.mgesture.dDist = dDist;
520 #if defined(ENABLE_DOLLAR)
527 event.dgesture.touchId = touch->
id;
530 event.dgesture.gestureId = gestureId;
531 event.dgesture.error = error;
543 event.dgesture.touchId = touch->
id;
544 event.dgesture.gestureId = gestureId;
554 #if defined(ENABLE_DOLLAR)
557 float pathDx, pathDy;
572 if (inTouch ==
NULL)
return;
574 x =
event->tfinger.x;
575 y =
event->tfinger.y;
579 #if defined(ENABLE_DOLLAR)
585 #if defined(ENABLE_DOLLAR)
628 float dx =
event->tfinger.dx;
629 float dy =
event->tfinger.dy;
630 #if defined(ENABLE_DOLLAR)
639 path->length += (float)
SDL_sqrt(pathDx*pathDx + pathDy*pathDy);
654 lv.
x = lastP.
x - lastCentroid.
x;
655 lv.
y = lastP.
y - lastCentroid.
y;
671 dDist = (Dist - lDist);
672 if (lDist == 0) {dDist = 0;dtheta = 0;}
707 #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()
#define SDL_GetEventState(type)
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)
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)
static void SDL_SendGestureDollar(SDL_GestureTouch *touch, SDL_GestureID gestureId, float error)
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 void SDL_SendDollarRecord(SDL_GestureTouch *touch, SDL_GestureID gestureId)
static int dollarNormalize(const SDL_DollarPath *path, SDL_FloatPoint *points, SDL_bool is_recording)
static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
void SDL_GestureProcessEvent(SDL_Event *event)
static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
static SDL_bool recordAll
static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
static void SDL_SendGestureMulti(SDL_GestureTouch *touch, float dTheta, float dDist)
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 in 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 int in j)
SDL_FloatPoint p[MAXPATHSIZE]
SDL_FloatPoint path[DOLLARNPOINTS]
SDL_DollarTemplate * dollarTemplate
SDL_DollarPath dollarPath