comparison touchTest/gestureSDLTest.c @ 4657:eed063a0bf5b

Moved Multi finger gesture recognition into the library.
author Jim Grandpre <jim.tla@gmail.com>
date Wed, 07 Jul 2010 04:13:08 -0700
parents
children 063b9455bd1a
comparison
equal deleted inserted replaced
4656:b5007b7995c6 4657:eed063a0bf5b
1 #include <stdio.h>
2 #include <SDL.h>
3 #include <math.h>
4 #include <SDL_touch.h>
5
6 #define PI 3.1415926535897
7 #define PHI ((sqrt(5)-1)/2)
8 #define WIDTH 640
9 #define HEIGHT 480
10 #define BPP 4
11 #define DEPTH 32
12
13 #define MAXFINGERS 3
14
15 #define DOLLARNPOINTS 64
16 #define DOLLARSIZE 256
17
18 //MUST BE A POWER OF 2!
19 #define EVENT_BUF_SIZE 256
20
21 SDL_Event events[EVENT_BUF_SIZE];
22 int eventWrite;
23
24 int mousx,mousy;
25 int keystat[512];
26 int bstatus;
27
28 int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF};
29
30 int index2fingerid[MAXFINGERS];
31 int fingersDown;
32
33 typedef struct {
34 float x,y;
35 } Point;
36
37 typedef struct {
38 Point p;
39 float pressure;
40 int id;
41 } Finger;
42
43 typedef struct {
44 Finger f;
45 Point cv;
46 float dtheta,dDist;
47 } TouchPoint;
48
49
50 typedef struct { //dt + s
51 Point d,s; //direction, start
52 int points;
53 } Line;
54
55
56 typedef struct {
57 float length;
58
59 int numPoints;
60 Point p[EVENT_BUF_SIZE]; //To be safe
61 } DollarPath;
62
63 typedef struct {
64 float ang,r;
65 Point p;
66 } Knob;
67
68 Knob knob;
69
70 Finger finger[MAXFINGERS];
71
72
73 DollarPath dollarPath[MAXFINGERS];
74
75 #define MAXTEMPLATES 4
76
77 Point dollarTemplate[MAXTEMPLATES][DOLLARNPOINTS];
78 int numDollarTemplates = 0;
79 #ifdef DRAW_VECTOR_EST
80 Line gestureLine[MAXFINGERS];
81 #endif
82
83 void handler (int sig)
84 {
85 printf ("\exiting...(%d)\n", sig);
86 exit (0);
87 }
88
89 void perror_exit (char *error)
90 {
91 perror (error);
92 handler (9);
93 }
94
95
96 void setpix(SDL_Surface *screen, int x, int y, unsigned int col)
97 {
98 Uint32 *pixmem32;
99 Uint32 colour;
100
101 if((unsigned)x > screen->w) return;
102 if((unsigned)y > screen->h) return;
103
104 pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
105
106 Uint8 r,g,b;
107 float a;
108
109 memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
110
111 SDL_GetRGB(colour,screen->format,&r,&g,&b); //Always returns 0xFFFFFF?
112 //r = 0;g = 0; b = 0;
113 a = (col>>24)&0xFF;
114 if(a == 0) a = 0xFF; //Hack, to make things easier.
115 a /= 0xFF;
116 r = r*(1-a) + ((col>>16)&0xFF)*(a);
117 g = g*(1-a) + ((col>> 8)&0xFF)*(a);
118 b = b*(1-a) + ((col>> 0)&0xFF)*(a);
119 colour = SDL_MapRGB( screen->format,r, g, b);
120
121
122 *pixmem32 = colour;
123 }
124
125 void drawLine(SDL_Surface *screen,int x0,int y0,int x1,int y1,unsigned int col) {
126 float t;
127 for(t=0;t<1;t+=1.f/SDL_max(abs(x0-x1),abs(y0-y1)))
128 setpix(screen,x1+t*(x0-x1),y1+t*(y0-y1),col);
129 }
130 void drawCircle(SDL_Surface* screen,int x,int y,int r,unsigned int c)
131 {
132
133 float a;
134 int tx;
135
136 int ty;
137 float xr;
138 for(ty = -abs(r);ty <= abs(r);ty++) {
139 xr = sqrt(r*r - ty*ty);
140 if(r > 0) { //r > 0 ==> filled circle
141 for(tx=-xr+.5;tx<=xr-.5;tx++) {
142 setpix(screen,x+tx,y+ty,c);
143 }
144 }
145 else {
146 setpix(screen,x-xr+.5,y+ty,c);
147 setpix(screen,x+xr-.5,y+ty,c);
148 }
149 }
150 }
151
152 void drawKnob(SDL_Surface* screen,Knob k) {
153 //printf("Knob: x = %f, y = %f, r = %f, a = %f\n",k.p.x,k.p.y,k.r,k.ang);
154
155 drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF);
156
157 drawCircle(screen,(k.p.x+k.r/2*cos(k.ang))*screen->w,
158 (k.p.y+k.r/2*sin(k.ang))*screen->h,k.r/4*screen->w,0);
159
160 }
161
162 void drawDollarPath(SDL_Surface* screen,Point* points,int numPoints,
163 int rad,unsigned int col){
164 int i;
165 for(i=0;i<numPoints;i++) {
166 drawCircle(screen,points[i].x+screen->w/2,
167 points[i].y+screen->h/2,
168 rad,col);
169 }
170 }
171
172 float dollarDifference(Point* points,Point* templ,float ang) {
173 // Point p[DOLLARNPOINTS];
174 float dist = 0;
175 Point p;
176 int i;
177 for(i = 0; i < DOLLARNPOINTS; i++) {
178 p.x = points[i].x * cos(ang) - points[i].y * sin(ang);
179 p.y = points[i].x * sin(ang) + points[i].y * cos(ang);
180 dist += sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
181 (p.y-templ[i].y)*(p.y-templ[i].y));
182 }
183 return dist/DOLLARNPOINTS;
184
185 }
186
187 float bestDollarDifference(Point* points,Point* templ) {
188 //------------BEGIN DOLLAR BLACKBOX----------------//
189 //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-//
190 //-"http://depts.washington.edu/aimgroup/proj/dollar/"-//
191 float ta = -PI/4;
192 float tb = PI/4;
193 float dt = PI/90;
194 float x1 = PHI*ta + (1-PHI)*tb;
195 float f1 = dollarDifference(points,templ,x1);
196 float x2 = (1-PHI)*ta + PHI*tb;
197 float f2 = dollarDifference(points,templ,x2);
198 while(abs(ta-tb) > dt) {
199 if(f1 < f2) {
200 tb = x2;
201 x2 = x1;
202 f2 = f1;
203 x1 = PHI*ta + (1-PHI)*tb;
204 f1 = dollarDifference(points,templ,x1);
205 }
206 else {
207 ta = x1;
208 x1 = x2;
209 f1 = f2;
210 x2 = (1-PHI)*ta + PHI*tb;
211 f2 = dollarDifference(points,templ,x2);
212 }
213 }
214 /*
215 if(f1 <= f2)
216 printf("Min angle (x1): %f\n",x1);
217 else if(f1 > f2)
218 printf("Min angle (x2): %f\n",x2);
219 */
220 return SDL_min(f1,f2);
221 }
222
223 float dollarRecognize(SDL_Surface* screen, DollarPath path,int *bestTempl) {
224
225 Point points[DOLLARNPOINTS];
226 int numPoints = dollarNormalize(path,points);
227 int i;
228
229 int k;
230 /*
231 for(k = 0;k<DOLLARNPOINTS;k++) {
232 printf("(%f,%f)\n",points[k].x,
233 points[k].y);
234 }
235 */
236 drawDollarPath(screen,points,numPoints,-15,0xFF6600);
237
238 int bestDiff = 10000;
239 *bestTempl = -1;
240 for(i = 0;i < numDollarTemplates;i++) {
241 int diff = bestDollarDifference(points,dollarTemplate[i]);
242 if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
243 }
244 return bestDiff;
245 }
246
247 //DollarPath contains raw points, plus (possibly) the calculated length
248 int dollarNormalize(DollarPath path,Point *points) {
249 int i;
250 //Calculate length if it hasn't already been done
251 if(path.length <= 0) {
252 for(i=1;i<path.numPoints;i++) {
253 float dx = path.p[i ].x -
254 path.p[i-1].x;
255 float dy = path.p[i ].y -
256 path.p[i-1].y;
257 path.length += sqrt(dx*dx+dy*dy);
258 }
259 }
260
261
262 //Resample
263 float interval = path.length/(DOLLARNPOINTS - 1);
264 float dist = 0;
265
266 int numPoints = 0;
267 Point centroid; centroid.x = 0;centroid.y = 0;
268 //printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
269 for(i = 1;i < path.numPoints;i++) {
270 float d = sqrt((path.p[i-1].x-path.p[i].x)*(path.p[i-1].x-path.p[i].x)+
271 (path.p[i-1].y-path.p[i].y)*(path.p[i-1].y-path.p[i].y));
272 //printf("d = %f dist = %f/%f\n",d,dist,interval);
273 while(dist + d > interval) {
274 points[numPoints].x = path.p[i-1].x +
275 ((interval-dist)/d)*(path.p[i].x-path.p[i-1].x);
276 points[numPoints].y = path.p[i-1].y +
277 ((interval-dist)/d)*(path.p[i].y-path.p[i-1].y);
278 centroid.x += points[numPoints].x;
279 centroid.y += points[numPoints].y;
280 numPoints++;
281
282 dist -= interval;
283 }
284 dist += d;
285 }
286 if(numPoints < 1) return 0;
287 centroid.x /= numPoints;
288 centroid.y /= numPoints;
289
290 //printf("Centroid (%f,%f)",centroid.x,centroid.y);
291 //Rotate Points so point 0 is left of centroid and solve for the bounding box
292 float xmin,xmax,ymin,ymax;
293 xmin = centroid.x;
294 xmax = centroid.x;
295 ymin = centroid.y;
296 ymax = centroid.y;
297
298 float ang = atan2(centroid.y - points[0].y,
299 centroid.x - points[0].x);
300
301 for(i = 0;i<numPoints;i++) {
302 float px = points[i].x;
303 float py = points[i].y;
304 points[i].x = (px - centroid.x)*cos(ang) -
305 (py - centroid.y)*sin(ang) + centroid.x;
306 points[i].y = (px - centroid.x)*sin(ang) +
307 (py - centroid.y)*cos(ang) + centroid.y;
308
309
310 if(points[i].x < xmin) xmin = points[i].x;
311 if(points[i].x > xmax) xmax = points[i].x;
312 if(points[i].y < ymin) ymin = points[i].y;
313 if(points[i].y > ymax) ymax = points[i].y;
314 }
315
316 //Scale points to DOLLARSIZE, and translate to the origin
317 float w = xmax-xmin;
318 float h = ymax-ymin;
319
320 for(i=0;i<numPoints;i++) {
321 points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
322 points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
323 }
324 return numPoints;
325 }
326
327 void DrawScreen(SDL_Surface* screen, int h)
328 {
329 int x, y, xm,ym,c;
330 if(SDL_MUSTLOCK(screen))
331 {
332 if(SDL_LockSurface(screen) < 0) return;
333 }
334 for(y = 0; y < screen->h; y++ )
335 {
336 for( x = 0; x < screen->w; x++ )
337 {
338 //setpixel(screen, x, y, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
339 //xm = (x+h)%screen->w;
340 //ym = (y+h)%screen->w;
341 //c = sin(h/256*2*PI)*x*y/screen->w/screen->h;
342 //setpix(screen,x,y,255*sin(xm/screen->w*2*PI),sin(h/255*2*PI)*255*y/screen->h,c);
343 setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
344 //setpix(screen,x,y,0); //Inefficient, but that's okay...
345 }
346 }
347 drawCircle(screen,mousx,mousy,-30,0xFFFFFF);
348 drawLine(screen,0,0,screen->w,screen->h,0xFFFFFF);
349
350 int i;
351 //draw Touch History
352 TouchPoint gestureLast[MAXFINGERS];
353 //printf("------------------Start History------------------\n");
354 for(i = 0;i < MAXFINGERS;i++) {
355 gestureLast[i].f.id = -1;
356 }
357 int numDownFingers = 0;
358 Point centroid;
359 float gdtheta,gdDist;
360
361
362 for(i = SDL_max(0,eventWrite - EVENT_BUF_SIZE);i < eventWrite;i++) {
363 SDL_Event event = events[i&(EVENT_BUF_SIZE-1)];
364 int age = eventWrite - i - 1;
365 if(event.type == SDL_FINGERMOTION ||
366 event.type == SDL_FINGERDOWN ||
367 event.type == SDL_FINGERUP) {
368 SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
369 //SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId);
370
371 float x = ((float)event.tfinger.x)/inTouch->xres;
372 float y = ((float)event.tfinger.y)/inTouch->yres;
373 int j,empty = -1;
374
375 for(j = 0;j<MAXFINGERS;j++) {
376 if(gestureLast[j].f.id == event.tfinger.fingerId) {
377 if(event.type == SDL_FINGERUP) {
378 numDownFingers--;
379 if(numDownFingers <= 1) {
380 gdtheta = 0;
381 gdDist = 0;
382 }
383 if(!keystat[32]){ //spacebar
384 int bestTempl;
385 float error = dollarRecognize(screen,dollarPath[j],&bestTempl);
386 if(bestTempl >= 0){
387 drawDollarPath(screen,dollarTemplate[bestTempl]
388 ,DOLLARNPOINTS,-15,0x0066FF);
389 printf("Dollar error: %f\n",error);
390 }
391
392 }
393 else if(numDollarTemplates < MAXTEMPLATES) {
394
395 dollarNormalize(dollarPath[j],
396 dollarTemplate[numDollarTemplates]);
397 /*
398 int k;
399 for(k = 0;k<DOLLARNPOINTS;k++) {
400 printf("(%f,%f)\n",dollarTemplate[numDollarTemplates][i].x,
401 dollarTemplate[numDollarTemplates][i].y);
402 }*/
403 numDollarTemplates++;
404 }
405
406 gestureLast[j].f.id = -1;
407 break;
408 }
409 else {
410 dollarPath[j].p[dollarPath[j].numPoints].x = x;
411 dollarPath[j].p[dollarPath[j].numPoints].y = y;
412 float dx = (dollarPath[j].p[dollarPath[j].numPoints ].x-
413 dollarPath[j].p[dollarPath[j].numPoints-1].x);
414 float dy = (dollarPath[j].p[dollarPath[j].numPoints ].y-
415 dollarPath[j].p[dollarPath[j].numPoints-1].y);
416 dollarPath[j].length += sqrt(dx*dx + dy*dy);
417
418 dollarPath[j].numPoints++;
419
420 centroid.x = centroid.x + dx/numDownFingers;
421 centroid.y = centroid.y + dy/numDownFingers;
422 if(numDownFingers > 1) {
423 Point lv; //Vector from centroid to last x,y position
424 Point v; //Vector from centroid to current x,y position
425 lv.x = gestureLast[j].cv.x;
426 lv.y = gestureLast[j].cv.y;
427 float lDist = sqrt(lv.x*lv.x + lv.y*lv.y);
428
429 v.x = x - centroid.x;
430 v.y = y - centroid.y;
431 gestureLast[j].cv = v;
432 float Dist = sqrt(v.x*v.x+v.y*v.y);
433 // cos(dTheta) = (v . lv)/(|v| * |lv|)
434
435 lv.x/=lDist;
436 lv.y/=lDist;
437 v.x/=Dist;
438 v.y/=Dist;
439 float dtheta = atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
440
441 float dDist = (lDist - Dist);
442
443 gestureLast[j].dDist = dDist;
444 gestureLast[j].dtheta = dtheta;
445
446 //gdtheta = gdtheta*.9 + dtheta*.1;
447 //gdDist = gdDist*.9 + dDist*.1
448 gdtheta += dtheta;
449 gdDist += dDist;
450
451 //printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
452 //printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);
453 }
454 else {
455 gestureLast[j].dDist = 0;
456 gestureLast[j].dtheta = 0;
457 gestureLast[j].cv.x = 0;
458 gestureLast[j].cv.y = 0;
459 }
460 gestureLast[j].f.p.x = x;
461 gestureLast[j].f.p.y = y;
462 break;
463 //pressure?
464 }
465 }
466 else if(gestureLast[j].f.id == -1 && empty == -1) {
467 empty = j;
468 }
469 }
470
471 if(j >= MAXFINGERS && empty >= 0) {
472 // printf("Finger Down!!!\n");
473 numDownFingers++;
474 centroid.x = (centroid.x*(numDownFingers - 1) + x)/numDownFingers;
475 centroid.y = (centroid.y*(numDownFingers - 1) + y)/numDownFingers;
476
477 j = empty;
478 gestureLast[j].f.id = event.tfinger.fingerId;
479 gestureLast[j].f.p.x = x;
480 gestureLast[j].f.p.y = y;
481
482
483 dollarPath[j].length = 0;
484 dollarPath[j].p[0].x = x;
485 dollarPath[j].p[0].y = y;
486 dollarPath[j].numPoints = 1;
487 }
488
489 //draw the touch:
490
491 if(gestureLast[j].f.id < 0) continue; //Finger up. Or some error...
492
493 unsigned int c = colors[gestureLast[j].f.id%7];
494 unsigned int col =
495 ((unsigned int)(c*(.1+.85))) |
496 ((unsigned int)((0xFF*(1-((float)age)/EVENT_BUF_SIZE))) & 0xFF)<<24;
497 x = gestureLast[j].f.p.x;
498 y = gestureLast[j].f.p.y;
499 if(event.type == SDL_FINGERMOTION)
500 drawCircle(screen,x*screen->w,y*screen->h,5,col);
501 else if(event.type == SDL_FINGERDOWN)
502 drawCircle(screen,x*screen->w,y*screen->h,-10,col);
503
504 //if there is a centroid, draw it
505 if(numDownFingers > 1) {
506 unsigned int col =
507 ((unsigned int)(0xFFFFFF)) |
508 ((unsigned int)((0xFF*(1-((float)age)/EVENT_BUF_SIZE))) & 0xFF)<<24;
509 drawCircle(screen,centroid.x*screen->w,centroid.y*screen->h,5,col);
510 }
511 }
512 }
513
514
515 for(i=0;i<MAXFINGERS;i++)
516 if(finger[i].p.x >= 0 && finger[i].p.y >= 0)
517 if(finger[i].pressure > 0)
518 drawCircle(screen,finger[i].p.x*screen->w,finger[i].p.y*screen->h
519 ,20,0xFF*finger[i].pressure);
520 else
521 drawCircle(screen,finger[i].p.x*screen->w,finger[i].p.y*screen->h
522 ,20,0xFF);
523
524
525
526 keystat[32] = 0;
527
528 if(knob.p.x > 0)
529 drawKnob(screen,knob);
530
531 if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
532
533 SDL_Flip(screen);
534 }
535
536 SDL_Surface* initScreen(int width,int height)
537 {
538 return SDL_SetVideoMode(width, height, DEPTH,
539 SDL_HWSURFACE | SDL_RESIZABLE);
540 }
541
542 int main(int argc, char* argv[])
543 {
544 SDL_Surface *screen;
545 SDL_Event event;
546
547 int keypress = 0;
548 int h=0,s=1,i,j;
549
550 //gesture variables
551 int numDownFingers = 0;
552 float gdtheta = 0,gdDist = 0;
553 Point centroid;
554 knob.r = .1;
555 knob.ang = 0;
556 TouchPoint gestureLast[MAXFINGERS];
557
558
559
560 memset(keystat,0,512*sizeof(keystat[0]));
561 if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
562
563 if (!(screen = initScreen(WIDTH,HEIGHT)))
564 {
565 SDL_Quit();
566 return 1;
567 }
568
569 while(!keystat[27]) {
570 //Poll SDL
571 while(SDL_PollEvent(&event))
572 {
573 //Record _all_ events
574 events[eventWrite & (EVENT_BUF_SIZE-1)] = event;
575 eventWrite++;
576
577 switch (event.type)
578 {
579 case SDL_QUIT:
580 keystat[27] = 1;
581 break;
582 case SDL_KEYDOWN:
583 //printf("%i\n",event.key.keysym.sym);
584 keystat[event.key.keysym.sym] = 1;
585 //keypress = 1;
586 break;
587 case SDL_KEYUP:
588 //printf("%i\n",event.key.keysym.sym);
589 keystat[event.key.keysym.sym] = 0;
590 //keypress = 1;
591 break;
592 case SDL_VIDEORESIZE:
593 if (!(screen = initScreen(event.resize.w,
594 event.resize.h)))
595 {
596 SDL_Quit();
597 return 1;
598 }
599 break;
600 case SDL_MOUSEMOTION:
601 mousx = event.motion.x;
602 mousy = event.motion.y;
603 break;
604 case SDL_MOUSEBUTTONDOWN:
605 bstatus |= (1<<(event.button.button-1));
606 break;
607 case SDL_MOUSEBUTTONUP:
608 bstatus &= ~(1<<(event.button.button-1));
609 break;
610 case SDL_FINGERMOTION:
611 ;
612 //printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId,
613 // event.tfinger.x,event.tfinger.y);
614 SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
615 SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId);
616
617 for(i = 0;i<MAXFINGERS;i++)
618 if(index2fingerid[i] == event.tfinger.fingerId)
619 break;
620 if(i == MAXFINGERS) break;
621 if(inTouch > 0) {
622 finger[i].p.x = ((float)event.tfinger.x)/
623 inTouch->xres;
624 finger[i].p.y = ((float)event.tfinger.y)/
625 inTouch->yres;
626
627 finger[i].pressure =
628 ((float)event.tfinger.pressure)/inTouch->pressureres;
629 /*
630 printf("Finger: %i, Pressure: %f Pressureres: %i\n",
631 event.tfinger.fingerId,
632 finger[i].pressure,
633 inTouch->pressureres);
634 */
635 //printf("Finger: %i, pressure: %f\n",event.tfinger.fingerId,
636 // finger[event.tfinger.fingerId].pressure);
637 }
638
639 break;
640 case SDL_FINGERDOWN:
641 printf("Finger: %i down - x: %i, y: %i\n",event.tfinger.fingerId,
642 event.tfinger.x,event.tfinger.y);
643
644 for(i = 0;i<MAXFINGERS;i++)
645 if(index2fingerid[i] == -1) {
646 index2fingerid[i] = event.tfinger.fingerId;
647 break;
648 }
649 finger[i].p.x = event.tfinger.x;
650 finger[i].p.y = event.tfinger.y;
651 break;
652 case SDL_FINGERUP:
653 printf("Figner: %i up - x: %i, y: %i\n",event.tfinger.fingerId,
654 event.tfinger.x,event.tfinger.y);
655 for(i = 0;i<MAXFINGERS;i++)
656 if(index2fingerid[i] == event.tfinger.fingerId) {
657 index2fingerid[i] = -1;
658 break;
659 }
660 finger[i].p.x = -1;
661 finger[i].p.y = -1;
662 break;
663 case SDL_MULTIGESTURE:
664 knob.p.x = event.mgesture.x;
665 knob.p.y = event.mgesture.y;
666 knob.ang += event.mgesture.dTheta;
667 knob.r += event.mgesture.dDist;
668 }
669
670
671
672 //And draw
673
674 }
675 DrawScreen(screen,h);
676 //printf("c: (%f,%f)\n",centroid.x,centroid.y);
677 //printf("numDownFingers: %i\n",numDownFingers);
678 //for(i=0;i<512;i++)
679 // if(keystat[i]) printf("%i\n",i);
680
681
682 }
683 SDL_Quit();
684
685 return 0;
686 }
687