diff 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
line wrap: on
line diff
--- a/src/events/SDL_touch.c	Wed Jul 28 23:32:13 2010 -0700
+++ b/src/events/SDL_touch.c	Thu Jul 29 12:24:34 2010 -0400
@@ -312,6 +312,10 @@
     int posted;
     SDL_Touch* touch = SDL_GetTouch(id);
 
+    if(!touch) {
+      return SDL_TouchNotFoundError(id);
+    }
+
     if(down) {
 	SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
 	if(finger == NULL) {
@@ -374,7 +378,10 @@
     int yrel;
     int x_max = 0, y_max = 0;
     
-    if (!touch || touch->flush_motion) {
+    if (!touch) {
+      return SDL_TouchNotFoundError(id);
+    }
+    if(touch->flush_motion) {
 	return 0;
     }
     
@@ -459,8 +466,9 @@
     int posted;
     Uint32 type;
 
+    
     if (!touch) {
-        return 0;
+      return SDL_TouchNotFoundError(id);
     }
 
     /* Figure out which event to perform */
@@ -510,4 +518,13 @@
     return touch->name;
 }
 
+int SDL_TouchNotFoundError(int id) {
+  printf("ERROR: Cannot send touch on non-existent device with id: %i make sure SDL_AddTouch has been called\n",id);
+  printf("ERROR: There are %i touches installed with Id's:\n",SDL_num_touch);
+  int i;
+  for(i=0;i < SDL_num_touch;i++) {
+    printf("ERROR: %i\n",SDL_touchPads[i]->id);
+  }
+  return 0;
+}
 /* vi: set ts=4 sw=4 expandtab: */