1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Start wrapping settings->path.libretro

This commit is contained in:
twinaphex 2016-07-24 11:12:26 +02:00
parent 0a959ab047
commit 2be127c04a
9 changed files with 48 additions and 34 deletions

View File

@ -1448,8 +1448,8 @@ static bool command_event_save_core_config(void)
}
/* Infer file name based on libretro core. */
if (!string_is_empty(settings->path.libretro)
&& path_file_exists(settings->path.libretro))
if (!string_is_empty(config_get_active_core_path())
&& path_file_exists(config_get_active_core_path()))
{
unsigned i;
RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG));
@ -1461,7 +1461,7 @@ static bool command_event_save_core_config(void)
fill_pathname_base_noext(
config_name,
settings->path.libretro,
config_get_active_core_path(),
sizeof(config_name));
fill_pathname_join(config_path, config_dir, config_name,
@ -1791,17 +1791,17 @@ bool command_event(enum event_command cmd, void *data)
core_info_ctx_find_t info_find;
#if defined(HAVE_DYNAMIC)
if (string_is_empty(settings->path.libretro))
if (string_is_empty(config_get_active_core_path()))
return false;
libretro_get_system_info(
settings->path.libretro,
config_get_active_core_path(),
system,
ptr);
#else
libretro_get_system_info_static(system, ptr);
#endif
info_find.path = settings->path.libretro;
info_find.path = config_get_active_core_path();
if (!core_info_load(&info_find))
return false;

View File

@ -3146,6 +3146,22 @@ const char *config_get_active_core_path(void)
return settings->path.libretro;
}
void config_set_active_core_path(const char *path)
{
settings_t *settings = config_get_ptr();
if (!settings)
return;
strlcpy(settings->path.libretro, path, sizeof(settings->path.libretro));
}
void config_clear_active_core_path(void)
{
settings_t *settings = config_get_ptr();
if (!settings)
return;
*settings->path.libretro = '\0';
}
const char *config_get_active_path(void)
{
settings_t *settings = config_get_ptr();

View File

@ -600,6 +600,10 @@ const char *config_get_active_path(void);
const char *config_get_active_core_path(void);
void config_set_active_core_path(const char *path);
void config_clear_active_core_path(void);
void config_free_state(void);
settings_t *config_get_ptr(void);

View File

@ -322,7 +322,7 @@ static void load_dynamic_core(void)
retroarch_fail(1, "init_libretro_sym()");
}
if (string_is_empty(settings->path.libretro))
if (string_is_empty(config_get_active_core_path()))
{
RARCH_ERR("RetroArch is built for dynamic libretro cores, but "
"libretro_path is not set. Cannot continue.\n");
@ -335,12 +335,12 @@ static void load_dynamic_core(void)
path_resolve_realpath(settings->path.libretro, sizeof(settings->path.libretro));
RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n",
settings->path.libretro);
lib_handle = dylib_load(settings->path.libretro);
config_get_active_core_path());
lib_handle = dylib_load(config_get_active_core_path());
if (!lib_handle)
{
RARCH_ERR("Failed to open libretro core: \"%s\"\n",
settings->path.libretro);
config_get_active_core_path());
RARCH_ERR("Error(s): %s\n", dylib_error());
retroarch_fail(1, "load_dynamic()");
}

View File

@ -1872,10 +1872,8 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode)
{
char executable_path[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
fill_pathname_application_path(executable_path, sizeof(executable_path));
strlcpy(settings->path.libretro, executable_path, sizeof(settings->path.libretro));
config_set_active_core_path(executable_path);
}
command_event(CMD_EVENT_QUIT, NULL);
break;

View File

@ -236,10 +236,6 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
content_ctx_info_t content_info = {0};
core_info_list_t *core_info_list = NULL;
const core_info_t *core_info = NULL;
settings_t *settings = config_get_ptr();
if (!settings)
return 0;
DragQueryFile((HDROP)wparam, 0, szFilename, 1024);
@ -253,7 +249,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH,szFilename);
if (!string_is_empty(settings->path.libretro))
if (!string_is_empty(config_get_active_core_path()))
{
unsigned i;
core_info_t *current_core = NULL;
@ -267,7 +263,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
if(!string_is_equal(info->systemname, current_core->systemname))
break;
if(string_is_equal(settings->path.libretro, info->path))
if(string_is_equal(config_get_active_core_path(), info->path))
{
/* Our previous core supports the current rom */
content_ctx_info_t content_info = {0};
@ -318,7 +314,6 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
settings_t *settings = config_get_ptr();
if (message == WM_NCLBUTTONDBLCLK)
doubleclick_on_titlebar = true;
@ -374,8 +369,11 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
*quit = true;
break;
case WM_COMMAND:
if (settings->ui.menubar_enable)
win32_menu_loop(main_window.hwnd, wparam);
{
settings_t *settings = config_get_ptr();
if (settings->ui.menubar_enable)
win32_menu_loop(main_window.hwnd, wparam);
}
break;
}
return 0;
@ -433,7 +431,6 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message,
{
LRESULT ret;
bool quit = false;
settings_t *settings = config_get_ptr();
if (message == WM_NCLBUTTONDBLCLK)
doubleclick_on_titlebar = true;

View File

@ -846,7 +846,7 @@ static void retroarch_parse_input(int argc, char *argv[])
case 'L':
if (path_is_directory(optarg))
{
*settings->path.libretro = '\0';
config_clear_active_core_path();
strlcpy(settings->directory.libretro, optarg,
sizeof(settings->directory.libretro));
global->has_set.libretro = true;

View File

@ -741,7 +741,6 @@ static bool runloop_is_frame_count_end(void)
bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
settings_t *settings = config_get_ptr();
switch (state)
{
@ -910,10 +909,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
const char *fullpath = (const char*)data;
if (!fullpath)
return false;
strlcpy(
settings->path.libretro,
fullpath,
sizeof(settings->path.libretro));
config_set_active_core_path(fullpath);
}
break;
case RUNLOOP_CTL_CLEAR_CONTENT_PATH:
@ -1056,9 +1052,11 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
break;
case RUNLOOP_CTL_TASK_INIT:
{
bool threaded_enable = false;
#ifdef HAVE_THREADS
threaded_enable = settings->threaded_data_runloop_enable;
settings_t *settings = config_get_ptr();
bool threaded_enable = settings->threaded_data_runloop_enable;
#else
bool threaded_enable = false;
#endif
task_queue_ctl(TASK_QUEUE_CTL_DEINIT, NULL);
task_queue_ctl(TASK_QUEUE_CTL_INIT, &threaded_enable);
@ -1134,6 +1132,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
bool ret = false;
char buf[PATH_MAX_LENGTH] = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *options_path = settings->path.core_options;
const struct retro_variable *vars =
(const struct retro_variable*)data;

View File

@ -810,7 +810,7 @@ static void content_push_to_history_playlist(bool do_push,
playlist_push(g_defaults.history,
path,
NULL,
settings->path.libretro,
config_get_active_core_path(),
info->library_name,
NULL,
NULL);
@ -1572,8 +1572,8 @@ static void menu_content_environment_get(int *argc, char *argv[],
if (fullpath && *fullpath)
wrap_args->content_path = fullpath;
if (!global->has_set.libretro)
wrap_args->libretro_path = *settings->path.libretro
? settings->path.libretro : NULL;
wrap_args->libretro_path = string_is_empty(config_get_active_core_path()) ? NULL :
config_get_active_core_path();
}
#endif