Merge pull request #19159 from hrydgard/minor-ios-fixes

iOS: Fix threading issue, add back gesture
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2024-05-20 16:42:24 +02:00
commit f0befda912
3 files changed
+33 -4

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
#import "LocationHelper.h"
@interface ViewController : GLKViewController <iCadeEventDelegate,
LocationHandlerDelegate, CameraFrameDelegate>
LocationHandlerDelegate, CameraFrameDelegate, UIGestureRecognizerDelegate>
- (void)shareText:(NSString *)text;
- (void)shutdown;
+21 -3
View File
@@ -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()
+11
View File
@@ -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]));
}
}