From 1d727e50e755114da7f323795eb5c48d69afa98a Mon Sep 17 00:00:00 2001 From: meancoot Date: Wed, 6 Feb 2013 13:10:07 -0500 Subject: [PATCH] ios: Will load a file named 'overlay.cfg' stored in the bundles root directory. --- ios/RetroArch.xcodeproj/project.pbxproj | 8 +++++++- ios/RetroArch/AppDelegate.m | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ios/RetroArch.xcodeproj/project.pbxproj b/ios/RetroArch.xcodeproj/project.pbxproj index 4083c2357a..3e64c0ea4e 100644 --- a/ios/RetroArch.xcodeproj/project.pbxproj +++ b/ios/RetroArch.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 96AFAFD716C1FBC0009DE44C /* null.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCD16C1FBC0009DE44C /* null.c */; }; 96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */; }; 96CF014F16C2BB9E00ABF9C9 /* libretro.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 96CF014A16C2BA1900ABF9C9 /* libretro.dylib */; }; + 96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCE16C1FBC0009DE44C /* overlay.c */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -635,8 +636,8 @@ children = ( 96AFAFC816C1FBC0009DE44C /* dinput.c */, 96AFAFC916C1FBC0009DE44C /* input_common.c */, - 96AFAFCA16C1FBC0009DE44C /* input_common.h */, 96AFAFCB16C1FBC0009DE44C /* linuxraw_input.c */, + 96AFAFCA16C1FBC0009DE44C /* input_common.h */, 96AFAFCC16C1FBC0009DE44C /* linuxraw_joypad.c */, 96AFAFCD16C1FBC0009DE44C /* null.c */, 96AFAFCE16C1FBC0009DE44C /* overlay.c */, @@ -767,6 +768,7 @@ 96AFAFD416C1FBC0009DE44C /* input_common.c in Sources */, 96AFAFD716C1FBC0009DE44C /* null.c in Sources */, 96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */, + 96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -920,6 +922,8 @@ "-DHAVE_AL", "-DHAVE_NULLINPUT", "-DHAVE_DYNAMIC", + "-DHAVE_OVERLAY", + "-DHAVE_ZLIB", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; @@ -956,6 +960,8 @@ "-DHAVE_AL", "-DHAVE_NULLINPUT", "-DHAVE_DYNAMIC", + "-DHAVE_OVERLAY", + "-DHAVE_ZLIB", ); PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; diff --git a/ios/RetroArch/AppDelegate.m b/ios/RetroArch/AppDelegate.m index 250fc1942b..2cf0f201bc 100644 --- a/ios/RetroArch/AppDelegate.m +++ b/ios/RetroArch/AppDelegate.m @@ -13,15 +13,33 @@ @implementation AppDelegate +- (const char*)generate_config +{ + const char* overlay = [[[NSBundle mainBundle] pathForResource:@"overlay" ofType:@"cfg"] UTF8String]; + const char* config = [[NSTemporaryDirectory() stringByAppendingPathComponent: @"retroarch.cfg"] UTF8String]; + + FILE* config_file = fopen(config, "wb"); + + if (config_file) + { + if (overlay) fprintf(config_file, "input_overlay = \"%s\"\n", overlay); + fclose(config_file); + return config; + } + + return 0; +} + - (void)runMain:(id)sender { const char* filename = [[[NSBundle mainBundle] pathForResource:@"test" ofType:@"img"] UTF8String]; const char* libretro = [[[NSBundle mainBundle] pathForResource:@"libretro" ofType:@"dylib"] UTF8String]; + const char* config_file = [self generate_config]; - printf("%s\n", libretro); + if (!config_file) return; - const char* argv[] = {"retroarch", "-L", libretro, filename, 0}; - if (rarch_main_init(4, (char**)argv) == 0) + const char* argv[] = {"retroarch", "-L", libretro, "-c", config_file, filename, 0}; + if (rarch_main_init(6, (char**)argv) == 0) { rarch_init_msg_queue(); while (rarch_main_iterate());