Fixes a few non C89 compliant comments

This commit is contained in:
Gabriel Jacobo 2013-08-20 19:49:24 -03:00
parent d8f66188d1
commit 63fe3a7753
3 changed files with 63 additions and 62 deletions

View File

@ -121,8 +121,8 @@ static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src)
if (src == NULL) return 0; if (src == NULL) return 0;
//No Longer storing the Hash, rehash on load /*No Longer storing the Hash, rehash on load*/
//if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; /*if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;*/
if (SDL_RWwrite(src,templ->path, if (SDL_RWwrite(src,templ->path,
sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS)
@ -158,8 +158,8 @@ int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src)
return SDL_SetError("Unknown gestureId"); return SDL_SetError("Unknown gestureId");
} }
//path is an already sampled set of points /*path is an already sampled set of points
//Returns the index of the gesture on success, or -1 Returns the index of the gesture on success, or -1*/
static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
{ {
SDL_DollarTemplate* dollarTemplate; SDL_DollarTemplate* dollarTemplate;
@ -196,7 +196,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path)
if (index < 0) if (index < 0)
return -1; return -1;
} }
// Use the index of the last one added. /* Use the index of the last one added.*/
return index; return index;
} else { } else {
return SDL_AddDollarGesture_one(inTouch, path); return SDL_AddDollarGesture_one(inTouch, path);
@ -223,16 +223,16 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
DOLLARNPOINTS) break; DOLLARNPOINTS) break;
if (touchId >= 0) { if (touchId >= 0) {
//printf("Adding loaded gesture to 1 touch\n"); /*printf("Adding loaded gesture to 1 touch\n");*/
if (SDL_AddDollarGesture(touch, templ.path) >= 0) if (SDL_AddDollarGesture(touch, templ.path) >= 0)
loaded++; loaded++;
} }
else { else {
//printf("Adding to: %i touches\n",SDL_numGestureTouches); /*printf("Adding to: %i touches\n",SDL_numGestureTouches);*/
for (i = 0; i < SDL_numGestureTouches; i++) { for (i = 0; i < SDL_numGestureTouches; i++) {
touch = &SDL_gestureTouch[i]; touch = &SDL_gestureTouch[i];
//printf("Adding loaded gesture to + touches\n"); /*printf("Adding loaded gesture to + touches\n");*/
//TODO: What if this fails? /*TODO: What if this fails?*/
SDL_AddDollarGesture(touch,templ.path); SDL_AddDollarGesture(touch,templ.path);
} }
loaded++; loaded++;
@ -245,7 +245,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang)
{ {
// SDL_FloatPoint p[DOLLARNPOINTS]; /* SDL_FloatPoint p[DOLLARNPOINTS];*/
float dist = 0; float dist = 0;
SDL_FloatPoint p; SDL_FloatPoint p;
int i; int i;
@ -261,9 +261,10 @@ static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float
static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
{ {
//------------BEGIN DOLLAR BLACKBOX----------------// /*------------BEGIN DOLLAR BLACKBOX------------------
//-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-
//-"http://depts.washington.edu/aimgroup/proj/dollar/"-// -"http://depts.washington.edu/aimgroup/proj/dollar/"
*/
double ta = -M_PI/4; double ta = -M_PI/4;
double tb = M_PI/4; double tb = M_PI/4;
double dt = M_PI/90; double dt = M_PI/90;
@ -296,7 +297,7 @@ static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ)
return SDL_min(f1,f2); return SDL_min(f1,f2);
} }
//DollarPath contains raw points, plus (possibly) the calculated length /*DollarPath contains raw points, plus (possibly) the calculated length*/
static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
{ {
int i; int i;
@ -309,7 +310,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
float w,h; float w,h;
float length = path->length; float length = path->length;
//Calculate length if it hasn't already been done /*Calculate length if it hasn't already been done*/
if (length <= 0) { if (length <= 0) {
for (i=1;i < path->numPoints; i++) { for (i=1;i < path->numPoints; i++) {
float dx = path->p[i ].x - path->p[i-1].x; float dx = path->p[i ].x - path->p[i-1].x;
@ -318,17 +319,17 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
} }
} }
//Resample /*Resample*/
interval = length/(DOLLARNPOINTS - 1); interval = length/(DOLLARNPOINTS - 1);
dist = interval; dist = interval;
centroid.x = 0;centroid.y = 0; centroid.x = 0;centroid.y = 0;
//printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); /*printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y);*/
for (i = 1; i < path->numPoints; i++) { for (i = 1; i < path->numPoints; i++) {
float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+
(path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y)));
//printf("d = %f dist = %f/%f\n",d,dist,interval); /*printf("d = %f dist = %f/%f\n",d,dist,interval);*/
while (dist + d > interval) { while (dist + d > interval) {
points[numPoints].x = path->p[i-1].x + points[numPoints].x = path->p[i-1].x +
((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x);
@ -346,15 +347,15 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
SDL_SetError("ERROR: NumPoints = %i\n",numPoints); SDL_SetError("ERROR: NumPoints = %i\n",numPoints);
return 0; return 0;
} }
//copy the last point /*copy the last point*/
points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; points[DOLLARNPOINTS-1] = path->p[path->numPoints-1];
numPoints = DOLLARNPOINTS; numPoints = DOLLARNPOINTS;
centroid.x /= numPoints; centroid.x /= numPoints;
centroid.y /= numPoints; centroid.y /= numPoints;
//printf("Centroid (%f,%f)",centroid.x,centroid.y); /*printf("Centroid (%f,%f)",centroid.x,centroid.y);*/
//Rotate Points so point 0 is left of centroid and solve for the bounding box /*Rotate Points so point 0 is left of centroid and solve for the bounding box*/
xmin = centroid.x; xmin = centroid.x;
xmax = centroid.x; xmax = centroid.x;
ymin = centroid.y; ymin = centroid.y;
@ -378,7 +379,7 @@ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points)
if (points[i].y > ymax) ymax = points[i].y; if (points[i].y > ymax) ymax = points[i].y;
} }
//Scale points to DOLLARSIZE, and translate to the origin /*Scale points to DOLLARSIZE, and translate to the origin*/
w = xmax-xmin; w = xmax-xmin;
h = ymax-ymin; h = ymax-ymin;
@ -399,7 +400,7 @@ static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_Gestu
dollarNormalize(path,points); dollarNormalize(path,points);
//PrintPath(points); /*PrintPath(points);*/
*bestTempl = -1; *bestTempl = -1;
for (i = 0; i < touch->numDollarTemplates; i++) { for (i = 0; i < touch->numDollarTemplates; i++) {
float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); float diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
@ -435,7 +436,7 @@ static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id)
{ {
int i; int i;
for (i = 0; i < SDL_numGestureTouches; i++) { for (i = 0; i < SDL_numGestureTouches; i++) {
//printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); /*printf("%i ?= %i\n",SDL_gestureTouch[i].id,id);*/
if (SDL_gestureTouch[i].id == id) if (SDL_gestureTouch[i].id == id)
return &SDL_gestureTouch[i]; return &SDL_gestureTouch[i];
} }
@ -465,7 +466,7 @@ static int SDL_SendGestureDollar(SDL_GestureTouch* touch,
event.mgesture.y = touch->centroid.y; event.mgesture.y = touch->centroid.y;
event.dgesture.gestureId = gestureId; event.dgesture.gestureId = gestureId;
event.dgesture.error = error; event.dgesture.error = error;
//A finger came up to trigger this event. /*A finger came up to trigger this event.*/
event.dgesture.numFingers = touch->numDownFingers + 1; event.dgesture.numFingers = touch->numDownFingers + 1;
return SDL_PushEvent(&event) > 0; return SDL_PushEvent(&event) > 0;
} }
@ -500,13 +501,13 @@ void SDL_GestureProcessEvent(SDL_Event* event)
event->type == SDL_FINGERUP) { event->type == SDL_FINGERUP) {
SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
//Shouldn't be possible /*Shouldn't be possible*/
if (inTouch == NULL) return; if (inTouch == NULL) return;
x = event->tfinger.x; x = event->tfinger.x;
y = event->tfinger.y; y = event->tfinger.y;
//Finger Up /*Finger Up*/
if (event->type == SDL_FINGERUP) { if (event->type == SDL_FINGERUP) {
inTouch->numDownFingers--; inTouch->numDownFingers--;
@ -514,7 +515,7 @@ void SDL_GestureProcessEvent(SDL_Event* event)
if (inTouch->recording) { if (inTouch->recording) {
inTouch->recording = SDL_FALSE; inTouch->recording = SDL_FALSE;
dollarNormalize(&inTouch->dollarPath,path); dollarNormalize(&inTouch->dollarPath,path);
//PrintPath(path); /*PrintPath(path);*/
if (recordAll) { if (recordAll) {
index = SDL_AddDollarGesture(NULL,path); index = SDL_AddDollarGesture(NULL,path);
for (i = 0; i < SDL_numGestureTouches; i++) for (i = 0; i < SDL_numGestureTouches; i++)
@ -537,14 +538,14 @@ void SDL_GestureProcessEvent(SDL_Event* event)
error = dollarRecognize(&inTouch->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
//inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; /*inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];*/
if (inTouch->numDownFingers > 0) { if (inTouch->numDownFingers > 0) {
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)-
x)/inTouch->numDownFingers; x)/inTouch->numDownFingers;
@ -574,22 +575,22 @@ void SDL_GestureProcessEvent(SDL_Event* event)
inTouch->centroid.x += dx/inTouch->numDownFingers; 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); /*printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y);*/
if (inTouch->numDownFingers > 1) { if (inTouch->numDownFingers > 1) {
SDL_FloatPoint lv; //Vector from centroid to last x,y position SDL_FloatPoint lv; /*Vector from centroid to last x,y position*/
SDL_FloatPoint v; //Vector from centroid to current x,y position SDL_FloatPoint v; /*Vector from centroid to current x,y position*/
//lv = inTouch->gestureLast[j].cv; /*lv = inTouch->gestureLast[j].cv;*/
lv.x = lastP.x - lastCentroid.x; lv.x = lastP.x - lastCentroid.x;
lv.y = lastP.y - lastCentroid.y; lv.y = lastP.y - lastCentroid.y;
lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y);
//printf("lDist = %f\n",lDist); /*printf("lDist = %f\n",lDist);*/
v.x = x - inTouch->centroid.x; v.x = x - inTouch->centroid.x;
v.y = y - inTouch->centroid.y; v.y = y - inTouch->centroid.y;
//inTouch->gestureLast[j].cv = v; /*inTouch->gestureLast[j].cv = v;*/
Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y);
// SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|)*/
//Normalize Vectors to simplify angle calculation /*Normalize Vectors to simplify angle calculation*/
lv.x/=lDist; lv.x/=lDist;
lv.y/=lDist; lv.y/=lDist;
v.x/=Dist; v.x/=Dist;
@ -597,30 +598,30 @@ void SDL_GestureProcessEvent(SDL_Event* event)
dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
dDist = (Dist - lDist); dDist = (Dist - lDist);
if (lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values if (lDist == 0) {dDist = 0;dtheta = 0;} /*To avoid impossible values*/
//inTouch->gestureLast[j].dDist = dDist; /*inTouch->gestureLast[j].dDist = dDist;
//inTouch->gestureLast[j].dtheta = dtheta; inTouch->gestureLast[j].dtheta = dtheta;
//printf("dDist = %f, dTheta = %f\n",dDist,dtheta); printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
//gdtheta = gdtheta*.9 + dtheta*.1; gdtheta = gdtheta*.9 + dtheta*.1;
//gdDist = gdDist*.9 + dDist*.1 gdDist = gdDist*.9 + dDist*.1
//knob.r += dDist/numDownFingers; knob.r += dDist/numDownFingers;
//knob.ang += dtheta; knob.ang += dtheta;
//printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
//printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);*/
SDL_SendGestureMulti(inTouch,dtheta,dDist); SDL_SendGestureMulti(inTouch,dtheta,dDist);
} }
else { else {
//inTouch->gestureLast[j].dDist = 0; /*inTouch->gestureLast[j].dDist = 0;
//inTouch->gestureLast[j].dtheta = 0; inTouch->gestureLast[j].dtheta = 0;
//inTouch->gestureLast[j].cv.x = 0; inTouch->gestureLast[j].cv.x = 0;
//inTouch->gestureLast[j].cv.y = 0; inTouch->gestureLast[j].cv.y = 0;*/
} }
//inTouch->gestureLast[j].f.p.x = x; /*inTouch->gestureLast[j].f.p.x = x;
//inTouch->gestureLast[j].f.p.y = y; inTouch->gestureLast[j].f.p.y = y;
//break; break;
//pressure? pressure?*/
} }
if (event->type == SDL_FINGERDOWN) { if (event->type == SDL_FINGERDOWN) {
@ -630,8 +631,8 @@ void SDL_GestureProcessEvent(SDL_Event* event)
x)/inTouch->numDownFingers; x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
y)/inTouch->numDownFingers; y)/inTouch->numDownFingers;
//printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, /*printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y,
// inTouch->centroid.x,inTouch->centroid.y); inTouch->centroid.x,inTouch->centroid.y);*/
#ifdef ENABLE_DOLLAR #ifdef ENABLE_DOLLAR
inTouch->dollarPath.length = 0; inTouch->dollarPath.length = 0;

View File

@ -488,14 +488,14 @@ SDL_PrivateJoystickShouldIgnoreEvent()
if (SDL_WasInit(SDL_INIT_VIDEO)) { if (SDL_WasInit(SDL_INIT_VIDEO)) {
if (SDL_GetKeyboardFocus() == NULL) { if (SDL_GetKeyboardFocus() == NULL) {
// Video is initialized and we don't have focus, ignore the event. /* Video is initialized and we don't have focus, ignore the event.*/
return SDL_TRUE; return SDL_TRUE;
} else { } else {
return SDL_FALSE; return SDL_FALSE;
} }
} }
// Video subsystem wasn't initialized, always allow the event /* Video subsystem wasn't initialized, always allow the event*/
return SDL_FALSE; return SDL_FALSE;
} }

View File

@ -1761,7 +1761,7 @@ SDL_MaximizeWindow(SDL_Window * window)
return; return;
} }
// !!! FIXME: should this check if the window is resizable? /* !!! FIXME: should this check if the window is resizable? */
if (_this->MaximizeWindow) { if (_this->MaximizeWindow) {
_this->MaximizeWindow(_this, window); _this->MaximizeWindow(_this, window);