(OSX) Use more sane default config path.

This commit is contained in:
meancoot 2014-01-03 17:16:02 -05:00
parent 79cd808e81
commit b5ea9b4eb9
3 changed files with 71 additions and 31 deletions

View File

@ -73,6 +73,9 @@ static void* const associated_core_key = (void*)&associated_core_key;
@end
static int waiting_argc;
static char** waiting_argv;
@interface RetroArch_OSX()
@property (nonatomic, retain) NSWindowController* settingsWindow;
@property (nonatomic, retain) NSWindow IBOutlet* coreSelectSheet;
@ -146,14 +149,21 @@ static void* const associated_core_key = (void*)&associated_core_key;
else
apple_display_alert(@"No libretro cores were found.\nSelect \"Go->Cores Directory\" from the menu and place libretro dylib files there.", @"RetroArch");
// Run RGUI if needed
if (!_wantReload)//TODO || apple_argv)
if (waiting_argc)
{
apple_is_running = true;
apple_rarch_load_content(waiting_argc, waiting_argv);
}
else if (!_wantReload)
apple_run_core(nil, 0);
else
[self chooseCore];
waiting_argc = 0;
_wantReload = false;
apple_start_iteration();
extern void osx_pad_init();
osx_pad_init();
}
@ -247,14 +257,10 @@ static void* const associated_core_key = (void*)&associated_core_key;
{
if (file)
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:BOXSTRING(file)]];
apple_start_iteration();
}
- (void)unloadingCore:(const NSString*)core
{
apple_stop_iteration();
if (_isTerminating)
[[NSApplication sharedApplication] terminate:nil];
@ -294,24 +300,13 @@ static void* const associated_core_key = (void*)&associated_core_key;
int main(int argc, char *argv[])
{
/* TODO
uint32_t current_argc = 0;
for (int i = 0; i != argc; i ++)
{
if (strcmp(argv[i], "--") == 0)
{
current_argc = 1;
apple_argv = malloc(sizeof(char*) * (argc + 1));
memset(apple_argv, 0, sizeof(char*) * (argc + 1));
apple_argv[0] = argv[0];
waiting_argc = argc - i;
waiting_argv = argv + i;
break;
}
else if (current_argc)
{
apple_argv[current_argc ++] = argv[i];
}
}
*/
return NSApplicationMain(argc, (const char **) argv);
}

View File

@ -96,11 +96,19 @@ void apple_run_core(NSString* core, const char* file)
apple_core = core;
apple_is_running = true;
static char core_path[PATH_MAX];
static char file_path[PATH_MAX];
if (file && core)
{
strlcpy(core_path, apple_core.UTF8String, sizeof(core_path));
strlcpy(file_path, file, sizeof(file_path));
}
#ifdef IOS
static char config_path[PATH_MAX];
static char core_path[PATH_MAX];
static char file_path[PATH_MAX];
if (apple_core_info_has_custom_config(apple_core.UTF8String))
apple_core_info_get_custom_config(apple_core.UTF8String, config_path, sizeof(config_path));
else
@ -109,15 +117,16 @@ void apple_run_core(NSString* core, const char* file)
static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };
if (file && core)
{
strlcpy(core_path, apple_core.UTF8String, sizeof(core_path));
strlcpy(file_path, file, sizeof(file_path));
}
int argc = (file && core) ? 6 : 4;
char** argv = (char**)((file && core) ? argv_game : argv_menu);
#else
static const char* const argv_game[] = { "retroarch", "-L", core_path, file_path, 0 };
static const char* const argv_menu[] = { "retroarch", "--menu", 0 };
int argc = (file && core) ? 4 : 2;
char** argv = (char**)((file && core) ? argv_game : argv_menu);
#endif
if (apple_rarch_load_content(argc, argv))
{
char basedir[256];

View File

@ -540,6 +540,42 @@ static config_file_t *open_default_config_file(void)
if (conf)
strlcpy(g_extern.config_path, conf_path, sizeof(g_extern.config_path));
#elif defined(OSX)
char conf_path[PATH_MAX];
const char *home = getenv("HOME");
if (!home)
return NULL;
fill_pathname_join(conf_path, home, "Library/Application Support/RetroArch", sizeof(conf_path));
path_mkdir(conf_path);
fill_pathname_join(conf_path, conf_path, "retroarch.cfg", sizeof(conf_path));
conf = config_file_new(conf_path);
if (!conf)
{
conf = config_file_new(NULL);
bool saved = false;
if (conf)
{
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path);
}
if (saved)
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); // WARN here to make sure user has a good chance of seeing it.
else
{
RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
config_file_free(conf);
conf = NULL;
}
}
if (conf)
strlcpy(g_extern.config_path, conf_path, sizeof(g_extern.config_path));
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
char conf_path[PATH_MAX];
const char *xdg = getenv("XDG_CONFIG_HOME");