Prevented SDL_SendDown from sending on nonexistent touch devices.
authorJim Grandpre <jim.tla@gmail.com>
Thu, 29 Jul 2010 12:24:34 -0400
changeset 467489d5e2201b00
parent 4673 c17ac64abb70
child 4675 641c13b0ce5f
Prevented SDL_SendDown from sending on nonexistent touch devices.
src/events/SDL_touch.c
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/events/SDL_touch.c	Wed Jul 28 23:32:13 2010 -0700
     1.2 +++ b/src/events/SDL_touch.c	Thu Jul 29 12:24:34 2010 -0400
     1.3 @@ -312,6 +312,10 @@
     1.4      int posted;
     1.5      SDL_Touch* touch = SDL_GetTouch(id);
     1.6  
     1.7 +    if(!touch) {
     1.8 +      return SDL_TouchNotFoundError(id);
     1.9 +    }
    1.10 +
    1.11      if(down) {
    1.12  	SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
    1.13  	if(finger == NULL) {
    1.14 @@ -374,7 +378,10 @@
    1.15      int yrel;
    1.16      int x_max = 0, y_max = 0;
    1.17      
    1.18 -    if (!touch || touch->flush_motion) {
    1.19 +    if (!touch) {
    1.20 +      return SDL_TouchNotFoundError(id);
    1.21 +    }
    1.22 +    if(touch->flush_motion) {
    1.23  	return 0;
    1.24      }
    1.25      
    1.26 @@ -459,8 +466,9 @@
    1.27      int posted;
    1.28      Uint32 type;
    1.29  
    1.30 +    
    1.31      if (!touch) {
    1.32 -        return 0;
    1.33 +      return SDL_TouchNotFoundError(id);
    1.34      }
    1.35  
    1.36      /* Figure out which event to perform */
    1.37 @@ -510,4 +518,13 @@
    1.38      return touch->name;
    1.39  }
    1.40  
    1.41 +int SDL_TouchNotFoundError(int id) {
    1.42 +  printf("ERROR: Cannot send touch on non-existent device with id: %i make sure SDL_AddTouch has been called\n",id);
    1.43 +  printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
    1.44 +  int i;
    1.45 +  for(i=0;i < SDL_num_touch;i++) {
    1.46 +    printf("ERROR: %i\n",SDL_touchPads[i]->id);
    1.47 +  }
    1.48 +  return 0;
    1.49 +}
    1.50  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Wed Jul 28 23:32:13 2010 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Jul 29 12:24:34 2010 -0400
     2.3 @@ -313,7 +313,7 @@
     2.4              touch.pressureres = touch.pressure_max - touch.pressure_min;
     2.5              
     2.6              if (SDL_AddTouch(&touch, "") < 0) {
     2.7 -                return; 
     2.8 +                continue;
     2.9              }
    2.10          } 
    2.11          float x = [touch normalizedPosition].x;