Commit 44280ae5 authored by Sam Lantinga's avatar Sam Lantinga

Re-implemented single mouse touches on the iPhone/iPad

parent 52b41472
...@@ -125,7 +125,10 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) ...@@ -125,7 +125,10 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
UIKit_GL_DeleteContext(_this, view); UIKit_GL_DeleteContext(_this, view);
return NULL; return NULL;
} }
/* Make this window the current mouse focus for touch input */
SDL_SetMouseFocus(window);
return view; return view;
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#else #else
@interface SDL_uikitview : UIView { @interface SDL_uikitview : UIView {
#endif #endif
#if FIXME_MULTITOUCH #if FIXME_MULTITOUCH
SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES]; SDL_Mouse mice[MAX_SIMULTANEOUS_TOUCHES];
#endif #endif
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch =(UITouch*)[enumerator nextObject]; UITouch *touch = (UITouch*)[enumerator nextObject];
#if FIXME_MULTITOUCH #if FIXME_MULTITOUCH
/* associate touches with mice, so long as we have slots */ /* associate touches with mice, so long as we have slots */
...@@ -101,12 +101,21 @@ ...@@ -101,12 +101,21 @@
/* re-calibrate relative mouse motion */ /* re-calibrate relative mouse motion */
SDL_GetRelativeMouseState(i, NULL, NULL); SDL_GetRelativeMouseState(i, NULL, NULL);
/* grab next touch */
touch = (UITouch*)[enumerator nextObject];
/* switch back to our old mouse */ /* switch back to our old mouse */
SDL_SelectMouse(oldMouse); 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 #endif
} }
...@@ -114,10 +123,10 @@ ...@@ -114,10 +123,10 @@
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch=nil; UITouch *touch = (UITouch*)[enumerator nextObject];
#if FIXME_MULTITOUCH #if FIXME_MULTITOUCH
while(touch = (UITouch *)[enumerator nextObject]) { while(touch) {
/* search for the mouse slot associated with this touch */ /* search for the mouse slot associated with this touch */
int i, found = NO; int i, found = NO;
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
...@@ -131,6 +140,14 @@ ...@@ -131,6 +140,14 @@
found = YES; found = YES;
} }
} }
/* grab next touch */
touch = (UITouch*)[enumerator nextObject];
}
#else
if (touch) {
/* send mouse up */
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
} }
#endif #endif
} }
...@@ -147,10 +164,10 @@ ...@@ -147,10 +164,10 @@
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSEnumerator *enumerator = [touches objectEnumerator]; NSEnumerator *enumerator = [touches objectEnumerator];
UITouch *touch=nil; UITouch *touch = (UITouch*)[enumerator nextObject];
#if FIXME_MULTITOUCH #if FIXME_MULTITOUCH
while(touch = (UITouch *)[enumerator nextObject]) { while(touch) {
/* try to find the mouse associated with this touch */ /* try to find the mouse associated with this touch */
int i, found = NO; int i, found = NO;
for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) { for (i=0; i<MAX_SIMULTANEOUS_TOUCHES && !found; i++) {
...@@ -163,6 +180,16 @@ ...@@ -163,6 +180,16 @@
found = YES; found = YES;
} }
} }
/* 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);
} }
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment