Go to the documentation of this file.
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)
GLfixed GLfixed GLint GLint GLfixed points
static float dollarRecognize(const SDL_DollarPath *path, int *bestTempl, SDL_GestureTouch *touch)
SDL_DollarTemplate * dollarTemplate
static void SDL_SendDollarRecord(SDL_GestureTouch *touch, SDL_GestureID gestureId)
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
GLuint GLsizei GLsizei * length
static float bestDollarDifference(SDL_FloatPoint *points, SDL_FloatPoint *templ)
SDL_DollarPath dollarPath
GLint GLint GLint GLint GLint x
#define SDL_GetEventState(type)
static void SDL_SendGestureMulti(SDL_GestureTouch *touch, float dTheta, float dDist)
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]
int SDL_RecordGesture(SDL_TouchID touchId)
Begin Recording a gesture on the specified touch, or all touches (-1)
static SDL_bool recordAll
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
Load Dollar Gesture templates from a file.
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)
static int dollarNormalize(const SDL_DollarPath *path, SDL_FloatPoint *points, SDL_bool is_recording)
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 unsigned long SDL_HashDollar(SDL_FloatPoint *points)
int SDL_SaveAllDollarTemplates(SDL_RWops *dst)
Save all currently loaded Dollar Gesture templates.
static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
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 void SDL_SendGestureDollar(SDL_GestureTouch *touch, SDL_GestureID gestureId, float error)
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING 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)