src/video/uikit/SDL_uikitview.m
changeset 4488 6dc6a2bdd55e
parent 4465 3e69e077cb95
child 4490 06c7423f8c60
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Jul 06 10:58:23 2010 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Tue Jul 06 22:08:19 2010 -0700
     1.3 @@ -64,7 +64,7 @@
     1.4  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
     1.5  
     1.6  	NSEnumerator *enumerator = [touches objectEnumerator];
     1.7 -	UITouch *touch =(UITouch*)[enumerator nextObject];
     1.8 +	UITouch *touch = (UITouch*)[enumerator nextObject];
     1.9  	
    1.10  #if FIXME_MULTITOUCH
    1.11  	/* associate touches with mice, so long as we have slots */
    1.12 @@ -101,12 +101,21 @@
    1.13  		/* re-calibrate relative mouse motion */
    1.14  		SDL_GetRelativeMouseState(i, NULL, NULL);
    1.15  		
    1.16 -		/* grab next touch */
    1.17 -		touch = (UITouch*)[enumerator nextObject]; 
    1.18 -		
    1.19  		/* switch back to our old mouse */
    1.20  		SDL_SelectMouse(oldMouse);
    1.21  		
    1.22 +		/* grab next touch */
    1.23 +		touch = (UITouch*)[enumerator nextObject]; 
    1.24 +	}
    1.25 +#else
    1.26 +	if (touch) {
    1.27 +		CGPoint locationInView = [touch locationInView: self];
    1.28 +			
    1.29 +		/* send moved event */
    1.30 +		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.31 +
    1.32 +		/* send mouse down event */
    1.33 +		SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.34  	}
    1.35  #endif
    1.36  }
    1.37 @@ -114,10 +123,10 @@
    1.38  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    1.39  	
    1.40  	NSEnumerator *enumerator = [touches objectEnumerator];
    1.41 -	UITouch *touch=nil;
    1.42 +	UITouch *touch = (UITouch*)[enumerator nextObject];
    1.43  	
    1.44  #if FIXME_MULTITOUCH
    1.45 -	while(touch = (UITouch *)[enumerator nextObject]) {
    1.46 +	while(touch) {
    1.47  		/* search for the mouse slot associated with this touch */
    1.48  		int i, found = NO;
    1.49  		for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
    1.50 @@ -131,6 +140,14 @@
    1.51  				found = YES;
    1.52  			}
    1.53  		}
    1.54 +		
    1.55 +		/* grab next touch */
    1.56 +		touch = (UITouch*)[enumerator nextObject]; 
    1.57 +	}
    1.58 +#else
    1.59 +	if (touch) {
    1.60 +		/* send mouse up */
    1.61 +		SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.62  	}
    1.63  #endif
    1.64  }
    1.65 @@ -147,10 +164,10 @@
    1.66  - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    1.67  	
    1.68  	NSEnumerator *enumerator = [touches objectEnumerator];
    1.69 -	UITouch *touch=nil;
    1.70 +	UITouch *touch = (UITouch*)[enumerator nextObject];
    1.71  	
    1.72  #if FIXME_MULTITOUCH
    1.73 -	while(touch = (UITouch *)[enumerator nextObject]) {
    1.74 +	while(touch) {
    1.75  		/* try to find the mouse associated with this touch */
    1.76  		int i, found = NO;
    1.77  		for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
    1.78 @@ -163,6 +180,16 @@
    1.79  				found = YES;
    1.80  			}
    1.81  		}
    1.82 +		
    1.83 +		/* grab next touch */
    1.84 +		touch = (UITouch*)[enumerator nextObject]; 
    1.85 +	}
    1.86 +#else
    1.87 +	if (touch) {
    1.88 +		CGPoint locationInView = [touch locationInView: self];
    1.89 +
    1.90 +		/* send moved event */
    1.91 +		SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.92  	}
    1.93  #endif
    1.94  }