src/events/SDL_gesture.c
changeset 4684 f47c2640c667
parent 4683 15dfe42edbfd
child 4685 e0c3b09368a6
     1.1 --- a/src/events/SDL_gesture.c	Wed Aug 04 23:17:30 2010 -0400
     1.2 +++ b/src/events/SDL_gesture.c	Fri Aug 06 01:55:38 2010 -0400
     1.3 @@ -35,6 +35,8 @@
     1.4  #define DOLLARNPOINTS 64
     1.5  #define DOLLARSIZE 256
     1.6  
     1.7 +#define ENABLE_DOLLAR
     1.8 +
     1.9  //PHI = ((sqrt(5)-1)/2)
    1.10  #define PHI 0.618033989 
    1.11  
    1.12 @@ -57,14 +59,14 @@
    1.13    Point p[MAXPATHSIZE];
    1.14  } DollarPath;
    1.15  
    1.16 -
    1.17 +/*
    1.18  typedef struct {
    1.19    Finger f;
    1.20    Point cv;
    1.21    float dtheta,dDist;
    1.22    DollarPath dollarPath;
    1.23  } TouchPoint;
    1.24 -
    1.25 +*/
    1.26  typedef struct {
    1.27    Point path[DOLLARNPOINTS];
    1.28    unsigned long hash;
    1.29 @@ -74,7 +76,8 @@
    1.30    SDL_GestureID id;
    1.31    Point res;
    1.32    Point centroid;
    1.33 -  TouchPoint gestureLast[MAXFINGERS];
    1.34 +  //TouchPoint gestureLast[MAXFINGERS];
    1.35 +  DollarPath dollarPath;
    1.36    Uint16 numDownFingers;
    1.37  
    1.38    int numDollarTemplates;
    1.39 @@ -463,7 +466,7 @@
    1.40        if(inTouch->recording) {
    1.41  	inTouch->recording = SDL_FALSE;
    1.42  	Point path[DOLLARNPOINTS];
    1.43 -	dollarNormalize(inTouch->gestureLast[j].dollarPath,path);
    1.44 +	dollarNormalize(inTouch->dollarPath,path);
    1.45  	int index;
    1.46  	if(recordAll) {
    1.47  	  index = SDL_AddDollarGesture(NULL,path);
    1.48 @@ -485,13 +488,13 @@
    1.49        else {	
    1.50  	int bestTempl;
    1.51  	float error;
    1.52 -	error = dollarRecognize(inTouch->gestureLast[j].dollarPath,
    1.53 +	error = dollarRecognize(inTouch->dollarPath,
    1.54  				&bestTempl,inTouch);
    1.55  	if(bestTempl >= 0){
    1.56  	  //Send Event
    1.57  	  unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
    1.58  	  SDL_SendGestureDollar(inTouch,gestureId,error);
    1.59 -	    printf ("%s\n",);("Dollar error: %f\n",error);
    1.60 +	  //printf ("%s\n",);("Dollar error: %f\n",error);
    1.61  	}
    1.62        }
    1.63  #endif 
    1.64 @@ -508,10 +511,10 @@
    1.65        float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y;
    1.66        //printf("dx,dy: (%f,%f)\n",dx,dy); 
    1.67  #ifdef ENABLE_DOLLAR
    1.68 -      DollarPath* path = &inTouch->gestureLast[j].dollarPath;
    1.69 +      DollarPath* path = &inTouch->dollarPath;
    1.70        if(path->numPoints < MAXPATHSIZE) {
    1.71 -	path->p[path->numPoints].x = x;
    1.72 -	path->p[path->numPoints].y = y;
    1.73 +	path->p[path->numPoints].x = inTouch->centroid.x;
    1.74 +	path->p[path->numPoints].y = inTouch->centroid.y;
    1.75  	path->length += sqrt(dx*dx + dy*dy);
    1.76  	path->numPoints++;
    1.77        }
    1.78 @@ -588,11 +591,11 @@
    1.79  	inTouch->gestureLast[j].cv.x = 0;
    1.80  	inTouch->gestureLast[j].cv.y = 0;
    1.81        */
    1.82 -#ifdef ENABlE_DOLLAR
    1.83 -      inTouch->gestureLast[j].dollarPath.length = 0;
    1.84 -      inTouch->gestureLast[j].dollarPath.p[0].x = x;
    1.85 -      inTouch->gestureLast[j].dollarPath.p[0].y = y;
    1.86 -      inTouch->gestureLast[j].dollarPath.numPoints = 1;
    1.87 +#ifdef ENABLE_DOLLAR
    1.88 +      inTouch->dollarPath.length = 0;
    1.89 +      inTouch->dollarPath.p[0].x = x;
    1.90 +      inTouch->dollarPath.p[0].y = y;
    1.91 +      inTouch->dollarPath.numPoints = 1;
    1.92  #endif
    1.93      }
    1.94    }