mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Move more code to runloop.c
This commit is contained in:
parent
098d983587
commit
cd8f34e0f8
90
dynamic.c
90
dynamic.c
@ -591,67 +591,6 @@ static void rarch_log_libretro(enum retro_log_level level,
|
|||||||
va_end(vp);
|
va_end(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* rarch_game_specific_options:
|
|
||||||
* @cmd : Output variable with path to core options file.
|
|
||||||
*
|
|
||||||
* Environment callback function implementation.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if a game specific core options path has been found,
|
|
||||||
* otherwise false (0).
|
|
||||||
**/
|
|
||||||
static bool rarch_game_specific_options(char **output)
|
|
||||||
{
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
|
||||||
|
|
||||||
const char *core_name = NULL;
|
|
||||||
const char *game_name = NULL;
|
|
||||||
config_file_t *option_file = NULL;
|
|
||||||
char game_path[PATH_MAX_LENGTH] = {0};
|
|
||||||
char config_directory[PATH_MAX_LENGTH] = {0};
|
|
||||||
|
|
||||||
core_name = system ? system->info.library_name : NULL;
|
|
||||||
game_name = global ? path_basename(global->name.base) : NULL;
|
|
||||||
|
|
||||||
if (!core_name || !game_name)
|
|
||||||
return false;
|
|
||||||
if (core_name[0] == '\0' || game_name[0] == '\0')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RARCH_LOG("Per-Game Options: core name: %s\n", core_name);
|
|
||||||
RARCH_LOG("Per-Game Options: game name: %s\n", game_name);
|
|
||||||
|
|
||||||
/* Config directory: config_directory.
|
|
||||||
* Try config directory setting first,
|
|
||||||
* fallback to the location of the current configuration file. */
|
|
||||||
if (settings->menu_config_directory[0] != '\0')
|
|
||||||
strlcpy(config_directory, settings->menu_config_directory, sizeof(config_directory));
|
|
||||||
else if (global->path.config[0] != '\0')
|
|
||||||
fill_pathname_basedir(config_directory, global->path.config, sizeof(config_directory));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RARCH_WARN("Per-Game Options: no config directory set\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Concatenate strings into full paths for game_path */
|
|
||||||
fill_pathname_join(game_path, config_directory, core_name, sizeof(game_path));
|
|
||||||
fill_pathname_join(game_path, game_path, game_name, sizeof(game_path));
|
|
||||||
strlcat(game_path, ".opt", sizeof(game_path));
|
|
||||||
|
|
||||||
option_file = config_file_new(game_path);
|
|
||||||
if (!option_file)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
config_file_free(option_file);
|
|
||||||
|
|
||||||
RARCH_LOG("Per-Game Options: game-specific core options found at %s\n", game_path);
|
|
||||||
*output = strdup(game_path);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rarch_environment_cb:
|
* rarch_environment_cb:
|
||||||
* @cmd : Identifier of command.
|
* @cmd : Identifier of command.
|
||||||
@ -710,34 +649,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
RARCH_LOG("Environ SET_VARIABLES.\n");
|
RARCH_LOG("Environ SET_VARIABLES.\n");
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL);
|
runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL);
|
||||||
|
runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_INIT, data);
|
||||||
{
|
|
||||||
char *game_options_path = NULL;
|
|
||||||
bool ret = false;
|
|
||||||
const struct retro_variable *vars = (const struct retro_variable*)data;
|
|
||||||
char buf[PATH_MAX_LENGTH] = {0};
|
|
||||||
const char *options_path = settings->core_options_path;
|
|
||||||
|
|
||||||
if (!*options_path && *global->path.config)
|
|
||||||
{
|
|
||||||
fill_pathname_resolve_relative(buf, global->path.config,
|
|
||||||
"retroarch-core-options.cfg", sizeof(buf));
|
|
||||||
options_path = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (settings->game_specific_options)
|
|
||||||
ret = rarch_game_specific_options(&game_options_path);
|
|
||||||
|
|
||||||
if(ret)
|
|
||||||
{
|
|
||||||
system->core_options = core_option_new(game_options_path, vars);
|
|
||||||
free(game_options_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
system->core_options = core_option_new(options_path, vars);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
90
runloop.c
90
runloop.c
@ -402,6 +402,66 @@ static void check_shader_dir(bool pressed_next, bool pressed_prev)
|
|||||||
RARCH_WARN("%s\n", msg_hash_to_str(MSG_FAILED_TO_APPLY_SHADER));
|
RARCH_WARN("%s\n", msg_hash_to_str(MSG_FAILED_TO_APPLY_SHADER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rarch_game_specific_options:
|
||||||
|
* @cmd : Output variable with path to core options file.
|
||||||
|
*
|
||||||
|
* Environment callback function implementation.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if a game specific core options path has been found,
|
||||||
|
* otherwise false (0).
|
||||||
|
**/
|
||||||
|
static bool rarch_game_specific_options(char **output)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||||
|
|
||||||
|
const char *core_name = NULL;
|
||||||
|
const char *game_name = NULL;
|
||||||
|
config_file_t *option_file = NULL;
|
||||||
|
char game_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
char config_directory[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
|
core_name = system ? system->info.library_name : NULL;
|
||||||
|
game_name = global ? path_basename(global->name.base) : NULL;
|
||||||
|
|
||||||
|
if (!core_name || !game_name)
|
||||||
|
return false;
|
||||||
|
if (core_name[0] == '\0' || game_name[0] == '\0')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RARCH_LOG("Per-Game Options: core name: %s\n", core_name);
|
||||||
|
RARCH_LOG("Per-Game Options: game name: %s\n", game_name);
|
||||||
|
|
||||||
|
/* Config directory: config_directory.
|
||||||
|
* Try config directory setting first,
|
||||||
|
* fallback to the location of the current configuration file. */
|
||||||
|
if (settings->menu_config_directory[0] != '\0')
|
||||||
|
strlcpy(config_directory, settings->menu_config_directory, sizeof(config_directory));
|
||||||
|
else if (global->path.config[0] != '\0')
|
||||||
|
fill_pathname_basedir(config_directory, global->path.config, sizeof(config_directory));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RARCH_WARN("Per-Game Options: no config directory set\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Concatenate strings into full paths for game_path */
|
||||||
|
fill_pathname_join(game_path, config_directory, core_name, sizeof(game_path));
|
||||||
|
fill_pathname_join(game_path, game_path, game_name, sizeof(game_path));
|
||||||
|
strlcat(game_path, ".opt", sizeof(game_path));
|
||||||
|
|
||||||
|
option_file = config_file_new(game_path);
|
||||||
|
if (!option_file)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
config_file_free(option_file);
|
||||||
|
|
||||||
|
RARCH_LOG("Per-Game Options: game-specific core options found at %s\n", game_path);
|
||||||
|
*output = strdup(game_path);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void rarch_main_data_clear_state(void)
|
static void rarch_main_data_clear_state(void)
|
||||||
{
|
{
|
||||||
@ -936,6 +996,36 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
RARCH_LOG("\t%s\n", var->value ? var->value : "N/A");
|
RARCH_LOG("\t%s\n", var->value ? var->value : "N/A");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case RUNLOOP_CTL_CORE_OPTIONS_INIT:
|
||||||
|
{
|
||||||
|
char *game_options_path = NULL;
|
||||||
|
bool ret = false;
|
||||||
|
const struct retro_variable *vars = (const struct retro_variable*)data;
|
||||||
|
char buf[PATH_MAX_LENGTH] = {0};
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
const char *options_path = settings->core_options_path;
|
||||||
|
|
||||||
|
if (!*options_path && *global->path.config)
|
||||||
|
{
|
||||||
|
fill_pathname_resolve_relative(buf, global->path.config,
|
||||||
|
"retroarch-core-options.cfg", sizeof(buf));
|
||||||
|
options_path = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (settings->game_specific_options)
|
||||||
|
ret = rarch_game_specific_options(&game_options_path);
|
||||||
|
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
system->core_options = core_option_new(game_options_path, vars);
|
||||||
|
free(game_options_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
system->core_options = core_option_new(options_path, vars);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RUNLOOP_CTL_CORE_OPTIONS_DEINIT:
|
case RUNLOOP_CTL_CORE_OPTIONS_DEINIT:
|
||||||
if (!system->core_options)
|
if (!system->core_options)
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,6 +88,7 @@ enum runloop_ctl_state
|
|||||||
RUNLOOP_CTL_MSG_QUEUE_FREE,
|
RUNLOOP_CTL_MSG_QUEUE_FREE,
|
||||||
RUNLOOP_CTL_IS_CORE_OPTION_UPDATED,
|
RUNLOOP_CTL_IS_CORE_OPTION_UPDATED,
|
||||||
RUNLOOP_CTL_CORE_OPTIONS_GET,
|
RUNLOOP_CTL_CORE_OPTIONS_GET,
|
||||||
|
RUNLOOP_CTL_CORE_OPTIONS_INIT,
|
||||||
RUNLOOP_CTL_CORE_OPTIONS_DEINIT,
|
RUNLOOP_CTL_CORE_OPTIONS_DEINIT,
|
||||||
RUNLOOP_CTL_SYSTEM_INFO_INIT,
|
RUNLOOP_CTL_SYSTEM_INFO_INIT,
|
||||||
RUNLOOP_CTL_SYSTEM_INFO_FREE,
|
RUNLOOP_CTL_SYSTEM_INFO_FREE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user