From 64805b5e92d0fb1571f919374c6f5e2daeba076d Mon Sep 17 00:00:00 2001 From: Jim Grandpre Date: Sat, 7 Aug 2010 11:32:11 -0400 Subject: [PATCH] Fixed Dollar Recognition. --- src/events/SDL_gesture.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index d45388796..2a03baac8 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -90,6 +90,15 @@ GestureTouch gestureTouch[MAXTOUCHES]; int numGestureTouches = 0; SDL_bool recordAll; +void SDL_PrintPath(Point *path) { + int i; + printf("Path:"); + for(i=0;irecording = SDL_FALSE; Point path[DOLLARNPOINTS]; dollarNormalize(inTouch->dollarPath,path); + SDL_PrintPath(path); int index; if(recordAll) { index = SDL_AddDollarGesture(NULL,path); @@ -515,7 +536,11 @@ void SDL_GestureProcessEvent(SDL_Event* event) if(path->numPoints < MAXPATHSIZE) { path->p[path->numPoints].x = inTouch->centroid.x; path->p[path->numPoints].y = inTouch->centroid.y; - path->length += sqrt(dx*dx + dy*dy); + float pathDx = + (path->p[path->numPoints].x-path->p[path->numPoints-1].x); + float pathDy = + (path->p[path->numPoints].y-path->p[path->numPoints-1].y); + path->length += sqrt(pathDx*pathDx + pathDy*pathDy); path->numPoints++; } #endif @@ -526,7 +551,8 @@ void SDL_GestureProcessEvent(SDL_Event* event) lastCentroid = inTouch->centroid; inTouch->centroid.x += dx/inTouch->numDownFingers; - inTouch->centroid.y += dy/inTouch->numDownFingers; + inTouch->centroid.y += dy/inTouch->numDownFingers; + //printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); if(inTouch->numDownFingers > 1) { Point lv; //Vector from centroid to last x,y position Point v; //Vector from centroid to current x,y position