commit 2fbb79b6d995ad63350ede264a37e919347ba19a Author: Stossy11 <69031796+stossy11@users.noreply.github.com> Date: Thu Mar 20 08:24:10 2025 +1100 first commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..0aad534 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ba6728 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Ryujinx Helper + +**Ryujinx Helper** is a framework used in **MeloNX** to bridge the gap between iOS and C#. + +### Features +- `showAlert(const char *title, const char *message, bool showCancel)` – Displays an alert with an optional cancel button. +- `showKeyboardAlert(const char *title, const char *message, const char *placeholder)` – Presents a keyboard input prompt with a placeholder. +- `const char *getKeyboardInput()` – Retrieves the user's keyboard input. +- `clearKeyboardInput()` – Clears the stored keyboard input. + diff --git a/RyujinxHelper.xcodeproj/project.pbxproj b/RyujinxHelper.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a2ce969 --- /dev/null +++ b/RyujinxHelper.xcodeproj/project.pbxproj @@ -0,0 +1,381 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 4E7023CD2D5AE490002C7183 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E7023CC2D5AE490002C7183 /* UIKit.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 4E7023B12D5AD5FB002C7183 /* RyujinxHelper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RyujinxHelper.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4E7023CC2D5AE490002C7183 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 4E7023B82D5AD5FB002C7183 /* Exceptions for "RyujinxHelper" folder in "RyujinxHelper" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + publicHeaders = ( + RyujinxHelper.h, + ); + target = 4E7023B02D5AD5FB002C7183 /* RyujinxHelper */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 4E7023B32D5AD5FB002C7183 /* RyujinxHelper */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 4E7023B82D5AD5FB002C7183 /* Exceptions for "RyujinxHelper" folder in "RyujinxHelper" target */, + ); + path = RyujinxHelper; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4E7023AE2D5AD5FB002C7183 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4E7023CD2D5AE490002C7183 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4E7023A72D5AD5FB002C7183 = { + isa = PBXGroup; + children = ( + 4E7023B32D5AD5FB002C7183 /* RyujinxHelper */, + 4E7023CB2D5AE490002C7183 /* Frameworks */, + 4E7023B22D5AD5FB002C7183 /* Products */, + ); + sourceTree = ""; + }; + 4E7023B22D5AD5FB002C7183 /* Products */ = { + isa = PBXGroup; + children = ( + 4E7023B12D5AD5FB002C7183 /* RyujinxHelper.framework */, + ); + name = Products; + sourceTree = ""; + }; + 4E7023CB2D5AE490002C7183 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4E7023CC2D5AE490002C7183 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 4E7023AC2D5AD5FB002C7183 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 4E7023B02D5AD5FB002C7183 /* RyujinxHelper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4E7023B92D5AD5FB002C7183 /* Build configuration list for PBXNativeTarget "RyujinxHelper" */; + buildPhases = ( + 4E7023AC2D5AD5FB002C7183 /* Headers */, + 4E7023AD2D5AD5FB002C7183 /* Sources */, + 4E7023AE2D5AD5FB002C7183 /* Frameworks */, + 4E7023AF2D5AD5FB002C7183 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 4E7023B32D5AD5FB002C7183 /* RyujinxHelper */, + ); + name = RyujinxHelper; + packageProductDependencies = ( + ); + productName = RyujinxKeyboard; + productReference = 4E7023B12D5AD5FB002C7183 /* RyujinxHelper.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4E7023A82D5AD5FB002C7183 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1620; + TargetAttributes = { + 4E7023B02D5AD5FB002C7183 = { + CreatedOnToolsVersion = 16.2; + }; + }; + }; + buildConfigurationList = 4E7023AB2D5AD5FB002C7183 /* Build configuration list for PBXProject "RyujinxHelper" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 4E7023A72D5AD5FB002C7183; + minimizedProjectReferenceProxies = 1; + preferredProjectObjectVersion = 77; + productRefGroup = 4E7023B22D5AD5FB002C7183 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4E7023B02D5AD5FB002C7183 /* RyujinxHelper */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 4E7023AF2D5AD5FB002C7183 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4E7023AD2D5AD5FB002C7183 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4E7023BA2D5AD5FB002C7183 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 95J8WZ4TN8; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.RyujinxKeyboard; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 4E7023BB2D5AD5FB002C7183 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUILD_LIBRARY_FOR_DISTRIBUTION = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 95J8WZ4TN8; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_MODULE_VERIFIER = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; + MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; + PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.RyujinxKeyboard; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_INSTALL_OBJC_HEADER = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 4E7023BC2D5AD5FB002C7183 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 4E7023BD2D5AD5FB002C7183 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4E7023AB2D5AD5FB002C7183 /* Build configuration list for PBXProject "RyujinxHelper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4E7023BC2D5AD5FB002C7183 /* Debug */, + 4E7023BD2D5AD5FB002C7183 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4E7023B92D5AD5FB002C7183 /* Build configuration list for PBXNativeTarget "RyujinxHelper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4E7023BA2D5AD5FB002C7183 /* Debug */, + 4E7023BB2D5AD5FB002C7183 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4E7023A82D5AD5FB002C7183 /* Project object */; +} diff --git a/RyujinxHelper.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/RyujinxHelper.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/RyujinxHelper.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate b/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..7745554 Binary files /dev/null and b/RyujinxHelper.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist b/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..968f09a --- /dev/null +++ b/RyujinxHelper.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + RyujinxKeyboard.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/RyujinxHelper/RyujinxHelper.docc/RyujinxKeyboard.md b/RyujinxHelper/RyujinxHelper.docc/RyujinxKeyboard.md new file mode 100644 index 0000000..fea4637 --- /dev/null +++ b/RyujinxHelper/RyujinxHelper.docc/RyujinxKeyboard.md @@ -0,0 +1,13 @@ +# ``RyujinxKeyboard`` + +Summary + +## Overview + +Text + +## Topics + +### Group + +- ``Symbol`` \ No newline at end of file diff --git a/RyujinxHelper/RyujinxHelper.h b/RyujinxHelper/RyujinxHelper.h new file mode 100644 index 0000000..1ef86b4 --- /dev/null +++ b/RyujinxHelper/RyujinxHelper.h @@ -0,0 +1,18 @@ +// +// RyujinxKeyboard.h +// RyujinxKeyboard +// +// Created by Stossy11 on 11/02/2025. +// + +#import + +//! Project version number for RyujinxKeyboard. +FOUNDATION_EXPORT double RyujinxKeyboardVersionNumber; + +//! Project version string for RyujinxKeyboard. +FOUNDATION_EXPORT const unsigned char RyujinxKeyboardVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/RyujinxHelper/main.h b/RyujinxHelper/main.h new file mode 100644 index 0000000..d3ceb1a --- /dev/null +++ b/RyujinxHelper/main.h @@ -0,0 +1,22 @@ +// +// main.h +// RyujinxKeyboard +// +// Created by Stossy11 on 11/02/2025. +// + +#ifdef __cplusplus +extern "C" { +#endif + +void showAlert(const char *title, const char *message, bool showCancel); + +void showKeyboardAlert(const char *title, const char *message, const char *placeholder); + +const char *getKeyboardInput(); + +void clearKeyboardInput(); + +#ifdef __cplusplus +} +#endif diff --git a/RyujinxHelper/main.mm b/RyujinxHelper/main.mm new file mode 100644 index 0000000..a3de801 --- /dev/null +++ b/RyujinxHelper/main.mm @@ -0,0 +1,142 @@ +// +// main.mm +// RyujinxKeyboard +// +// Created by Stossy11 on 11/02/2025. +// + +#import +#import + +#ifdef __cplusplus +extern "C" { +#endif + +static char *keyboardInput = NULL; + +void showKeyboardAlert(const char *title, const char *message, const char *placeholder) { + NSString *alertTitle = [NSString stringWithUTF8String:title]; + NSString *alertMessage = [NSString stringWithUTF8String:message]; + NSString *alertPlaceholder = [NSString stringWithUTF8String:placeholder]; + + dispatch_async(dispatch_get_main_queue(), ^{ + UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; + if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { + return; + } + + UIWindow *popupWindow = [[UIWindow alloc] initWithWindowScene:activeScene]; + popupWindow.frame = UIScreen.mainScreen.bounds; + popupWindow.windowLevel = UIWindowLevelAlert + 1; + popupWindow.backgroundColor = [UIColor clearColor]; + + UIViewController *tempViewController = [[UIViewController alloc] init]; + popupWindow.rootViewController = tempViewController; + [popupWindow makeKeyAndVisible]; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle + message:alertMessage + preferredStyle:UIAlertControllerStyleAlert]; + + [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { + textField.placeholder = alertPlaceholder; + }]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + NSString *inputText = alertController.textFields.firstObject.text; + + if (keyboardInput) { + free(keyboardInput); + keyboardInput = NULL; + } + + if (inputText.length > 0) { + keyboardInput = strdup([inputText UTF8String]); + } + + popupWindow.hidden = YES; + popupWindow.rootViewController = nil; + }]; + + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + free(keyboardInput); + keyboardInput = strdup(""); + + popupWindow.hidden = YES; + popupWindow.rootViewController = nil; + }]; + + [alertController addAction:okAction]; + [alertController addAction:cancelAction]; + + [tempViewController presentViewController:alertController animated:YES completion:nil]; + }); +} + +void showAlert(const char *title, const char *message, bool showCancel) { + NSString *alertTitle = [NSString stringWithUTF8String:title]; + NSString *alertMessage = [NSString stringWithUTF8String:message]; + + dispatch_async(dispatch_get_main_queue(), ^{ + UIWindowScene *activeScene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; + if (!activeScene || ![activeScene isKindOfClass:[UIWindowScene class]]) { + return; + } + + UIWindow *popupWindow = [[UIWindow alloc] initWithWindowScene:activeScene]; + popupWindow.frame = UIScreen.mainScreen.bounds; + popupWindow.windowLevel = UIWindowLevelAlert + 1; + popupWindow.backgroundColor = [UIColor clearColor]; + + UIViewController *tempViewController = [[UIViewController alloc] init]; + popupWindow.rootViewController = tempViewController; + [popupWindow makeKeyAndVisible]; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle + message:alertMessage + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + popupWindow.hidden = YES; + popupWindow.rootViewController = nil; + }]; + + [alertController addAction:okAction]; + + if (showCancel) { + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + popupWindow.hidden = YES; + popupWindow.rootViewController = nil; + }]; + [alertController addAction:cancelAction]; + } + + [tempViewController presentViewController:alertController animated:YES completion:nil]; + }); +} + +const char *getKeyboardInput() { + if (keyboardInput) { + return keyboardInput; + } + return NULL; +} + +void clearKeyboardInput() { + if (keyboardInput) { + free(keyboardInput); + keyboardInput = NULL; + } +} + +#ifdef __cplusplus +} +#endif