diff --git a/UI/DarwinFileSystemServices.mm b/UI/DarwinFileSystemServices.mm index 2afeabfa94..6b9ddce644 100644 --- a/UI/DarwinFileSystemServices.mm +++ b/UI/DarwinFileSystemServices.mm @@ -7,6 +7,7 @@ #include "ppsspp_config.h" #include "Core/Config.h" +#include "Common/Log.h" #include "DarwinFileSystemServices.h" #include #include @@ -16,6 +17,7 @@ #endif #if __has_include() +#include "../ios/ViewControllerCommon.h" #include @interface DocumentPickerDelegate : NSObject @@ -24,18 +26,27 @@ @implementation DocumentPickerDelegate -(instancetype)initWithCallback: (DarwinDirectoryPanelCallback)callback { - if (self = [super init]) { - self.callback = callback; - } - - return self; + if (self = [super init]) { + self.callback = callback; + } + return self; } -- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray *)urls { - if (urls.count >= 1) +- (void)didPickDocumentsAtURLs:(NSArray *)urls { + if (urls.count >= 1) self.callback(true, Path(urls[0].path.UTF8String)); - else - self.callback(false, Path()); + else + self.callback(false, Path()); + + INFO_LOG(SYSTEM, "Callback processed, pre-emptively hide keyboard"); + [sharedViewController hideKeyboard]; +} + +- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller { + self.callback(false, Path()); + + INFO_LOG(SYSTEM, "Picker cancelled, pre-emptively hide keyboard"); + [sharedViewController hideKeyboard]; } @end @@ -77,6 +88,7 @@ void DarwinFileSystemServices::presentDirectoryPanel( // panel.allowedFileTypes = @[(__bridge NSString *)kUTTypeFolder]; NSModalResponse modalResponse = [panel runModal]; + INFO_LOG(SYSTEM, "Mac: Received response from modal"); if (modalResponse == NSModalResponseOK && panel.URLs.firstObject) { callback(true, Path(panel.URLs.firstObject.path.UTF8String)); } else if (modalResponse == NSModalResponseCancel) { @@ -144,4 +156,4 @@ void RestartMacApp() { [task launch]; exit(0); #endif -} \ No newline at end of file +} diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 6c1d3e53d9..48afd931e3 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -448,11 +448,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { INFO_LOG(SYSTEM, "Backspace"); } --(BOOL) hasText -{ - return YES; -} - -(void) insertText:(NSString *)text { std::string str = std::string([text UTF8String]); @@ -460,6 +455,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { UTF8 chars(str); while (!chars.end()) { uint32_t codePoint = chars.next(); + INFO_LOG(SYSTEM, "Codepoint#: %d", codePoint); KeyInput input{}; input.deviceId = DEVICE_ID_KEYBOARD; input.flags = KEY_CHAR; @@ -470,17 +466,24 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { -(BOOL) canBecomeFirstResponder { - return YES; + return true; +} + +-(BOOL) hasText +{ + return true; } -(void) showKeyboard { dispatch_async(dispatch_get_main_queue(), ^{ + INFO_LOG(SYSTEM, "becomeFirstResponder"); [self becomeFirstResponder]; }); } -(void) hideKeyboard { dispatch_async(dispatch_get_main_queue(), ^{ + INFO_LOG(SYSTEM, "resignFirstResponder"); [self resignFirstResponder]; }); }