diff --git a/ios/ViewController.h b/ios/ViewController.h index d64d973c77..d17de68c1c 100644 --- a/ios/ViewController.h +++ b/ios/ViewController.h @@ -10,7 +10,7 @@ #import "LocationHelper.h" @interface ViewController : GLKViewController + LocationHandlerDelegate, CameraFrameDelegate, UIGestureRecognizerDelegate> - (void)shareText:(NSString *)text; - (void)shutdown; diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 11649745cd..b25b5cb83e 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -192,12 +192,16 @@ extern float g_safeInsetBottom; self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; } + UIScreenEdgePanGestureRecognizer *mBackGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:) ]; + [mBackGestureRecognizer setEdges:UIRectEdgeLeft]; + [[self view] addGestureRecognizer:mBackGestureRecognizer]; + GLKView* view = (GLKView *)self.view; view.context = self.context; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; view.drawableStencilFormat = GLKViewDrawableStencilFormat8; [EAGLContext setCurrentContext:self.context]; - self.preferredFramesPerSecond = 60; + self.preferredFramesPerSecond = 60; // NOTE: We don't yet take advantage of 120hz screens [[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; @@ -239,7 +243,6 @@ extern float g_safeInsetBottom; NativeFrame(graphicsContext); } - INFO_LOG(SYSTEM, "Emulation thread shutting down\n"); NativeShutdownGraphics(); @@ -251,6 +254,18 @@ extern float g_safeInsetBottom; }); } +- (void)handleSwipeFrom:(UIScreenEdgePanGestureRecognizer *)recognizer +{ + if (recognizer.state == UIGestureRecognizerStateEnded) { + KeyInput key; + key.flags = KEY_DOWN | KEY_UP; + key.keyCode = NKCODE_BACK; + key.deviceId = DEVICE_ID_TOUCH; + NativeKey(key); + INFO_LOG(SYSTEM, "Detected back swipe"); + } +} + - (void)appWillTerminate:(NSNotification *)notification { [self shutdown]; @@ -752,7 +767,10 @@ void stopLocation() { void System_LaunchUrl(LaunchUrlType urlType, char const* url) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithCString:url encoding:NSStringEncodingConversionAllowLossy]]]; + NSURL *nsUrl = [NSURL URLWithString:[NSString stringWithCString:url encoding:NSStringEncodingConversionAllowLossy]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication] openURL:nsUrl options:@{} completionHandler:nil]; + }); } void bindDefaultFBO() diff --git a/ios/main.mm b/ios/main.mm index 073304b3ca..28d1bdf6aa 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -437,6 +437,16 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string [sharedViewController shareText:text]; return true; } +/* + // Not 100% sure the threading is right + case SystemRequestType::COPY_TO_CLIPBOARD: + { + @autoreleasepool { + [UIPasteboard generalPasteboard].string = @(param1.c_str()); + return 0; + } + } +*/ case SystemRequestType::SET_KEEP_SCREEN_BRIGHT: dispatch_async(dispatch_get_main_queue(), ^{ INFO_LOG(SYSTEM, "SET_KEEP_SCREEN_BRIGHT: %d", (int)param3); @@ -550,3 +560,4 @@ int main(int argc, char *argv[]) return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), NSStringFromClass([AppDelegate class])); } } +