diff -r 477957a89881 -r 1965eba10be6 cocoaTouch/SDLOverrides/SDL_uikitview.m --- a/cocoaTouch/SDLOverrides/SDL_uikitview.m Mon Feb 08 18:12:06 2010 +0000 +++ b/cocoaTouch/SDLOverrides/SDL_uikitview.m Mon Feb 08 21:49:52 2010 +0000 @@ -20,7 +20,8 @@ slouken@libsdl.org, vittorio.giovara@gmail.com */ -#include "PascalImports.h" +#import "PascalImports.h" +#import "CGPointUtils.h" #import "SDL_uikitview.h" #import "SDL_uikitappdelegate.h" @@ -64,7 +65,8 @@ } self.multipleTouchEnabled = YES; - + self.exclusiveTouch = YES; +/* // custom code // the coordinate system is still like in Portrait even though everything is rotated attackButton = [[UIButton alloc] initWithFrame:CGRectMake(30, 480, 260, 50)]; @@ -109,7 +111,7 @@ [chatButton addTarget:[self superclass] action:@selector(chatBegin) forControlEvents:UIControlEventTouchDown]; [self insertSubview:chatButton atIndex:0]; [chatButton release]; - + */ return self; } @@ -123,11 +125,13 @@ void IPH_showControls (void) { NSLog(@"Showing controls"); + /* [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; attackButton.frame = CGRectMake(30, 430, 260, 50); menuButton.frame = CGRectMake(0, 430, 30, 50); [UIView commitAnimations]; + */ } #pragma mark - @@ -157,8 +161,7 @@ } +(void) chatBegin { - HW_chat(); - SDL_iPhoneKeyboardShow([SDLUIKitDelegate sharedAppDelegate].uiwindow); + //TODO: implement a UITextScroll and put received chat lines in there } #pragma mark - @@ -169,55 +172,7 @@ // we override default touch input to implement our own gestures - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - /* - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch =(UITouch*)[enumerator nextObject]; - - // associate touches with mice, so long as we have slots - int i; - int found = 0; - for(i=0; touch && i < MAX_SIMULTANEOUS_TOUCHES; i++) { - - // check if this mouse is already tracking a touch - if (mice[i].driverdata != NULL) { - continue; - } - - // mouse not associated with anything right now, associate the touch with this mouse - found = 1; - - // save old mouse so we can switch back - int oldMouse = SDL_SelectMouse(-1); - - // select this slot's mouse - SDL_SelectMouse(i); - CGPoint locationInView = [touch locationInView: self]; - - CGFloat oldX = locationInView.x; - locationInView.x = locationInView.y; - locationInView.y = 320 - oldX; - - // set driver data to touch object, we'll use touch object later - mice[i].driverdata = [touch retain]; - - // send moved event - SDL_SendMouseMotion(i, 0, locationInView.x, locationInView.y, 0); - - // send mouse down event - SDL_SendMouseButton(i, SDL_PRESSED, SDL_BUTTON_LEFT); - - // re-calibrate relative mouse motion - SDL_GetRelativeMouseState(i, NULL, NULL); - - // grab next touch - touch = (UITouch*)[enumerator nextObject]; - - // switch back to our old mouse - SDL_SelectMouse(oldMouse); - - } - */ - + NSArray *twoTouches; UITouch *touch = [touches anyObject]; switch ([touches count]) { @@ -226,7 +181,8 @@ initialDistanceForPinching = 0; switch ([touch tapCount]) { case 1: - NSLog(@"X:%d Y:%d", (int) gestureStartPoint.x, gestureStartPoint.y ); + + NSLog(@"X:%d Y:%d", (int)gestureStartPoint.x, (int)gestureStartPoint.y ); SDL_WarpMouseInWindow([SDLUIKitDelegate sharedAppDelegate].window, (int)gestureStartPoint.y, 320 - (int)gestureStartPoint.x); HW_click(); @@ -244,7 +200,7 @@ } // pinching - NSArray *twoTouches = [touches allObjects]; + twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; initialDistanceForPinching = distanceBetweenPoints([first locationInView:self], [second locationInView:self]); @@ -257,34 +213,14 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { initialDistanceForPinching = 0; - + gestureStartPoint.x = 0; + gestureStartPoint.y = 0; HW_allKeysUp(); - /* - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch=nil; - - while(touch = (UITouch *)[enumerator nextObject]) { - // search for the mouse slot associated with this touch - int i, found = NO; - for (i=0; i