Mercurial > sdl-ios-xcode
comparison src/events/SDL_touch.c @ 4674:89d5e2201b00
Prevented SDL_SendDown from sending on nonexistent touch devices.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Thu, 29 Jul 2010 12:24:34 -0400 |
parents | 0ecdbabdd7e7 |
children | 99b4560b7aa1 |
comparison
equal
deleted
inserted
replaced
4673:c17ac64abb70 | 4674:89d5e2201b00 |
---|---|
309 int | 309 int |
310 SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure) | 310 SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure) |
311 { | 311 { |
312 int posted; | 312 int posted; |
313 SDL_Touch* touch = SDL_GetTouch(id); | 313 SDL_Touch* touch = SDL_GetTouch(id); |
314 | |
315 if(!touch) { | |
316 return SDL_TouchNotFoundError(id); | |
317 } | |
314 | 318 |
315 if(down) { | 319 if(down) { |
316 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); | 320 SDL_Finger *finger = SDL_GetFinger(touch,fingerid); |
317 if(finger == NULL) { | 321 if(finger == NULL) { |
318 SDL_Finger nf; | 322 SDL_Finger nf; |
372 int posted; | 376 int posted; |
373 int xrel; | 377 int xrel; |
374 int yrel; | 378 int yrel; |
375 int x_max = 0, y_max = 0; | 379 int x_max = 0, y_max = 0; |
376 | 380 |
377 if (!touch || touch->flush_motion) { | 381 if (!touch) { |
382 return SDL_TouchNotFoundError(id); | |
383 } | |
384 if(touch->flush_motion) { | |
378 return 0; | 385 return 0; |
379 } | 386 } |
380 | 387 |
381 if(finger == NULL || !finger->down) { | 388 if(finger == NULL || !finger->down) { |
382 return SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure); | 389 return SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure); |
457 { | 464 { |
458 SDL_Touch *touch = SDL_GetTouch(id); | 465 SDL_Touch *touch = SDL_GetTouch(id); |
459 int posted; | 466 int posted; |
460 Uint32 type; | 467 Uint32 type; |
461 | 468 |
469 | |
462 if (!touch) { | 470 if (!touch) { |
463 return 0; | 471 return SDL_TouchNotFoundError(id); |
464 } | 472 } |
465 | 473 |
466 /* Figure out which event to perform */ | 474 /* Figure out which event to perform */ |
467 switch (state) { | 475 switch (state) { |
468 case SDL_PRESSED: | 476 case SDL_PRESSED: |
508 return NULL; | 516 return NULL; |
509 } | 517 } |
510 return touch->name; | 518 return touch->name; |
511 } | 519 } |
512 | 520 |
521 int SDL_TouchNotFoundError(int id) { | |
522 printf("ERROR: Cannot send touch on non-existent device with id: %i make sure SDL_AddTouch has been called\n",id); | |
523 printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch); | |
524 int i; | |
525 for(i=0;i < SDL_num_touch;i++) { | |
526 printf("ERROR: %i\n",SDL_touchPads[i]->id); | |
527 } | |
528 return 0; | |
529 } | |
513 /* vi: set ts=4 sw=4 expandtab: */ | 530 /* vi: set ts=4 sw=4 expandtab: */ |