Fix for Game Center leaderboard screens not always responding to touch input in iOS apps that don't use SDL_iPhoneSetAnimationCallback
authorDavidLudwig <dludwig@pobox.com>
Mon, 23 Jul 2012 00:14:07 -0400
changeset 6685 8faee8f46165
parent 6684 992268e65626
child 6686 45014250760c
Fix for Game Center leaderboard screens not always responding to touch input in iOS apps that don't use SDL_iPhoneSetAnimationCallback
src/video/uikit/SDL_uikitevents.m
--- a/src/video/uikit/SDL_uikitevents.m	Mon Jul 23 00:10:19 2012 -0400
+++ b/src/video/uikit/SDL_uikitevents.m	Mon Jul 23 00:14:07 2012 -0400
@@ -57,14 +57,24 @@
      */
     if (setjmp(*jump_env()) == 0) {
         /* if we're setting the jump, rather than jumping back */
+		
+		/* Let the run loop run for a short amount of time: long enough for
+		   touch events to get processed (which is important to get certain
+		   elements of Game Center's GKLeaderboardViewController to respond
+		   to touch input), but not long enough to introduce a significant
+		   delay in the rest of the app.
+		*/
+		const CFTimeInterval seconds = 0.000002;
+		
+		/* Pump most event types. */
         SInt32 result;
         do {
-            result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE);
+            result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE);
         } while (result == kCFRunLoopRunHandledSource);
 		
 		/* Make sure UIScrollView objects scroll properly. */
 		do {
-			result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, 0, TRUE);
+			result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE);
 		} while(result == kCFRunLoopRunHandledSource);
     }
 }