1.1 --- a/src/events/SDL_gesture.c Wed Aug 21 09:43:09 2013 -0300
1.2 +++ b/src/events/SDL_gesture.c Wed Aug 21 09:47:10 2013 -0300
1.3 @@ -121,8 +121,8 @@
1.4 if (src == NULL) return 0;
1.5
1.6
1.7 - /*No Longer storing the Hash, rehash on load */
1.8 - /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */
1.9 + /* No Longer storing the Hash, rehash on load */
1.10 + /* if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; */
1.11
1.12 if (SDL_RWwrite(src,templ->path,
1.13 sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
1.14 @@ -158,7 +158,7 @@
1.15 return SDL_SetError("Unknown gestureId");
1.16 }
1.17
1.18 -/*path is an already sampled set of points
1.19 +/* path is an already sampled set of points
1.20 Returns the index of the gesture on success, or -1 */
1.21 static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
1.22 {
1.23 @@ -223,16 +223,16 @@
1.24 DOLLARNPOINTS) break;
1.25
1.26 if (touchId >= 0) {
1.27 - /*printf("Adding loaded gesture to 1 touch\n"); */
1.28 + /* printf("Adding loaded gesture to 1 touch\n"); */
1.29 if (SDL_AddDollarGesture(touch, templ.path) >= 0)
1.30 loaded++;
1.31 }
1.32 else {
1.33 - /*printf("Adding to: %i touches\n",SDL_numGestureTouches); */
1.34 + /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */
1.35 for (i = 0; i < SDL_numGestureTouches; i++) {
1.36 touch = &SDL_gestureTouch[i];
1.37 - /*printf("Adding loaded gesture to + touches\n"); */
1.38 - /*TODO: What if this fails? */
1.39 + /* printf("Adding loaded gesture to + touches\n"); */
1.40 + /* TODO: What if this fails? */
1.41 SDL_AddDollarGesture(touch,templ.path);
1.42 }
1.43 loaded++;
1.44 @@ -297,7 +297,7 @@
1.45 return SDL_min(f1,f2);
1.46 }
1.47
1.48 -/*DollarPath contains raw points, plus (possibly) the calculated length */
1.49 +/* DollarPath contains raw points, plus (possibly) the calculated length */
1.50 static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
1.51 {
1.52 int i;
1.53 @@ -310,7 +310,7 @@
1.54 float w,h;
1.55 float length = path->length;
1.56
1.57 - /*Calculate length if it hasn't already been done */
1.58 + /* Calculate length if it hasn't already been done */
1.59 if (length <= 0) {
1.60 for (i=1;i < path->numPoints; i++) {
1.61 float dx = path->p[i ].x - path->p[i-1].x;
1.62 @@ -319,17 +319,17 @@
1.63 }
1.64 }
1.65
1.66 - /*Resample */
1.67 + /* Resample */
1.68 interval = length/(DOLLARNPOINTS - 1);
1.69 dist = interval;
1.70
1.71 centroid.x = 0;centroid.y = 0;
1.72
1.73 - /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */
1.74 + /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */
1.75 for (i = 1; i < path->numPoints; i++) {
1.76 float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+
1.77 (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y)));
1.78 - /*printf("d = %f dist = %f/%f\n",d,dist,interval); */
1.79 + /* printf("d = %f dist = %f/%f\n",d,dist,interval); */
1.80 while (dist + d > interval) {
1.81 points[numPoints].x = path->p[i-1].x +
1.82 ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x);
1.83 @@ -347,15 +347,15 @@
1.84 SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
1.85 return 0;
1.86 }
1.87 - /*copy the last point */
1.88 + /* copy the last point */
1.89 points[DOLLARNPOINTS-1] = path->p[path->numPoints-1];
1.90 numPoints = DOLLARNPOINTS;
1.91
1.92 centroid.x /= numPoints;
1.93 centroid.y /= numPoints;
1.94
1.95 - /*printf("Centroid (%f,%f)",centroid.x,centroid.y); */
1.96 - /*Rotate Points so point 0 is left of centroid and solve for the bounding box */
1.97 + /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */
1.98 + /* Rotate Points so point 0 is left of centroid and solve for the bounding box */
1.99 xmin = centroid.x;
1.100 xmax = centroid.x;
1.101 ymin = centroid.y;
1.102 @@ -379,7 +379,7 @@
1.103 if (points[i].y > ymax) ymax = points[i].y;
1.104 }
1.105
1.106 - /*Scale points to DOLLARSIZE, and translate to the origin */
1.107 + /* Scale points to DOLLARSIZE, and translate to the origin */
1.108 w = xmax-xmin;
1.109 h = ymax-ymin;
1.110
1.111 @@ -400,7 +400,7 @@
1.112
1.113 dollarNormalize(path,points);
1.114
1.115 - /*PrintPath(points); */
1.116 + /* PrintPath(points); */
1.117 *bestTempl = -1;
1.118 for (i = 0; i < touch->numDollarTemplates; i++) {
1.119 float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
1.120 @@ -436,7 +436,7 @@
1.121 {
1.122 int i;
1.123 for (i = 0; i < SDL_numGestureTouches; i++) {
1.124 - /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */
1.125 + /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */
1.126 if (SDL_gestureTouch[i].id == id)
1.127 return &SDL_gestureTouch[i];
1.128 }
1.129 @@ -466,7 +466,7 @@
1.130 event.mgesture.y = touch->centroid.y;
1.131 event.dgesture.gestureId = gestureId;
1.132 event.dgesture.error = error;
1.133 - /*A finger came up to trigger this event. */
1.134 + /* A finger came up to trigger this event. */
1.135 event.dgesture.numFingers = touch->numDownFingers + 1;
1.136 return SDL_PushEvent(&event) > 0;
1.137 }
1.138 @@ -501,13 +501,13 @@
1.139 event->type == SDL_FINGERUP) {
1.140 SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
1.141
1.142 - /*Shouldn't be possible */
1.143 + /* Shouldn't be possible */
1.144 if (inTouch == NULL) return;
1.145
1.146 x = event->tfinger.x;
1.147 y = event->tfinger.y;
1.148
1.149 - /*Finger Up */
1.150 + /* Finger Up */
1.151 if (event->type == SDL_FINGERUP) {
1.152 inTouch->numDownFingers--;
1.153
1.154 @@ -515,7 +515,7 @@
1.155 if (inTouch->recording) {
1.156 inTouch->recording = SDL_FALSE;
1.157 dollarNormalize(&inTouch->dollarPath,path);
1.158 - /*PrintPath(path); */
1.159 + /* PrintPath(path); */
1.160 if (recordAll) {
1.161 index = SDL_AddDollarGesture(NULL,path);
1.162 for (i = 0; i < SDL_numGestureTouches; i++)
1.163 @@ -538,14 +538,14 @@
1.164 error = dollarRecognize(&inTouch->dollarPath,
1.165 &bestTempl,inTouch);
1.166 if (bestTempl >= 0){
1.167 - /*Send Event */
1.168 + /* Send Event */
1.169 unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
1.170 SDL_SendGestureDollar(inTouch,gestureId,error);
1.171 - /*printf ("%s\n",);("Dollar error: %f\n",error); */
1.172 + /* printf ("%s\n",);("Dollar error: %f\n",error); */
1.173 }
1.174 }
1.175 #endif
1.176 - /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */
1.177 + /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */
1.178 if (inTouch->numDownFingers > 0) {
1.179 inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
1.180 x)/inTouch->numDownFingers;
1.181 @@ -575,22 +575,22 @@
1.182
1.183 inTouch->centroid.x += dx/inTouch->numDownFingers;
1.184 inTouch->centroid.y += dy/inTouch->numDownFingers;
1.185 - /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */
1.186 + /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */
1.187 if (inTouch->numDownFingers > 1) {
1.188 - SDL_FloatPoint lv; /*Vector from centroid to last x,y position */
1.189 - SDL_FloatPoint v; /*Vector from centroid to current x,y position */
1.190 - /*lv = inTouch->gestureLast[j].cv; */
1.191 + SDL_FloatPoint lv; /* Vector from centroid to last x,y position */
1.192 + SDL_FloatPoint v; /* Vector from centroid to current x,y position */
1.193 + /* lv = inTouch->gestureLast[j].cv; */
1.194 lv.x = lastP.x - lastCentroid.x;
1.195 lv.y = lastP.y - lastCentroid.y;
1.196 lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
1.197 - /*printf("lDist = %f\n",lDist); */
1.198 + /* printf("lDist = %f\n",lDist); */
1.199 v.x = x - inTouch->centroid.x;
1.200 v.y = y - inTouch->centroid.y;
1.201 - /*inTouch->gestureLast[j].cv = v; */
1.202 + /* inTouch->gestureLast[j].cv = v; */
1.203 Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
1.204 /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */
1.205
1.206 - /*Normalize Vectors to simplify angle calculation */
1.207 + /* Normalize Vectors to simplify angle calculation */
1.208 lv.x/=lDist;
1.209 lv.y/=lDist;
1.210 v.x/=Dist;
1.211 @@ -598,9 +598,9 @@
1.212 dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
1.213
1.214 dDist = (Dist - lDist);
1.215 - if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values */
1.216 + if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */
1.217
1.218 - /*inTouch->gestureLast[j].dDist = dDist;
1.219 + /* inTouch->gestureLast[j].dDist = dDist;
1.220 inTouch->gestureLast[j].dtheta = dtheta;
1.221
1.222 printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
1.223 @@ -613,12 +613,12 @@
1.224 SDL_SendGestureMulti(inTouch,dtheta,dDist);
1.225 }
1.226 else {
1.227 - /*inTouch->gestureLast[j].dDist = 0;
1.228 + /* inTouch->gestureLast[j].dDist = 0;
1.229 inTouch->gestureLast[j].dtheta = 0;
1.230 inTouch->gestureLast[j].cv.x = 0;
1.231 inTouch->gestureLast[j].cv.y = 0; */
1.232 }
1.233 - /*inTouch->gestureLast[j].f.p.x = x;
1.234 + /* inTouch->gestureLast[j].f.p.x = x;
1.235 inTouch->gestureLast[j].f.p.y = y;
1.236 break;
1.237 pressure? */
1.238 @@ -631,7 +631,7 @@
1.239 x)/inTouch->numDownFingers;
1.240 inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
1.241 y)/inTouch->numDownFingers;
1.242 - /*printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
1.243 + /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
1.244 inTouch->centroid.x,inTouch->centroid.y); */
1.245
1.246 #ifdef ENABLE_DOLLAR