From 04b0dd95d92d4218081a23288c36670569e137fe Mon Sep 17 00:00:00 2001 From: Jim Grandpre Date: Fri, 6 Aug 2010 01:55:38 -0400 Subject: [PATCH] Re-enabled dollar gesture --- src/events/SDL_gesture.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 6d057585f..d45388796 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -35,6 +35,8 @@ #define DOLLARNPOINTS 64 #define DOLLARSIZE 256 +#define ENABLE_DOLLAR + //PHI = ((sqrt(5)-1)/2) #define PHI 0.618033989 @@ -57,14 +59,14 @@ typedef struct { Point p[MAXPATHSIZE]; } DollarPath; - +/* typedef struct { Finger f; Point cv; float dtheta,dDist; DollarPath dollarPath; } TouchPoint; - +*/ typedef struct { Point path[DOLLARNPOINTS]; unsigned long hash; @@ -74,7 +76,8 @@ typedef struct { SDL_GestureID id; Point res; Point centroid; - TouchPoint gestureLast[MAXFINGERS]; + //TouchPoint gestureLast[MAXFINGERS]; + DollarPath dollarPath; Uint16 numDownFingers; int numDollarTemplates; @@ -463,7 +466,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) if(inTouch->recording) { inTouch->recording = SDL_FALSE; Point path[DOLLARNPOINTS]; - dollarNormalize(inTouch->gestureLast[j].dollarPath,path); + dollarNormalize(inTouch->dollarPath,path); int index; if(recordAll) { index = SDL_AddDollarGesture(NULL,path); @@ -485,13 +488,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) else { int bestTempl; float error; - error = dollarRecognize(inTouch->gestureLast[j].dollarPath, + error = dollarRecognize(inTouch->dollarPath, &bestTempl,inTouch); if(bestTempl >= 0){ //Send Event unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); - printf ("%s\n",);("Dollar error: %f\n",error); + //printf ("%s\n",);("Dollar error: %f\n",error); } } #endif @@ -508,10 +511,10 @@ void SDL_GestureProcessEvent(SDL_Event* event) float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y; //printf("dx,dy: (%f,%f)\n",dx,dy); #ifdef ENABLE_DOLLAR - DollarPath* path = &inTouch->gestureLast[j].dollarPath; + DollarPath* path = &inTouch->dollarPath; if(path->numPoints < MAXPATHSIZE) { - path->p[path->numPoints].x = x; - path->p[path->numPoints].y = y; + path->p[path->numPoints].x = inTouch->centroid.x; + path->p[path->numPoints].y = inTouch->centroid.y; path->length += sqrt(dx*dx + dy*dy); path->numPoints++; } @@ -588,11 +591,11 @@ void SDL_GestureProcessEvent(SDL_Event* event) inTouch->gestureLast[j].cv.x = 0; inTouch->gestureLast[j].cv.y = 0; */ -#ifdef ENABlE_DOLLAR - inTouch->gestureLast[j].dollarPath.length = 0; - inTouch->gestureLast[j].dollarPath.p[0].x = x; - inTouch->gestureLast[j].dollarPath.p[0].y = y; - inTouch->gestureLast[j].dollarPath.numPoints = 1; +#ifdef ENABLE_DOLLAR + inTouch->dollarPath.length = 0; + inTouch->dollarPath.p[0].x = x; + inTouch->dollarPath.p[0].y = y; + inTouch->dollarPath.numPoints = 1; #endif } }