From 2ad30883bb939611a1c959d6b1be1fd9805fd838 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 5 Aug 2025 00:58:28 +0200 Subject: [PATCH] ios fixes --- base/project.js | 1 - .../backends/data/LaunchScreen.storyboard | 27 -- base/sources/backends/data/ios.plist | 26 +- base/sources/backends/ios_file_dialog.m | 6 +- base/sources/backends/ios_system.h | 30 +- base/sources/backends/ios_system.m | 405 +++++++----------- base/sources/backends/macos_system.m | 8 +- base/sources/iron_system.c | 4 +- base/sources/libs/kong/backends/util.c | 4 + base/tools/make.js | 4 +- 10 files changed, 198 insertions(+), 317 deletions(-) delete mode 100644 base/sources/backends/data/LaunchScreen.storyboard diff --git a/base/project.js b/base/project.js index 8ce250f8..bc3a6743 100644 --- a/base/project.js +++ b/base/project.js @@ -191,7 +191,6 @@ if (!flags.lite) { add_thread_backend("apple"); add_gpu_backend("metal"); project.add_cfiles("sources/backends/data/ios.plist"); - project.add_cfiles("sources/backends/data/LaunchScreen.storyboard"); project.add_cfiles("sources/backends/ios_file_dialog.m"); project.add_define("IRON_METAL"); } diff --git a/base/sources/backends/data/LaunchScreen.storyboard b/base/sources/backends/data/LaunchScreen.storyboard deleted file mode 100644 index 542ecd9e..00000000 --- a/base/sources/backends/data/LaunchScreen.storyboard +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/base/sources/backends/data/ios.plist b/base/sources/backends/data/ios.plist index 6c410ad7..2bd46bcf 100644 --- a/base/sources/backends/data/ios.plist +++ b/base/sources/backends/data/ios.plist @@ -26,11 +26,9 @@ UIFileSharingEnabled - UILaunchStoryboardName - LaunchScreen UIRequiredDeviceCapabilities - armv7 + arm64 UIStatusBarHidden @@ -49,5 +47,27 @@ UIViewControllerBasedStatusBarAppearance + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + IronSceneDelegate + + + + + UILaunchScreen + + UIColorName + Black + diff --git a/base/sources/backends/ios_file_dialog.m b/base/sources/backends/ios_file_dialog.m index a6805394..d67b98b0 100644 --- a/base/sources/backends/ios_file_dialog.m +++ b/base/sources/backends/ios_file_dialog.m @@ -3,11 +3,11 @@ #import void IOSFileDialogOpen() { - UIViewController *glViewController = [UIApplication sharedApplication].keyWindow.rootViewController; + UIViewController *myViewController = [UIApplication sharedApplication].keyWindow.rootViewController; UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"] inMode:UIDocumentPickerModeOpen]; - documentPicker.delegate = glViewController; + documentPicker.delegate = myViewController; documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; - [glViewController presentViewController:documentPicker animated:YES completion:nil]; + [myViewController presentViewController:documentPicker animated:YES completion:nil]; } wchar_t* IOSFileDialogSave() { diff --git a/base/sources/backends/ios_system.h b/base/sources/backends/ios_system.h index 38f9ff35..b6e5554a 100644 --- a/base/sources/backends/ios_system.h +++ b/base/sources/backends/ios_system.h @@ -4,9 +4,7 @@ #import #import -struct gpu_texture; - -@interface GLView : UIView { +@interface MyView : UIView { @private id device; id commandQueue; @@ -15,12 +13,10 @@ struct gpu_texture; id drawable; id library; MTLRenderPassDescriptor *renderPassDescriptor; - CMMotionManager *motionManager; bool hasAccelerometer; float lastAccelerometerX, lastAccelerometerY, lastAccelerometerZ; } - - (void)begin; - (void)end; - (void)showKeyboard; @@ -28,28 +24,18 @@ struct gpu_texture; - (CAMetalLayer *)metalLayer; - (id)metalDevice; - (id)metalQueue; - +- (BOOL)hasText; +- (void)insertText:(NSString *)text; +- (void)deleteBackward; @end -@interface GLViewController : UIViewController { -@private -} - +@interface MyViewController : UIViewController {} - (void)loadView; - - (void)setVisible:(BOOL)value; - +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures; @end -@class GLView; - -@interface IronAppDelegate : NSObject { -} - -@end - -@interface Motion : NSObject { - -} +@interface IronSceneDelegate : UIResponder {} +@property (strong, nonatomic) UIWindow *window; @end diff --git a/base/sources/backends/ios_system.m b/base/sources/backends/ios_system.m index fa7c43c4..a74f789c 100644 --- a/base/sources/backends/ios_system.m +++ b/base/sources/backends/ios_system.m @@ -1,34 +1,42 @@ #include "ios_system.h" +#include #include #include -#import #include #include -#import -#include -#import -#include -#import #include +#import +#import -static const int touchmaxcount = 20; +#define touchmaxcount 20 + +extern char mobile_title[1024]; static void *touches[touchmaxcount]; +static int backing_width; +static int backing_height; +static bool shift_down = false; +static bool visible; +static MyView *myView; +static MyViewController *myViewController; +static bool keyboard_shown = false; +static char language[3]; +static char sysid[512]; +static const char *video_formats[] = {"mp4", NULL}; +static void (*resize_callback)(int x, int y, void *data) = NULL; +static void *resize_callback_data = NULL; -static void initTouches(void) { - for (int i = 0; i < touchmaxcount; ++i) { - touches[i] = NULL; - } -} +void iron_internal_call_resize_callback(int width, int height); -static int getTouchIndex(void *touch) { +static int get_touch_index(void *touch) { for (int i = 0; i < touchmaxcount; ++i) { - if (touches[i] == touch) + if (touches[i] == touch) { return i; + } } return -1; } -static int addTouch(void *touch) { +static int add_touch(void *touch) { for (int i = 0; i < touchmaxcount; ++i) { if (touches[i] == NULL) { touches[i] = touch; @@ -38,7 +46,7 @@ static int addTouch(void *touch) { return -1; } -static int removeTouch(void *touch) { +static int remove_touch(void *touch) { for (int i = 0; i < touchmaxcount; ++i) { if (touches[i] == touch) { touches[i] = NULL; @@ -48,17 +56,15 @@ static int removeTouch(void *touch) { return -1; } -static GLint backingWidth, backingHeight; - int iron_window_width() { - return backingWidth; + return backing_width; } int iron_window_height() { - return backingHeight; + return backing_height; } -@implementation GLView +@implementation MyView + (Class)layerClass { return [CAMetalLayer class]; @@ -68,62 +74,52 @@ int iron_window_height() { CGPoint point = [recognizer locationInView:self]; float x = point.x * self.contentScaleFactor; float y = point.y * self.contentScaleFactor; - // Pencil hover - iron_internal_pen_trigger_move(x, y, 0.0); + iron_internal_pen_trigger_move(x, y, 0.0); // Pencil hover } - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:(CGRect)frame]; self.contentScaleFactor = [UIScreen mainScreen].scale; + backing_width = frame.size.width * self.contentScaleFactor; + backing_height = frame.size.height * self.contentScaleFactor; - backingWidth = frame.size.width * self.contentScaleFactor; - backingHeight = frame.size.height * self.contentScaleFactor; - - initTouches(); + for (int i = 0; i < touchmaxcount; ++i) { + touches[i] = NULL; + } device = MTLCreateSystemDefaultDevice(); commandQueue = [device newCommandQueue]; library = [device newDefaultLibrary]; CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer; - metalLayer.device = device; metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; metalLayer.framebufferOnly = YES; - // metalLayer.presentsWithTransaction = YES; - metalLayer.opaque = YES; metalLayer.backgroundColor = nil; [self addGestureRecognizer:[[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(hoverGesture:)]]; - return self; } -- (void)begin { -} - -- (void)end { -} - -void iron_internal_call_resize_callback(int width, int height); +- (void)begin {} +- (void)end {} +- (void)dealloc {} - (void)layoutSubviews { - backingWidth = self.frame.size.width * self.contentScaleFactor; - backingHeight = self.frame.size.height * self.contentScaleFactor; + backing_width = self.frame.size.width * self.contentScaleFactor; + backing_height = self.frame.size.height * self.contentScaleFactor; - gpu_resize(); - iron_internal_call_resize_callback(backingWidth, backingHeight); -} - -- (void)dealloc { + gpu_resize(backing_width, backing_height); + iron_internal_call_resize_callback(backing_width, backing_height); } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { - int index = getTouchIndex((__bridge void *)touch); - if (index == -1) - index = addTouch((__bridge void *)touch); + int index = get_touch_index((__bridge void *)touch); + if (index == -1) { + index = add_touch((__bridge void *)touch); + } if (index >= 0) { CGPoint point = [touch locationInView:self]; float x = point.x * self.contentScaleFactor; @@ -132,7 +128,6 @@ void iron_internal_call_resize_callback(int width, int height); iron_internal_mouse_trigger_press(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } iron_internal_surface_trigger_touch_start(index, x, y); - if (touch.type == UITouchTypePencil) { iron_internal_pen_trigger_press(x, y, 0.0); } @@ -142,7 +137,7 @@ void iron_internal_call_resize_callback(int width, int height); - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { - int index = getTouchIndex((__bridge void *)touch); + int index = get_touch_index((__bridge void *)touch); if (index >= 0) { CGPoint point = [touch locationInView:self]; float x = point.x * self.contentScaleFactor; @@ -168,7 +163,7 @@ void iron_internal_call_resize_callback(int width, int height); - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { - int index = removeTouch((__bridge void *)touch); + int index = remove_touch((__bridge void *)touch); if (index >= 0) { CGPoint point = [touch locationInView:self]; float x = point.x * self.contentScaleFactor; @@ -177,7 +172,6 @@ void iron_internal_call_resize_callback(int width, int height); iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } iron_internal_surface_trigger_touch_end(index, x, y); - if (touch.type == UITouchTypePencil) { iron_internal_pen_trigger_release(x, y, 0.0); } @@ -187,7 +181,7 @@ void iron_internal_call_resize_callback(int width, int height); - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { - int index = removeTouch((__bridge void *)touch); + int index = remove_touch((__bridge void *)touch); if (index >= 0) { CGPoint point = [touch locationInView:self]; float x = point.x * self.contentScaleFactor; @@ -196,7 +190,6 @@ void iron_internal_call_resize_callback(int width, int height); iron_internal_mouse_trigger_release(event.buttonMask == UIEventButtonMaskSecondary ? 1 : 0, x, y); } iron_internal_surface_trigger_touch_end(index, x, y); - if (touch.type == UITouchTypePencil) { iron_internal_pen_trigger_release(x, y, 0.0); } @@ -204,10 +197,6 @@ void iron_internal_call_resize_callback(int width, int height); } } -static NSString *keyboardstring; -static UITextField *myTextField = NULL; -static bool shiftDown = false; - - (void)showKeyboard { [self becomeFirstResponder]; } @@ -223,14 +212,14 @@ static bool shiftDown = false; - (void)insertText:(NSString *)text { if ([text length] == 1) { unichar ch = [text characterAtIndex:[text length] - 1]; - if (ch == 8212) + if (ch == 8212) { ch = '_'; + } if (ch == L'\n') { iron_internal_keyboard_trigger_key_down(IRON_KEY_RETURN); iron_internal_keyboard_trigger_key_up(IRON_KEY_RETURN); return; } - if (ch == L'.') { iron_internal_keyboard_trigger_key_down(IRON_KEY_PERIOD); iron_internal_keyboard_trigger_key_up(IRON_KEY_PERIOD); @@ -256,22 +245,21 @@ static bool shiftDown = false; iron_internal_keyboard_trigger_key_up(IRON_KEY_HASH); } else if (ch >= L'a' && ch <= L'z') { - if (shiftDown) { + if (shift_down) { iron_internal_keyboard_trigger_key_up(IRON_KEY_SHIFT); - shiftDown = false; + shift_down = false; } iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'a'); iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'a'); } else { - if (!shiftDown) { + if (!shift_down) { iron_internal_keyboard_trigger_key_down(IRON_KEY_SHIFT); - shiftDown = true; + shift_down = true; } iron_internal_keyboard_trigger_key_down(ch + IRON_KEY_A - L'A'); iron_internal_keyboard_trigger_key_up(ch + IRON_KEY_A - L'A'); } - iron_internal_keyboard_trigger_key_press(ch); } } @@ -303,49 +291,31 @@ static bool shiftDown = false; @end -static GLView *glView; -static bool visible; - -void beginGL(void) { - if (!visible) { - return; - } - [glView begin]; -} - -void endGL(void) { - if (!visible) { - return; - } - [glView end]; -} - void showKeyboard(void) { - [glView showKeyboard]; + [myView showKeyboard]; } void hideKeyboard(void) { - [glView hideKeyboard]; + [myView hideKeyboard]; } CAMetalLayer *getMetalLayer(void) { - return [glView metalLayer]; + return [myView metalLayer]; } id getMetalDevice(void) { - return [glView metalDevice]; + return [myView metalDevice]; } id getMetalQueue(void) { - return [glView metalQueue]; + return [myView metalQueue]; } -@implementation GLViewController +@implementation MyViewController - (void)loadView { visible = true; - self.view = glView = [[GLView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - + self.view = myView = [[MyView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.view addInteraction: [[UIDropInteraction alloc] initWithDelegate: self]]; [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; } @@ -354,10 +324,6 @@ id getMetalQueue(void) { visible = value; } -#include - -extern char mobile_title[1024]; - void importFile(NSURL *url) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *folderName = [NSString stringWithUTF8String:mobile_title]; @@ -386,11 +352,10 @@ void importFile(NSURL *url) { - (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id)session { CGPoint point = [session locationInView:self.view]; - float x = point.x * glView.contentScaleFactor; - float y = point.y * glView.contentScaleFactor; + float x = point.x * myView.contentScaleFactor; + float y = point.y * myView.contentScaleFactor; iron_internal_mouse_trigger_move(x, y); iron_internal_surface_trigger_move(0, x, y); - for (UIDragItem *item in session.items) { [item.itemProvider loadInPlaceFileRepresentationForTypeIdentifier:item.itemProvider.registeredTypeIdentifiers[0] completionHandler:^(NSURL * _Nullable url, BOOL isInPlace, NSError * _Nullable error) { importFile(url); @@ -402,17 +367,13 @@ void importFile(NSURL *url) { return [[UIDropProposal alloc] initWithDropOperation: UIDropOperationCopy]; } -- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures -{ +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { return UIRectEdgeAll; } @end -@implementation IronAppDelegate - -static UIWindow *window; -static GLViewController *glViewController; +@implementation IronSceneDelegate void loadURL(const char *url) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]; @@ -424,54 +385,53 @@ void loadURL(const char *url) { } } -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + #ifdef IRON_A2 AVAudioSession *sessionInstance = [AVAudioSession sharedInstance]; NSError *error; - - // set the session category NSString *category = AVAudioSessionCategoryAmbient; - bool success = [sessionInstance setCategory:category error:&error]; - if (!success) - NSLog(@"Error setting AVAudioSession category! %@\n", [error localizedDescription]); + [sessionInstance setCategory:category error:&error]; + #endif - window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - [window setBackgroundColor:[UIColor blackColor]]; + UIWindowScene *windowScene = (UIWindowScene *)scene; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + // self.window.frame = windowScene.coordinateSpace.bounds; + self.window.frame = [UIScreen mainScreen].bounds; + [self.window setBackgroundColor:[UIColor blackColor]]; - glViewController = [[GLViewController alloc] init]; - glViewController.view.multipleTouchEnabled = YES; - - [window setRootViewController:glViewController]; - [window makeKeyAndVisible]; + myViewController = [[MyViewController alloc] init]; + myViewController.view.multipleTouchEnabled = YES; + [self.window setRootViewController:myViewController]; + [self.window makeKeyAndVisible]; + [myViewController setVisible:YES]; + // iron_internal_foreground_callback(); [self performSelectorOnMainThread:@selector(mainLoop) withObject:nil waitUntilDone:NO]; - - return YES; } -void IronUpdateKeyboard(void); - -- (void)applicationWillEnterForeground:(UIApplication *)application { - [glViewController setVisible:YES]; - iron_internal_foreground_callback(); -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - iron_internal_resume_callback(); -} - -- (void)applicationWillResignActive:(UIApplication *)application { - iron_internal_pause_callback(); -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - [glViewController setVisible:NO]; - iron_internal_background_callback(); -} - -- (void)applicationWillTerminate:(UIApplication *)application { +- (void)sceneDidDisconnect:(UIScene *)scene { + [myViewController setVisible:NO]; iron_internal_shutdown_callback(); } +- (void)sceneDidBecomeActive:(UIScene *)scene { + iron_internal_resume_callback(); +} + +- (void)sceneWillResignActive:(UIScene *)scene { + iron_internal_pause_callback(); +} + +- (void)sceneWillEnterForeground:(UIScene *)scene { + [myViewController setVisible:YES]; + iron_internal_foreground_callback(); +} + +- (void)sceneDidEnterBackground:(UIScene *)scene { + [myViewController setVisible:NO]; + iron_internal_background_callback(); +} + @end void iron_display_init(void) {} @@ -493,12 +453,7 @@ int iron_primary_display(void) { return 0; } -@implementation Motion - -@end - void iron_internal_mouse_lock(void) {} - void iron_internal_mouse_unlock(void) {} bool iron_mouse_can_lock(void) { @@ -506,23 +461,17 @@ bool iron_mouse_can_lock(void) { } void iron_mouse_show(void) {} - void iron_mouse_hide(void) {} - void iron_mouse_set_position(int x, int y) {} - void iron_mouse_get_position(int *x, int *y) {} - void iron_mouse_set_cursor(int cursor_index) {} -bool withAutoreleasepool(bool (*f)(void)) { +bool with_autoreleasepool(bool (*f)(void)) { @autoreleasepool { return f(); } } -static bool keyboardshown = false; - const char *iphonegetresourcepath(void) { return [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:1]; } @@ -537,31 +486,24 @@ bool iron_internal_handle_messages(void) { void iron_set_keep_screen_on(bool on) {} -void showKeyboard(void); -void hideKeyboard(void); - void iron_keyboard_show(void) { - keyboardshown = true; + keyboard_shown = true; showKeyboard(); } void iron_keyboard_hide(void) { - keyboardshown = false; + keyboard_shown = false; hideKeyboard(); } bool iron_keyboard_active(void) { - return keyboardshown; + return keyboard_shown; } -void loadURL(const char *url); - void iron_load_url(const char *url) { loadURL(url); } -static char language[3]; - const char *iron_language(void) { NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0]; const char *lang = [nsstr UTF8String]; @@ -571,35 +513,17 @@ const char *iron_language(void) { return language; } -void IronUpdateKeyboard(void) { - if (keyboardshown) { - hideKeyboard(); - showKeyboard(); - } - else { - hideKeyboard(); - } -} - void iron_internal_shutdown(void) {} void iron_init(const char *name, int width, int height, struct iron_window_options *win) { - iron_window_options_t defaultWin; + iron_window_options_t default_win; if (win == NULL) { - iron_window_options_set_defaults(&defaultWin); - win = &defaultWin; + iron_window_options_set_defaults(&default_win); + win = &default_win; } gpu_init(win->depth_bits, true); } -void endGL(void); - -void swapBuffersiOS(void) { - endGL(); -} - -static char sysid[512]; - const char *iron_system_id(void) { const char *name = [[[UIDevice currentDevice] name] UTF8String]; const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String]; @@ -609,29 +533,20 @@ const char *iron_system_id(void) { return sysid; } -static const char *getSavePath(void) { +const char *iron_internal_save_path(void) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *resolvedPath = [paths objectAtIndex:0]; NSString *appName = [NSString stringWithUTF8String:iron_application_name()]; resolvedPath = [resolvedPath stringByAppendingPathComponent:appName]; - NSFileManager *fileMgr = [[NSFileManager alloc] init]; - NSError *error; [fileMgr createDirectoryAtPath:resolvedPath withIntermediateDirectories:YES attributes:nil error:&error]; - resolvedPath = [resolvedPath stringByAppendingString:@"/"]; return [resolvedPath cStringUsingEncoding:1]; } -const char *iron_internal_save_path(void) { - return getSavePath(); -} - -static const char *videoFormats[] = {"mp4", NULL}; - const char **iron_video_formats(void) { - return videoFormats; + return video_formats; } double iron_frequency(void) { @@ -645,6 +560,53 @@ uint64_t iron_timestamp(void) { return time; } +int main(int argc, char *argv[]) { + int res = 0; + @autoreleasepool { + [IronSceneDelegate description]; // otherwise removed by the linker + res = UIApplicationMain(argc, argv, nil, nil); + } + return res; +} + +int iron_window_x() { + return 0; +} + +int iron_window_y() { + return 0; +} + +void iron_window_resize(int width, int height) {} +void iron_window_move(int x, int y) {} +void iron_window_change_mode(iron_window_mode_t mode) {} +void iron_window_destroy() {} +void iron_window_show() {} +void iron_window_hide() {} +void iron_window_set_title(const char *title) {} +void iron_window_create(iron_window_options_t *win) {} + +void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { + resize_callback = callback; + resize_callback_data = data; +} + +void iron_internal_call_resize_callback(int width, int height) { + if (resize_callback != NULL) { + resize_callback(width, height, resize_callback_data); + } +} + +void iron_window_set_close_callback(bool (*callback)(void *), void *data) {} + +iron_window_mode_t iron_window_get_mode() { + return IRON_WINDOW_MODE_FULLSCREEN; +} + +int iron_window_display() { + return 0; +} + #ifdef WITH_GAMEPAD const char *iron_gamepad_vendor(int gamepad) { @@ -662,60 +624,3 @@ bool iron_gamepad_connected(int num) { void iron_gamepad_rumble(int gamepad, float left, float right) {} #endif - -int main(int argc, char *argv[]) { - int retVal = 0; - @autoreleasepool { - [IronAppDelegate description]; // otherwise removed by the linker - retVal = UIApplicationMain(argc, argv, nil, @"IronAppDelegate"); - } - return retVal; -} - -static void (*resizeCallback)(int x, int y, void *data) = NULL; -static void *resizeCallbackData = NULL; - -int iron_window_x() { - return 0; -} - -int iron_window_y() { - return 0; -} - -void iron_window_resize(int width, int height) {} - -void iron_window_move(int x, int y) {} - -void iron_window_change_mode(iron_window_mode_t mode) {} - -void iron_window_destroy() {} - -void iron_window_show() {} - -void iron_window_hide() {} - -void iron_window_set_title(const char *title) {} - -void iron_window_create(iron_window_options_t *win) {} - -void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) { - resizeCallback = callback; - resizeCallbackData = data; -} - -void iron_internal_call_resize_callback(int width, int height) { - if (resizeCallback != NULL) { - resizeCallback(width, height, resizeCallbackData); - } -} - -void iron_window_set_close_callback(bool (*callback)(void *), void *data) {} - -iron_window_mode_t iron_window_get_mode() { - return IRON_WINDOW_MODE_FULLSCREEN; -} - -int iron_window_display() { - return 0; -} diff --git a/base/sources/backends/macos_system.m b/base/sources/backends/macos_system.m index cdd94881..e9bfc4e3 100644 --- a/base/sources/backends/macos_system.m +++ b/base/sources/backends/macos_system.m @@ -892,7 +892,7 @@ void iron_gamepad_rumble(int gamepad, float left, float right) {} #endif -bool withAutoreleasepool(bool (*f)(void)) { +bool with_autoreleasepool(bool (*f)(void)) { @autoreleasepool { return f(); } @@ -1079,7 +1079,7 @@ const char *iron_language(void) { void iron_internal_shutdown(void) {} -static const char *getSavePath(void) { +const char *iron_internal_save_path(void) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *resolvedPath = [paths objectAtIndex:0]; NSString *appName = [NSString stringWithUTF8String:iron_application_name()]; @@ -1094,10 +1094,6 @@ static const char *getSavePath(void) { return [resolvedPath cStringUsingEncoding:NSUTF8StringEncoding]; } -const char *iron_internal_save_path(void) { - return getSavePath(); -} - #ifndef IRON_NO_MAIN int main(int argc, char **argv) { return kickstart(argc, argv); diff --git a/base/sources/iron_system.c b/base/sources/iron_system.c index 8e18279a..c1232a49 100644 --- a/base/sources/iron_system.c +++ b/base/sources/iron_system.c @@ -121,7 +121,7 @@ static void (*paste_callback)(char *, void *) = NULL; static void *paste_callback_data = NULL; #if defined(IRON_IOS) || defined(IRON_MACOS) -bool withAutoreleasepool(bool (*f)(void)); +bool with_autoreleasepool(bool (*f)(void)); #endif void iron_set_update_callback(void (*callback)(void *), void *data) { @@ -263,7 +263,7 @@ void iron_start(void) { #if !defined(IRON_WASM) #if defined(IRON_IOS) || defined(IRON_MACOS) - while (withAutoreleasepool(iron_internal_frame)) { + while (with_autoreleasepool(iron_internal_frame)) { } #else while (iron_internal_frame()) { diff --git a/base/sources/libs/kong/backends/util.c b/base/sources/libs/kong/backends/util.c index 9e50a073..66907a64 100644 --- a/base/sources/libs/kong/backends/util.c +++ b/base/sources/libs/kong/backends/util.c @@ -96,7 +96,11 @@ bool execute_sync(const char *command, uint32_t *exit_code) { return success != FALSE; #elif defined(__APPLE__) + #ifdef TARGET_OS_IPHONE + int status = -1; + #else int status = system(command); + #endif if (status < 0) { return false; diff --git a/base/tools/make.js b/base/tools/make.js index 0de2e52b..3b06e9cd 100644 --- a/base/tools/make.js +++ b/base/tools/make.js @@ -936,7 +936,7 @@ class File { } isBuildFile() { - return this.filename.endsWith(".c") || this.filename.endsWith(".cpp") || this.filename.endsWith(".m") || this.filename.endsWith(".mm") || this.filename.endsWith(".cc") || this.filename.endsWith(".metal") || this.filename.endsWith(".storyboard"); + return this.filename.endsWith(".c") || this.filename.endsWith(".cpp") || this.filename.endsWith(".m") || this.filename.endsWith(".mm") || this.filename.endsWith(".cc") || this.filename.endsWith(".metal"); } getName() { @@ -1196,8 +1196,6 @@ class XCodeExporter extends Exporter { for (let file of files) { let filetype = "unknown"; let fileencoding = ""; - if (file.getName().endsWith(".storyboard")) - filetype = "file.storyboard"; if (file.getName().endsWith(".plist")) filetype = "text.plist.xml"; if (file.getName().endsWith(".h"))