Skip to content

Commit

Permalink
Add RARCH_MAIN_CTL_SET_LIBRETRO_PATH/RARCH_MAIN_CTL_SET_CONTENT_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Nov 18, 2015
1 parent e27d533 commit 2b727fa
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 42 deletions.
3 changes: 1 addition & 2 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 3 additions & 6 deletions dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions gfx/common/win32_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions menu/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 5 additions & 7 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
16 changes: 16 additions & 0 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions runloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 13 additions & 15 deletions ui/drivers/ui_cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
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);
Expand Down Expand Up @@ -308,17 +307,17 @@ - (IBAction)openCore:(id)sender {

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();
}
}
}
}];
Expand All @@ -343,8 +342,7 @@ - (void)openDocument:(id)sender
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);
Expand Down

0 comments on commit 2b727fa

Please sign in to comment.