cocoaTouch/SDLOverrides/SDL_uikitview.m
changeset 2701 3a8560c00f78
parent 2696 41aa7b56c17b
child 2705 2b5625c4ec16
equal deleted inserted replaced
2700:726e4a230b48 2701:3a8560c00f78
   164 	UITouch *touch = [touches anyObject];
   164 	UITouch *touch = [touches anyObject];
   165 	gestureStartPoint = [touch locationInView:self];
   165 	gestureStartPoint = [touch locationInView:self];
   166 
   166 
   167 	// one tap - single click
   167 	// one tap - single click
   168 	if (1 == [touch tapCount] ) {
   168 	if (1 == [touch tapCount] ) {
   169 		SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].windowID, gestureStartPoint.x, gestureStartPoint.y);
   169 		//SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].windowID, gestureStartPoint.x, gestureStartPoint.y);
   170 		HW_click();
   170 		HW_click();
   171 	}
   171 	}
   172 	
   172 	
   173 	// two taps - right click
   173 	// two taps - right click
   174 	if (2 == [touch tapCount] ) {
   174 	if (2 == [touch tapCount] ) {
   228 	CGPoint currentPosition = [touch locationInView:self];
   228 	CGPoint currentPosition = [touch locationInView:self];
   229 	
   229 	
   230 	CGFloat Xdiff = gestureStartPoint.x - currentPosition.x;
   230 	CGFloat Xdiff = gestureStartPoint.x - currentPosition.x;
   231 	CGFloat Ydiff = gestureStartPoint.y - currentPosition.y;
   231 	CGFloat Ydiff = gestureStartPoint.y - currentPosition.y;
   232 	CGFloat deltaX = fabsf(Xdiff);
   232 	CGFloat deltaX = fabsf(Xdiff);
   233     CGFloat deltaY = fabsf(Ydiff);
   233 	CGFloat deltaY = fabsf(Ydiff);
   234     
   234     
   235 	if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) {
   235 	if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) {
   236 		NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x);
   236 		NSLog(@"Horizontal swipe detected, begX:%f curX:%f", gestureStartPoint.x, currentPosition.x);
   237 		if (Xdiff > 0) HW_walkLeft();
   237 		if (Xdiff > 0) HW_walkLeft();
   238 		else HW_walkRight();
   238 		else HW_walkRight();
   239     }
   239 	}
   240     else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){
   240 	else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){
   241 		NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y);
   241 		NSLog(@"Vertical swipe detected, begY:%f curY:%f", gestureStartPoint.y, currentPosition.y);
   242 		if (Ydiff > 0) HW_aimUp();
   242 		if (Ydiff > 0) HW_aimUp();
   243 		else HW_aimDown();
   243 		else HW_aimDown();
   244 	}
   244 	}
   245 	
   245 	
   247 	if (2 == [touches count]) {
   247 	if (2 == [touches count]) {
   248 		NSArray *twoTouches = [touches allObjects];
   248 		NSArray *twoTouches = [touches allObjects];
   249 		UITouch *first = [twoTouches objectAtIndex:0];
   249 		UITouch *first = [twoTouches objectAtIndex:0];
   250 		UITouch *second = [twoTouches objectAtIndex:1];
   250 		UITouch *second = [twoTouches objectAtIndex:1];
   251 		CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
   251 		CGFloat currentDistance = distanceBetweenPoints([first locationInView:self], [second locationInView:self]);
   252 	
   252 		
   253 		if (0 == initialDistance) 
   253 		if (0 == initialDistance) 
   254 			initialDistance = currentDistance;
   254 			initialDistance = currentDistance;
   255 		else if (currentDistance - initialDistance > kMinimumPinchDelta) {
   255 		else if (currentDistance - initialDistance > kMinimumPinchDelta) {
   256 			NSLog(@"Outward pinch detected");
   256 			NSLog(@"Outward pinch detected");
   257 			HW_zoomOut();
   257 			HW_zoomOut();