# HG changeset patch # User Sam Lantinga # Date 1278479299 25200 # Node ID 6dc6a2bdd55ecb4f084db332cee34a0cff85deec # Parent ba7b2bc1f1a1d5ae4479bf993477c0952892f6f6 Re-implemented single mouse touches on the iPhone/iPad diff -r ba7b2bc1f1a1 -r 6dc6a2bdd55e src/video/uikit/SDL_uikitopengles.m --- a/src/video/uikit/SDL_uikitopengles.m Tue Jul 06 10:58:23 2010 -0700 +++ b/src/video/uikit/SDL_uikitopengles.m Tue Jul 06 22:08:19 2010 -0700 @@ -125,7 +125,10 @@ UIKit_GL_DeleteContext(_this, view); return NULL; } - + + /* Make this window the current mouse focus for touch input */ + SDL_SetMouseFocus(window); + return view; } diff -r ba7b2bc1f1a1 -r 6dc6a2bdd55e src/video/uikit/SDL_uikitview.h --- a/src/video/uikit/SDL_uikitview.h Tue Jul 06 10:58:23 2010 -0700 +++ b/src/video/uikit/SDL_uikitview.h Tue Jul 06 22:08:19 2010 -0700 @@ -38,7 +38,7 @@ #else @interface SDL_uikitview : UIView { #endif - + #if FIXME_MULTITOUCH SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; #endif diff -r ba7b2bc1f1a1 -r 6dc6a2bdd55e src/video/uikit/SDL_uikitview.m --- a/src/video/uikit/SDL_uikitview.m Tue Jul 06 10:58:23 2010 -0700 +++ b/src/video/uikit/SDL_uikitview.m Tue Jul 06 22:08:19 2010 -0700 @@ -64,7 +64,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch =(UITouch*)[enumerator nextObject]; + UITouch *touch = (UITouch*)[enumerator nextObject]; #if FIXME_MULTITOUCH /* associate touches with mice, so long as we have slots */ @@ -101,12 +101,21 @@ /* 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); + /* grab next touch */ + touch = (UITouch*)[enumerator nextObject]; + } +#else + if (touch) { + CGPoint locationInView = [touch locationInView: self]; + + /* send moved event */ + SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + + /* send mouse down event */ + SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); } #endif } @@ -114,10 +123,10 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch=nil; + UITouch *touch = (UITouch*)[enumerator nextObject]; #if FIXME_MULTITOUCH - while(touch = (UITouch *)[enumerator nextObject]) { + while(touch) { /* search for the mouse slot associated with this touch */ int i, found = NO; for (i=0; i