Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
585 lines (498 loc) · 16 KB

SDL_gesture.c

File metadata and controls

585 lines (498 loc) · 16 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
Jul 11, 2010
Jul 11, 2010
16
License along with this library; if not, write to the Free Software Founation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18
19
20
21
22
23
24
25
26
27
28
29
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General mouse handling code for SDL */
#include "SDL_events.h"
#include "SDL_events_c.h"
#include "SDL_gesture_c.h"
//TODO: Replace with malloc
Aug 2, 2010
Aug 2, 2010
30
#define MAXFINGERS 5
31
#define MAXTOUCHES 2
Jul 9, 2010
Jul 9, 2010
32
33
34
35
36
37
38
39
#define MAXTEMPLATES 4
#define MAXPATHSIZE 1024
#define DOLLARNPOINTS 64
#define DOLLARSIZE 256
//PHI = ((sqrt(5)-1)/2)
#define PHI 0.618033989
40
41
42
43
44
45
46
47
48
typedef struct {
float x,y;
} Point;
typedef struct {
Point p;
float pressure;
Jul 31, 2010
Jul 31, 2010
49
SDL_FingerID id;
Jul 9, 2010
Jul 9, 2010
52
53
54
55
56
57
58
59
60
typedef struct {
float length;
int numPoints;
Point p[MAXPATHSIZE];
} DollarPath;
61
62
63
64
typedef struct {
Finger f;
Point cv;
float dtheta,dDist;
Jul 9, 2010
Jul 9, 2010
65
DollarPath dollarPath;
66
67
} TouchPoint;
Jul 11, 2010
Jul 11, 2010
68
69
70
71
typedef struct {
Point path[DOLLARNPOINTS];
unsigned long hash;
} DollarTemplate;
72
73
typedef struct {
Jul 31, 2010
Jul 31, 2010
74
SDL_GestureID id;
75
76
77
78
Point res;
Point centroid;
TouchPoint gestureLast[MAXFINGERS];
int numDownFingers;
Jul 9, 2010
Jul 9, 2010
79
80
int numDollarTemplates;
Jul 11, 2010
Jul 11, 2010
81
82
83
DollarTemplate dollarTemplate[MAXTEMPLATES];
SDL_bool recording;
84
85
86
87
} GestureTouch;
GestureTouch gestureTouch[MAXTOUCHES];
int numGestureTouches = 0;
Jul 11, 2010
Jul 11, 2010
88
89
SDL_bool recordAll;
Jul 31, 2010
Jul 31, 2010
90
int SDL_RecordGesture(SDL_TouchID touchId) {
Jul 11, 2010
Jul 11, 2010
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
int i;
if(touchId < 0) recordAll = SDL_TRUE;
for(i = 0;i < numGestureTouches; i++) {
if((touchId < 0) || (gestureTouch[i].id == touchId)) {
gestureTouch[i].recording = SDL_TRUE;
if(touchId >= 0)
return 1;
}
}
return (touchId < 0);
}
unsigned long SDL_HashDollar(Point* points) {
unsigned long hash = 5381;
int i;
for(i = 0;i < DOLLARNPOINTS; i++) {
hash = ((hash<<5) + hash) + points[i].x;
hash = ((hash<<5) + hash) + points[i].y;
}
return hash;
}
Jul 17, 2010
Jul 17, 2010
113
114
static int SaveTemplate(DollarTemplate *templ, SDL_RWops * src) {
Jul 17, 2010
Jul 17, 2010
115
if(src == NULL) return 0;
Jul 17, 2010
Jul 17, 2010
116
Jul 11, 2010
Jul 11, 2010
117
int i;
Jul 17, 2010
Jul 17, 2010
118
119
120
121
122
123
//No Longer storing the Hash, rehash on load
//fprintf(fp,"%lu ",templ->hash);
//if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0;
/*
Jul 11, 2010
Jul 11, 2010
124
125
126
127
for(i = 0;i < DOLLARNPOINTS;i++) {
fprintf(fp,"%i %i ",(int)templ->path[i].x,(int)templ->path[i].y);
}
fprintf(fp,"\n");
Jul 17, 2010
Jul 17, 2010
128
Jul 17, 2010
Jul 17, 2010
129
130
131
*/
if(SDL_RWwrite(src,templ->path,sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) return 0;
return 1;
Jul 11, 2010
Jul 11, 2010
132
133
134
}
Jul 17, 2010
Jul 17, 2010
135
int SDL_SaveAllDollarTemplates(SDL_RWops *src) {
Jul 11, 2010
Jul 11, 2010
136
137
138
139
int i,j,rtrn = 0;
for(i = 0; i < numGestureTouches; i++) {
GestureTouch* touch = &gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
Jul 17, 2010
Jul 17, 2010
140
rtrn += SaveTemplate(&touch->dollarTemplate[i],src);
Jul 11, 2010
Jul 11, 2010
141
142
143
144
145
}
}
return rtrn;
}
Jul 31, 2010
Jul 31, 2010
146
int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) {
Jul 11, 2010
Jul 11, 2010
147
148
149
150
151
int i,j;
for(i = 0; i < numGestureTouches; i++) {
GestureTouch* touch = &gestureTouch[i];
for(j = 0;j < touch->numDollarTemplates; j++) {
if(touch->dollarTemplate[i].hash == gestureId) {
Jul 17, 2010
Jul 17, 2010
152
return SaveTemplate(&touch->dollarTemplate[i],src);
Jul 11, 2010
Jul 11, 2010
153
154
155
}
}
}
Jul 15, 2010
Jul 15, 2010
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
SDL_SetError("Unknown gestureId");
return -1;
}
//path is an already sampled set of points
//Returns the index of the gesture on success, or -1
static int SDL_AddDollarGesture(GestureTouch* inTouch,Point* path) {
if(inTouch == NULL) {
if(numGestureTouches == 0) return -1;
int i = 0;
for(i = 0;i < numGestureTouches; i++) {
inTouch = &gestureTouch[i];
if(inTouch->numDollarTemplates < MAXTEMPLATES) {
DollarTemplate *templ =
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
memcpy(templ->path,path,DOLLARNPOINTS*sizeof(Point));
templ->hash = SDL_HashDollar(templ->path);
inTouch->numDollarTemplates++;
}
}
return inTouch->numDollarTemplates - 1;
}else if(inTouch->numDollarTemplates < MAXTEMPLATES) {
DollarTemplate *templ =
&inTouch->dollarTemplate[inTouch->numDollarTemplates];
memcpy(templ->path,path,DOLLARNPOINTS*sizeof(Point));
templ->hash = SDL_HashDollar(templ->path);
inTouch->numDollarTemplates++;
return inTouch->numDollarTemplates - 1;
}
return -1;
Jul 11, 2010
Jul 11, 2010
186
187
}
Jul 31, 2010
Jul 31, 2010
188
int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) {
Jul 17, 2010
Jul 17, 2010
189
if(src == NULL) return 0;
Jul 11, 2010
Jul 11, 2010
190
191
192
193
194
195
196
197
198
int i,loaded = 0;
GestureTouch *touch = NULL;
if(touchId >= 0) {
for(i = 0;i < numGestureTouches; i++)
if(gestureTouch[i].id == touchId)
touch = &gestureTouch[i];
if(touch == NULL) return -1;
}
Jul 17, 2010
Jul 17, 2010
199
while(1) {
Jul 11, 2010
Jul 11, 2010
200
DollarTemplate templ;
Jul 17, 2010
Jul 17, 2010
201
202
//fscanf(fp,"%lu ",&templ.hash);
/*
Jul 11, 2010
Jul 11, 2010
203
204
205
206
207
208
209
for(i = 0;i < DOLLARNPOINTS; i++) {
int x,y;
if(fscanf(fp,"%i %i ",&x,&y) != 2) break;
templ.path[i].x = x;
templ.path[i].y = y;
}
fscanf(fp,"\n");
Jul 17, 2010
Jul 17, 2010
210
211
*/
if(SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) break;
Jul 11, 2010
Jul 11, 2010
212
213
if(touchId >= 0) {
Jul 17, 2010
Jul 17, 2010
214
215
printf("Adding loaded gesture to 1 touch\n");
if(SDL_AddDollarGesture(touch,templ.path)) loaded++;
Jul 11, 2010
Jul 11, 2010
216
217
}
else {
Jul 17, 2010
Jul 17, 2010
218
printf("Adding to: %i touches\n",numGestureTouches);
Jul 11, 2010
Jul 11, 2010
219
for(i = 0;i < numGestureTouches; i++) {
Jul 17, 2010
Jul 17, 2010
220
221
222
223
touch = &gestureTouch[i];
printf("Adding loaded gesture to + touches\n");
//TODO: What if this fails?
SDL_AddDollarGesture(touch,templ.path);
Jul 11, 2010
Jul 11, 2010
224
225
226
227
228
}
loaded++;
}
}
Jul 17, 2010
Jul 17, 2010
229
return loaded;
Jul 11, 2010
Jul 11, 2010
230
231
232
}
Jul 9, 2010
Jul 9, 2010
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
float dollarDifference(Point* points,Point* templ,float ang) {
// Point p[DOLLARNPOINTS];
float dist = 0;
Point p;
int i;
for(i = 0; i < DOLLARNPOINTS; i++) {
p.x = points[i].x * cos(ang) - points[i].y * sin(ang);
p.y = points[i].x * sin(ang) + points[i].y * cos(ang);
dist += sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+
(p.y-templ[i].y)*(p.y-templ[i].y));
}
return dist/DOLLARNPOINTS;
}
float bestDollarDifference(Point* points,Point* templ) {
//------------BEGIN DOLLAR BLACKBOX----------------//
//-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-//
//-"http://depts.washington.edu/aimgroup/proj/dollar/"-//
float ta = -M_PI/4;
float tb = M_PI/4;
float dt = M_PI/90;
float x1 = PHI*ta + (1-PHI)*tb;
float f1 = dollarDifference(points,templ,x1);
float x2 = (1-PHI)*ta + PHI*tb;
float f2 = dollarDifference(points,templ,x2);
while(abs(ta-tb) > dt) {
if(f1 < f2) {
tb = x2;
x2 = x1;
f2 = f1;
x1 = PHI*ta + (1-PHI)*tb;
f1 = dollarDifference(points,templ,x1);
}
else {
ta = x1;
x1 = x2;
f1 = f2;
x2 = (1-PHI)*ta + PHI*tb;
f2 = dollarDifference(points,templ,x2);
}
}
/*
if(f1 <= f2)
printf("Min angle (x1): %f\n",x1);
else if(f1 > f2)
printf("Min angle (x2): %f\n",x2);
*/
return SDL_min(f1,f2);
}
//DollarPath contains raw points, plus (possibly) the calculated length
int dollarNormalize(DollarPath path,Point *points) {
int i;
//Calculate length if it hasn't already been done
if(path.length <= 0) {
for(i=1;i<path.numPoints;i++) {
float dx = path.p[i ].x -
path.p[i-1].x;
float dy = path.p[i ].y -
path.p[i-1].y;
path.length += sqrt(dx*dx+dy*dy);
}
}
//Resample
float interval = path.length/(DOLLARNPOINTS - 1);
float dist = 0;
int numPoints = 0;
Point centroid; centroid.x = 0;centroid.y = 0;
//printf("(%f,%f)\n",path.p[path.numPoints-1].x,path.p[path.numPoints-1].y);
for(i = 1;i < path.numPoints;i++) {
float d = 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));
//printf("d = %f dist = %f/%f\n",d,dist,interval);
while(dist + d > interval) {
points[numPoints].x = path.p[i-1].x +
((interval-dist)/d)*(path.p[i].x-path.p[i-1].x);
points[numPoints].y = path.p[i-1].y +
((interval-dist)/d)*(path.p[i].y-path.p[i-1].y);
centroid.x += points[numPoints].x;
centroid.y += points[numPoints].y;
numPoints++;
dist -= interval;
}
dist += d;
}
if(numPoints < 1) return 0;
centroid.x /= numPoints;
centroid.y /= numPoints;
//printf("Centroid (%f,%f)",centroid.x,centroid.y);
//Rotate Points so point 0 is left of centroid and solve for the bounding box
float xmin,xmax,ymin,ymax;
xmin = centroid.x;
xmax = centroid.x;
ymin = centroid.y;
ymax = centroid.y;
float ang = atan2(centroid.y - points[0].y,
centroid.x - points[0].x);
for(i = 0;i<numPoints;i++) {
float px = points[i].x;
float py = points[i].y;
points[i].x = (px - centroid.x)*cos(ang) -
(py - centroid.y)*sin(ang) + centroid.x;
points[i].y = (px - centroid.x)*sin(ang) +
(py - centroid.y)*cos(ang) + centroid.y;
if(points[i].x < xmin) xmin = points[i].x;
if(points[i].x > xmax) xmax = points[i].x;
if(points[i].y < ymin) ymin = points[i].y;
if(points[i].y > ymax) ymax = points[i].y;
}
//Scale points to DOLLARSIZE, and translate to the origin
float w = xmax-xmin;
float h = ymax-ymin;
for(i=0;i<numPoints;i++) {
points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w;
points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h;
}
return numPoints;
}
Jul 15, 2010
Jul 15, 2010
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
float dollarRecognize(DollarPath path,int *bestTempl,GestureTouch* touch) {
Point points[DOLLARNPOINTS];
int numPoints = dollarNormalize(path,points);
int i;
int bestDiff = 10000;
*bestTempl = -1;
for(i = 0;i < touch->numDollarTemplates;i++) {
int diff = bestDollarDifference(points,touch->dollarTemplate[i].path);
if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;}
}
return bestDiff;
}
379
380
381
382
383
384
385
386
387
388
int SDL_GestureAddTouch(SDL_Touch* touch) {
if(numGestureTouches >= MAXTOUCHES) return -1;
gestureTouch[numGestureTouches].res.x = touch->xres;
gestureTouch[numGestureTouches].res.y = touch->yres;
gestureTouch[numGestureTouches].numDownFingers = 0;
gestureTouch[numGestureTouches].res.x = touch->xres;
gestureTouch[numGestureTouches].id = touch->id;
Jul 9, 2010
Jul 9, 2010
389
390
gestureTouch[numGestureTouches].numDollarTemplates = 0;
Jul 11, 2010
Jul 11, 2010
391
392
gestureTouch[numGestureTouches].recording = SDL_FALSE;
393
394
395
396
numGestureTouches++;
return 0;
}
Jul 31, 2010
Jul 31, 2010
397
GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) {
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
int i;
for(i = 0;i < numGestureTouches; i++) {
//printf("%i ?= %i\n",gestureTouch[i].id,id);
if(gestureTouch[i].id == id) return &gestureTouch[i];
}
return NULL;
}
int SDL_SendGestureMulti(GestureTouch* touch,float dTheta,float dDist) {
SDL_Event event;
event.mgesture.type = SDL_MULTIGESTURE;
event.mgesture.touchId = touch->id;
event.mgesture.x = touch->centroid.x;
event.mgesture.y = touch->centroid.y;
event.mgesture.dTheta = dTheta;
event.mgesture.dDist = dDist;
return SDL_PushEvent(&event) > 0;
}
Jul 31, 2010
Jul 31, 2010
417
418
int SDL_SendGestureDollar(GestureTouch* touch,
SDL_GestureID gestureId,float error) {
Jul 9, 2010
Jul 9, 2010
419
420
421
422
423
424
425
426
427
428
429
430
431
SDL_Event event;
event.dgesture.type = SDL_DOLLARGESTURE;
event.dgesture.touchId = touch->id;
/*
//TODO: Add this to give location of gesture?
event.mgesture.x = touch->centroid.x;
event.mgesture.y = touch->centroid.y;
*/
event.dgesture.gestureId = gestureId;
event.dgesture.error = error;
return SDL_PushEvent(&event) > 0;
}
Jul 11, 2010
Jul 11, 2010
432
Jul 31, 2010
Jul 31, 2010
433
int SDL_SendDollarRecord(GestureTouch* touch,SDL_GestureID gestureId) {
Jul 11, 2010
Jul 11, 2010
434
435
436
437
438
439
440
441
442
SDL_Event event;
event.dgesture.type = SDL_DOLLARRECORD;
event.dgesture.touchId = touch->id;
event.dgesture.gestureId = gestureId;
return SDL_PushEvent(&event) > 0;
}
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
void SDL_GestureProcessEvent(SDL_Event* event)
{
if(event->type == SDL_FINGERMOTION ||
event->type == SDL_FINGERDOWN ||
event->type == SDL_FINGERUP) {
GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
//Shouldn't be possible
if(inTouch == NULL) return;
float x = ((float)event->tfinger.x)/inTouch->res.x;
float y = ((float)event->tfinger.y)/inTouch->res.y;
int j,empty = -1;
for(j = 0;j<inTouch->numDownFingers;j++) {
if(inTouch->gestureLast[j].f.id != event->tfinger.fingerId) continue;
Jul 11, 2010
Jul 11, 2010
460
//Finger Up
461
462
if(event->type == SDL_FINGERUP) {
inTouch->numDownFingers--;
Jul 9, 2010
Jul 9, 2010
463
Jul 11, 2010
Jul 11, 2010
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
if(inTouch->recording) {
inTouch->recording = SDL_FALSE;
Point path[DOLLARNPOINTS];
dollarNormalize(inTouch->gestureLast[j].dollarPath,path);
int index;
if(recordAll) {
index = SDL_AddDollarGesture(NULL,path);
int i;
for(i = 0;i < numGestureTouches; i++)
gestureTouch[i].recording = SDL_FALSE;
}
else {
index = SDL_AddDollarGesture(inTouch,path);
}
if(index >= 0) {
SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash);
}
else {
SDL_SendDollarRecord(inTouch,-1);
}
Jul 9, 2010
Jul 9, 2010
485
}
Jul 11, 2010
Jul 11, 2010
486
487
488
489
490
491
492
else {
int bestTempl;
float error;
error = dollarRecognize(inTouch->gestureLast[j].dollarPath,
&bestTempl,inTouch);
if(bestTempl >= 0){
//Send Event
Jul 31, 2010
Jul 31, 2010
493
unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash;
Jul 11, 2010
Jul 11, 2010
494
495
496
497
SDL_SendGestureDollar(inTouch,gestureId,error);
printf("Dollar error: %f\n",error);
}
}
498
inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers];
Aug 2, 2010
Aug 2, 2010
499
j = -1;
500
501
502
503
504
break;
}
else {
float dx = x - inTouch->gestureLast[j].f.p.x;
float dy = y - inTouch->gestureLast[j].f.p.y;
Jul 9, 2010
Jul 9, 2010
505
506
507
508
509
510
511
512
513
DollarPath* path = &inTouch->gestureLast[j].dollarPath;
if(path->numPoints < MAXPATHSIZE) {
path->p[path->numPoints].x = x;
path->p[path->numPoints].y = y;
path->length += sqrt(dx*dx + dy*dy);
path->numPoints++;
}
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
inTouch->centroid.x += dx/inTouch->numDownFingers;
inTouch->centroid.y += dy/inTouch->numDownFingers;
if(inTouch->numDownFingers > 1) {
Point lv; //Vector from centroid to last x,y position
Point v; //Vector from centroid to current x,y position
lv = inTouch->gestureLast[j].cv;
float lDist = sqrt(lv.x*lv.x + lv.y*lv.y);
//printf("lDist = %f\n",lDist);
v.x = x - inTouch->centroid.x;
v.y = y - inTouch->centroid.y;
inTouch->gestureLast[j].cv = v;
float Dist = sqrt(v.x*v.x+v.y*v.y);
// cos(dTheta) = (v . lv)/(|v| * |lv|)
//Normalize Vectors to simplify angle calculation
lv.x/=lDist;
lv.y/=lDist;
v.x/=Dist;
v.y/=Dist;
float dtheta = atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y);
float dDist = (Dist - lDist);
if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values
inTouch->gestureLast[j].dDist = dDist;
inTouch->gestureLast[j].dtheta = dtheta;
//printf("dDist = %f, dTheta = %f\n",dDist,dtheta);
//gdtheta = gdtheta*.9 + dtheta*.1;
//gdDist = gdDist*.9 + dDist*.1
//knob.r += dDist/numDownFingers;
//knob.ang += dtheta;
//printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist);
//printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist);
SDL_SendGestureMulti(inTouch,dtheta,dDist);
}
else {
inTouch->gestureLast[j].dDist = 0;
inTouch->gestureLast[j].dtheta = 0;
inTouch->gestureLast[j].cv.x = 0;
inTouch->gestureLast[j].cv.y = 0;
}
inTouch->gestureLast[j].f.p.x = x;
inTouch->gestureLast[j].f.p.y = y;
break;
//pressure?
}
}
if(j == inTouch->numDownFingers) {
//printf("Finger Down!!!\n");
inTouch->numDownFingers++;
inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+
x)/inTouch->numDownFingers;
inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+
y)/inTouch->numDownFingers;
inTouch->gestureLast[j].f.id = event->tfinger.fingerId;
inTouch->gestureLast[j].f.p.x = x;
inTouch->gestureLast[j].f.p.y = y;
inTouch->gestureLast[j].cv.x = 0;
inTouch->gestureLast[j].cv.y = 0;
Jul 9, 2010
Jul 9, 2010
575
576
577
578
579
inTouch->gestureLast[j].dollarPath.length = 0;
inTouch->gestureLast[j].dollarPath.p[0].x = x;
inTouch->gestureLast[j].dollarPath.p[0].y = y;
inTouch->gestureLast[j].dollarPath.numPoints = 1;
580
581
582
583
584
585
}
}
}
/* vi: set ts=4 sw=4 expandtab: */