ios: Will load a file named 'overlay.cfg' stored in the bundles root directory.

This commit is contained in:
meancoot 2013-02-06 13:10:07 -05:00
parent 6ab845b795
commit 1d727e50e7
2 changed files with 28 additions and 4 deletions

View File

@ -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;

View File

@ -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());