Commit f15f76c9 authored by Jim Grandpre's avatar Jim Grandpre

Re-enabled dollar gesture

parent bcd4b4df
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#define DOLLARNPOINTS 64 #define DOLLARNPOINTS 64
#define DOLLARSIZE 256 #define DOLLARSIZE 256
#define ENABLE_DOLLAR
//PHI = ((sqrt(5)-1)/2) //PHI = ((sqrt(5)-1)/2)
#define PHI 0.618033989 #define PHI 0.618033989
...@@ -57,14 +59,14 @@ typedef struct { ...@@ -57,14 +59,14 @@ typedef struct {
Point p[MAXPATHSIZE]; Point p[MAXPATHSIZE];
} DollarPath; } DollarPath;
/*
typedef struct { typedef struct {
Finger f; Finger f;
Point cv; Point cv;
float dtheta,dDist; float dtheta,dDist;
DollarPath dollarPath; DollarPath dollarPath;
} TouchPoint; } TouchPoint;
*/
typedef struct { typedef struct {
Point path[DOLLARNPOINTS]; Point path[DOLLARNPOINTS];
unsigned long hash; unsigned long hash;
...@@ -74,7 +76,8 @@ typedef struct { ...@@ -74,7 +76,8 @@ typedef struct {
SDL_GestureID id; SDL_GestureID id;
Point res; Point res;
Point centroid; Point centroid;
TouchPoint gestureLast[MAXFINGERS]; //TouchPoint gestureLast[MAXFINGERS];
DollarPath dollarPath;
Uint16 numDownFingers; Uint16 numDownFingers;
int numDollarTemplates; int numDollarTemplates;
...@@ -463,7 +466,7 @@ void SDL_GestureProcessEvent(SDL_Event* event) ...@@ -463,7 +466,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
if(inTouch->recording) { if(inTouch->recording) {
inTouch->recording = SDL_FALSE; inTouch->recording = SDL_FALSE;
Point path[DOLLARNPOINTS]; Point path[DOLLARNPOINTS];
dollarNormalize(inTouch->gestureLast[j].dollarPath,path); dollarNormalize(inTouch->dollarPath,path);
int index; int index;
if(recordAll) { if(recordAll) {
index = SDL_AddDollarGesture(NULL,path); index = SDL_AddDollarGesture(NULL,path);
...@@ -485,13 +488,13 @@ void SDL_GestureProcessEvent(SDL_Event* event) ...@@ -485,13 +488,13 @@ void SDL_GestureProcessEvent(SDL_Event* event)
else { else {
int bestTempl; int bestTempl;
float error; float error;
error = dollarRecognize(inTouch->gestureLast[j].dollarPath, error = dollarRecognize(inTouch->dollarPath,
&bestTempl,inTouch); &bestTempl,inTouch);
if(bestTempl >= 0){ if(bestTempl >= 0){
//Send Event //Send Event
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
SDL_SendGestureDollar(inTouch,gestureId,error); SDL_SendGestureDollar(inTouch,gestureId,error);
printf ("%s\n",);("Dollar error: %f\n",error); //printf ("%s\n",);("Dollar error: %f\n",error);
} }
} }
#endif #endif
...@@ -508,10 +511,10 @@ void SDL_GestureProcessEvent(SDL_Event* event) ...@@ -508,10 +511,10 @@ void SDL_GestureProcessEvent(SDL_Event* event)
float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y; float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y;
//printf("dx,dy: (%f,%f)\n",dx,dy); //printf("dx,dy: (%f,%f)\n",dx,dy);
#ifdef ENABLE_DOLLAR #ifdef ENABLE_DOLLAR
DollarPath* path = &inTouch->gestureLast[j].dollarPath; DollarPath* path = &inTouch->dollarPath;
if(path->numPoints < MAXPATHSIZE) { if(path->numPoints < MAXPATHSIZE) {
path->p[path->numPoints].x = x; path->p[path->numPoints].x = inTouch->centroid.x;
path->p[path->numPoints].y = y; path->p[path->numPoints].y = inTouch->centroid.y;
path->length += sqrt(dx*dx + dy*dy); path->length += sqrt(dx*dx + dy*dy);
path->numPoints++; path->numPoints++;
} }
...@@ -588,11 +591,11 @@ void SDL_GestureProcessEvent(SDL_Event* event) ...@@ -588,11 +591,11 @@ void SDL_GestureProcessEvent(SDL_Event* event)
inTouch->gestureLast[j].cv.x = 0; inTouch->gestureLast[j].cv.x = 0;
inTouch->gestureLast[j].cv.y = 0; inTouch->gestureLast[j].cv.y = 0;
*/ */
#ifdef ENABlE_DOLLAR #ifdef ENABLE_DOLLAR
inTouch->gestureLast[j].dollarPath.length = 0; inTouch->dollarPath.length = 0;
inTouch->gestureLast[j].dollarPath.p[0].x = x; inTouch->dollarPath.p[0].x = x;
inTouch->gestureLast[j].dollarPath.p[0].y = y; inTouch->dollarPath.p[0].y = y;
inTouch->gestureLast[j].dollarPath.numPoints = 1; inTouch->dollarPath.numPoints = 1;
#endif #endif
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment