src/video/uikit/SDL_uikitview.m
changeset 4662 3c4e0130c9b1
parent 4661 03dcb795c583
child 4677 31607094315c
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Mon Jul 12 21:09:23 2010 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Tue Jul 13 18:31:09 2010 -0400
     1.3 @@ -91,9 +91,30 @@
     1.4  #if FIXED_MULTITOUCH
     1.5  	while(touch) {
     1.6  	  CGPoint locationInView = [touch locationInView: self];
     1.7 -	  SDL_SendFingerDown(touchId,(int)touch,
     1.8 +
     1.9 +
    1.10 +#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.11 +	  //FIXME: TODO: Using touch as the fingerId is potentially dangerous
    1.12 +	  //It is also much more efficient than storing the UITouch pointer
    1.13 +	  //and comparing it to the incoming event.
    1.14 +	  SDL_SendFingerDown(touchId,(long)touch,
    1.15  			     SDL_TRUE,locationInView.x,locationInView.y,
    1.16  			     1);
    1.17 +#else
    1.18 +	  int i;
    1.19 +	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
    1.20 +	    if(finger[i] == NULL) {
    1.21 +	      finger[i] = touch;
    1.22 +	      SDL_SendFingerDown(touchId,i,
    1.23 +				 SDL_TRUE,locationInView.x,locationInView.y,
    1.24 +				 1);
    1.25 +	      break;
    1.26 +	    }
    1.27 +	  }
    1.28 +#endif
    1.29 +	  
    1.30 +
    1.31 +	  
    1.32  
    1.33  	  touch = (UITouch*)[enumerator nextObject]; 
    1.34  	}
    1.35 @@ -113,9 +134,23 @@
    1.36  #if FIXED_MULTITOUCH
    1.37  	while(touch) {
    1.38  	  CGPoint locationInView = [touch locationInView: self];
    1.39 -	  SDL_SendFingerDown(touchId,(int)touch,
    1.40 +	  
    1.41 +
    1.42 +#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.43 +	  SDL_SendFingerDown(touchId,(long)touch,
    1.44  			     SDL_FALSE,locationInView.x,locationInView.y,
    1.45  			     1);
    1.46 +#else
    1.47 +	  int i;
    1.48 +	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
    1.49 +	    if(finger[i] == touch) {
    1.50 +	      SDL_SendFingerDown(touchId,i,
    1.51 +				 SDL_FALSE,locationInView.x,locationInView.y,
    1.52 +				 1);
    1.53 +	      break;
    1.54 +	    }
    1.55 +	  }
    1.56 +#endif
    1.57  
    1.58  	  touch = (UITouch*)[enumerator nextObject]; 
    1.59  	}
    1.60 @@ -146,9 +181,23 @@
    1.61  #if FIXED_MULTITOUCH
    1.62  	while(touch) {
    1.63  	  CGPoint locationInView = [touch locationInView: self];
    1.64 -	  SDL_SendTouchMotion(touchId,(int)touch,
    1.65 -			     SDL_FALSE,locationInView.x,locationInView.y,
    1.66 -			     1);
    1.67 +	  
    1.68 +
    1.69 +#ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.70 +	  SDL_SendTouchMotion(touchId,(long)touch,
    1.71 +			      SDL_FALSE,locationInView.x,locationInView.y,
    1.72 +			      1);
    1.73 +#else
    1.74 +	  int i;
    1.75 +	  for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) {
    1.76 +	    if(finger[i] == touch) {
    1.77 +	      SDL_SendTouchMotion(touchId,i,
    1.78 +				  SDL_FALSE,locationInView.x,locationInView.y,
    1.79 +				  1);
    1.80 +	      break;
    1.81 +	    }
    1.82 +	  }
    1.83 +#endif
    1.84  
    1.85  	  touch = (UITouch*)[enumerator nextObject]; 
    1.86  	}