comparison src/events/SDL_touch.c @ 4654:7dbcd71216df

Added $1 gesture recognition. Functional.
author Jim Grandpre <jim.tla@gmail.com>
date Thu, 17 Jun 2010 03:41:27 -0400
parents 0350b634c044
children 4c94f2023d62
comparison
equal deleted inserted replaced
4653:744b75ad18b8 4654:7dbcd71216df
320 nf.ydelta = 0; 320 nf.ydelta = 0;
321 nf.last_x = x; 321 nf.last_x = x;
322 nf.last_y = y; 322 nf.last_y = y;
323 nf.last_pressure = pressure; 323 nf.last_pressure = pressure;
324 SDL_AddFinger(touch,&nf); 324 SDL_AddFinger(touch,&nf);
325 325 //if(x < 0 || y < 0) return 0; //should defer if only a partial input
326 posted = 0; 326 posted = 0;
327 if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) { 327 if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) {
328 SDL_Event event; 328 SDL_Event event;
329 event.tfinger.type = SDL_FINGERDOWN; 329 event.tfinger.type = SDL_FINGERDOWN;
330 event.tfinger.touchId = (Uint8) id; 330 event.tfinger.touchId = (Uint8) id;
362 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); 362 SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
363 int posted; 363 int posted;
364 int xrel; 364 int xrel;
365 int yrel; 365 int yrel;
366 int x_max = 0, y_max = 0; 366 int x_max = 0, y_max = 0;
367 367
368 if (!touch || touch->flush_motion) { 368 if (!touch || touch->flush_motion) {
369 return 0;
370 }
371
372 if(finger == NULL) {
373 SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
374 return 0; 369 return 0;
375 } else { 370 }
371
372 if(finger == NULL) {
373 return SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
374 } else {
376 /* the relative motion is calculated regarding the last position */ 375 /* the relative motion is calculated regarding the last position */
377 if (relative) { 376 if (relative) {
378 xrel = x; 377 xrel = x;
379 yrel = y; 378 yrel = y;
380 x = (finger->last_x + x); 379 x = (finger->last_x + x);
387 yrel = y - finger->last_y; 386 yrel = y - finger->last_y;
388 } 387 }
389 388
390 /* Drop events that don't change state */ 389 /* Drop events that don't change state */
391 if (!xrel && !yrel) { 390 if (!xrel && !yrel) {
392 #if 0 391 #if 0
393 printf("Touch event didn't change state - dropped!\n"); 392 printf("Touch event didn't change state - dropped!\n");
394 #endif 393 #endif
395 return 0; 394 return 0;
396 } 395 }
397 396
398 /* Update internal touch coordinates */ 397 /* Update internal touch coordinates */
399 398