Add RARCH_MAIN_CTL_SET_LIBRETRO_PATH/RARCH_MAIN_CTL_SET_CONTENT_PATH

This commit is contained in:
twinaphex 2015-11-18 11:15:23 +01:00
parent e27d533fcd
commit 2b727fa941
9 changed files with 47 additions and 42 deletions

View File

@ -784,8 +784,7 @@ static void config_set_defaults(void)
fill_pathname_expand_special(settings->libretro_directory,
g_defaults.dir.core, sizeof(settings->libretro_directory));
if (*g_defaults.path.core)
strlcpy(settings->libretro, g_defaults.path.core,
sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, g_defaults.path.core);
if (*g_defaults.dir.database)
strlcpy(settings->content_database, g_defaults.dir.database,
sizeof(settings->content_database));

View File

@ -1284,11 +1284,9 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_LIBRETRO_PATH:
RARCH_LOG("Environ (Private) SET_LIBRETRO_PATH.\n");
if (path_file_exists((const char*)data))
strlcpy(settings->libretro, (const char*)data,
sizeof(settings->libretro));
else
if (!path_file_exists((const char*)data))
return false;
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, data);
break;
case RETRO_ENVIRONMENT_EXEC:
@ -1297,8 +1295,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
*global->path.fullpath = '\0';
if (data)
strlcpy(global->path.fullpath, (const char*)data,
sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, data);
}
#if defined(RARCH_CONSOLE)

View File

@ -320,9 +320,6 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
enum event_command cmd = EVENT_CMD_NONE;
bool do_wm_close = false;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
(void)global;
switch (mode)
{
@ -352,11 +349,11 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
switch (mode)
{
case ID_M_LOAD_CORE:
strlcpy(settings->libretro, win32_file, sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, win32_file);
cmd = EVENT_CMD_LOAD_CORE;
break;
case ID_M_LOAD_CONTENT:
strlcpy(global->path.fullpath, win32_file, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, win32_file);
cmd = EVENT_CMD_LOAD_CONTENT;
do_wm_close = true;
break;
@ -411,6 +408,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
default:
if (mode >= ID_M_WINDOW_SCALE_1X && mode <= ID_M_WINDOW_SCALE_10X)
{
global_t *global = global_get_ptr();
unsigned idx = (mode - (ID_M_WINDOW_SCALE_1X-1));
global->pending.windowed_scale = idx;
cmd = EVENT_CMD_RESIZE_WINDOWED_SCALE;

View File

@ -636,7 +636,7 @@ static int generic_action_ok(const char *path,
case ACTION_OK_LOAD_CORE:
flush_char = NULL;
flush_type = MENU_SETTINGS;
strlcpy(settings->libretro, action_path, sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, action_path);
event_command(EVENT_CMD_LOAD_CORE);
#if defined(HAVE_DYNAMIC)
@ -1346,8 +1346,7 @@ static int action_ok_file_load_or_resume(const char *path,
if (!strcmp(menu->deferred_path, global->path.fullpath))
return generic_action_ok_command(EVENT_CMD_RESUME);
strlcpy(global->path.fullpath,
menu->deferred_path, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, menu->deferred_path);
event_command(EVENT_CMD_LOAD_CORE);
rarch_ctl(RARCH_ACTION_STATE_LOAD_CONTENT, NULL);

View File

@ -127,18 +127,16 @@ int menu_common_load_content(
const char *core_path, const char *fullpath,
bool persist, enum rarch_core_type type)
{
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
enum event_command cmd = EVENT_CMD_NONE;
if (core_path)
{
strlcpy(settings->libretro, core_path, sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, (void*)core_path);
event_command(EVENT_CMD_LOAD_CORE);
}
if (fullpath)
strlcpy(global->path.fullpath, fullpath, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, (void*)fullpath);
switch (type)
{

View File

@ -246,7 +246,7 @@ static void set_basename(const char *path)
char *dst = NULL;
global_t *global = global_get_ptr();
strlcpy(global->path.fullpath, path, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, (void*)path);
strlcpy(global->name.base, path, sizeof(global->name.base));
#ifdef HAVE_COMPRESSION
@ -725,8 +725,7 @@ static void parse_input(int argc, char *argv[])
}
else
{
strlcpy(settings->libretro, optarg,
sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, optarg);
global->has_set.libretro = true;
}
break;
@ -1545,7 +1544,7 @@ void rarch_playlist_load_content(void *data, unsigned idx)
free(path_check);
}
strlcpy(settings->libretro, core_path, sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, (void*)core_path);
#ifdef HAVE_MENU
if (menu)
@ -1622,10 +1621,9 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir,
if (supported != 1)
return 0;
strlcpy(global->path.fullpath, s, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, s);
if (path_file_exists(new_core_path))
strlcpy(settings->libretro, new_core_path,
sizeof(settings->libretro));
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, new_core_path);
return -1;
}

View File

@ -317,6 +317,22 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
switch (state)
{
case RARCH_MAIN_CTL_SET_LIBRETRO_PATH:
{
const char *fullpath = (const char*)data;
if (!fullpath)
return false;
strlcpy(settings->libretro, fullpath, sizeof(settings->libretro));
}
break;
case RARCH_MAIN_CTL_SET_CONTENT_PATH:
{
const char *fullpath = (const char*)data;
if (!fullpath)
return false;
strlcpy(global->path.fullpath, fullpath, sizeof(global->path.fullpath));
}
break;
case RARCH_MAIN_CTL_CHECK_STATE:
{
event_cmd_state_t *cmd = (event_cmd_state_t*)data;

View File

@ -38,6 +38,8 @@ enum rarch_main_ctl_state
{
RARCH_MAIN_CTL_IS_IDLE = 0,
RARCH_MAIN_CTL_SET_IDLE,
RARCH_MAIN_CTL_SET_CONTENT_PATH,
RARCH_MAIN_CTL_SET_LIBRETRO_PATH,
RARCH_MAIN_CTL_IS_SLOWMOTION,
RARCH_MAIN_CTL_SET_SLOWMOTION,
RARCH_MAIN_CTL_IS_PAUSED,

View File

@ -276,8 +276,7 @@ extern void action_ok_push_quick_menu(void);
NSString *__core = [filenames objectAtIndex:0];
const char *core_name = global ? global->menu.info.library_name : NULL;
if (global)
strlcpy(global->path.fullpath, __core.UTF8String, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, __core.UTF8String);
if (core_name)
ui_companion_event_command(EVENT_CMD_LOAD_CONTENT);
@ -308,17 +307,17 @@ extern void action_ok_push_quick_menu(void);
if (__core)
{
strlcpy(settings->libretro, __core.UTF8String, sizeof(settings->libretro));
ui_companion_event_command(EVENT_CMD_LOAD_CORE);
if (menu->load_no_content && settings->core.set_supports_no_game_enable)
{
int ret = 0;
*global->path.fullpath = '\0';
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();
}
rarch_main_ctl(RARCH_MAIN_CTL_SET_LIBRETRO_PATH, __core.UTF8String);
ui_companion_event_command(EVENT_CMD_LOAD_CORE);
if (menu->load_no_content && settings->core.set_supports_no_game_enable)
{
int ret = 0;
*global->path.fullpath = '\0';
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();
}
}
}
}];
@ -343,8 +342,7 @@ extern void action_ok_push_quick_menu(void);
NSString *__core = url.path;
const char *core_name = global ? global->menu.info.library_name : NULL;
if (global)
strlcpy(global->path.fullpath, __core.UTF8String, sizeof(global->path.fullpath));
rarch_main_ctl(RARCH_MAIN_CTL_SET_CONTENT_PATH, __core.UTF8String);
if (core_name)
ui_companion_event_command(EVENT_CMD_LOAD_CONTENT);