get rid of some settings_t pointer passing

This commit is contained in:
LibretroAdmin 2025-02-10 15:47:18 +01:00
parent 50a0e17539
commit ddd7ff2d33
14 changed files with 83 additions and 66 deletions

View File

@ -77,10 +77,9 @@ static void cheat_manager_pause_cheevos(void)
} }
#endif #endif
void cheat_manager_apply_cheats(void) void cheat_manager_apply_cheats(bool notification_show_cheats_applied)
{ {
unsigned i, idx = 0; unsigned i, idx = 0;
settings_t *settings = config_get_ptr();
cheat_manager_t *cheat_st = &cheat_manager_state; cheat_manager_t *cheat_st = &cheat_manager_state;
if (!cheat_st->cheats) if (!cheat_st->cheats)
@ -104,7 +103,7 @@ void cheat_manager_apply_cheats(void)
} }
} }
if (cheat_st->size > 0 && settings->bools.notification_show_cheats_applied) if (cheat_st->size > 0 && notification_show_cheats_applied)
{ {
char msg[128]; char msg[128];
size_t _len = strlcpy(msg, msg_hash_to_str(MSG_APPLYING_CHEAT), sizeof(msg)); size_t _len = strlcpy(msg, msg_hash_to_str(MSG_APPLYING_CHEAT), sizeof(msg));
@ -643,7 +642,7 @@ void cheat_manager_toggle_index(bool apply_cheats_after_toggle,
cheat_manager_update(cheat_st, i); cheat_manager_update(cheat_st, i);
if (apply_cheats_after_toggle) if (apply_cheats_after_toggle)
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(config_get_ptr()->bools.notification_show_cheats_applied);
} }
void cheat_manager_toggle(void) void cheat_manager_toggle(void)
@ -653,7 +652,7 @@ void cheat_manager_toggle(void)
return; return;
cheat_st->cheats[cheat_st->ptr].state ^= true; cheat_st->cheats[cheat_st->ptr].state ^= true;
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(config_get_ptr()->bools.notification_show_cheats_applied);
cheat_manager_update(cheat_st, cheat_st->ptr); cheat_manager_update(cheat_st, cheat_st->ptr);
} }

View File

@ -217,7 +217,7 @@ void cheat_manager_index_prev(void);
void cheat_manager_toggle(void); void cheat_manager_toggle(void);
void cheat_manager_apply_cheats(void); void cheat_manager_apply_cheats(bool notification_show_cheats_applied);
void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx); void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx);

View File

@ -766,7 +766,8 @@ static void rcheevos_toggle_hardcore_active(rcheevos_locals_t* locals)
#ifdef HAVE_CHEATS #ifdef HAVE_CHEATS
/* If one or more emulator managed cheats is active, abort */ /* If one or more emulator managed cheats is active, abort */
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(
settings->bools.notification_show_cheats_applied);
if (!locals->hardcore_allowed) if (!locals->hardcore_allowed)
{ {
locals->hardcore_being_enabled = false; locals->hardcore_being_enabled = false;

View File

@ -1301,7 +1301,8 @@ void command_event_init_cheats(
cheat_manager_load_game_specific_cheats(path_cheat_db); cheat_manager_load_game_specific_cheats(path_cheat_db);
if (apply_cheats_after_load) if (apply_cheats_after_load)
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(
config_get_ptr()->bools.notification_show_cheats_applied);
} }
#endif #endif

View File

@ -59,9 +59,9 @@ bool PlatformEmscriptenPowerStateGetCharging(void);
uint64_t PlatformEmscriptenGetTotalMem(void); uint64_t PlatformEmscriptenGetTotalMem(void);
uint64_t PlatformEmscriptenGetFreeMem(void); uint64_t PlatformEmscriptenGetFreeMem(void);
//// begin exported functions /* begin exported functions */
// saves and states /* saves and states */
void cmd_savefiles(void) void cmd_savefiles(void)
{ {
@ -88,7 +88,7 @@ void cmd_undo_load_state(void)
command_event(CMD_EVENT_UNDO_LOAD_STATE, NULL); command_event(CMD_EVENT_UNDO_LOAD_STATE, NULL);
} }
// misc /* misc */
void cmd_take_screenshot(void) void cmd_take_screenshot(void)
{ {
@ -135,7 +135,8 @@ void cmd_unpause(void)
command_event(CMD_EVENT_UNPAUSE, NULL); command_event(CMD_EVENT_UNPAUSE, NULL);
} }
void cmd_set_volume(float volume) { void cmd_set_volume(float volume)
{
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, volume); audio_set_float(AUDIO_ACTION_VOLUME_GAIN, volume);
} }
@ -146,7 +147,7 @@ bool cmd_set_shader(const char *path)
} }
#endif #endif
// cheats /* cheats */
void cmd_cheat_set_code(unsigned index, const char *str) void cmd_cheat_set_code(unsigned index, const char *str)
{ {
@ -180,10 +181,11 @@ unsigned cmd_cheat_get_size(void)
void cmd_cheat_apply_cheats(void) void cmd_cheat_apply_cheats(void)
{ {
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(
config_get_ptr()->bools.notification_show_cheats_applied);
} }
//// end exported functions /* end exported functions */
static void frontend_emscripten_get_env(int *argc, char *argv[], static void frontend_emscripten_get_env(int *argc, char *argv[],
void *args, void *params_data) void *args, void *params_data)

View File

@ -1890,7 +1890,7 @@ end:
**/ **/
static bool video_shader_load_root_config_into_shader( static bool video_shader_load_root_config_into_shader(
config_file_t *conf, config_file_t *conf,
settings_t *settings, bool video_shader_watch_files,
struct video_shader *shader) struct video_shader *shader)
{ {
size_t i; size_t i;
@ -1921,7 +1921,7 @@ static bool video_shader_load_root_config_into_shader(
strlcpy(shader->loaded_preset_path, conf->path, strlcpy(shader->loaded_preset_path, conf->path,
sizeof(shader->loaded_preset_path)); sizeof(shader->loaded_preset_path));
if (settings->bools.video_shader_watch_files) if (video_shader_watch_files)
{ {
union string_list_elem_attr attr; union string_list_elem_attr attr;
int flags = int flags =
@ -2255,7 +2255,8 @@ bool video_shader_load_preset_into_shader(const char *path,
if (string_is_equal(root_conf->path, path)) if (string_is_equal(root_conf->path, path))
{ {
/* Load the config from the shader chain from the first reference into the shader */ /* Load the config from the shader chain from the first reference into the shader */
video_shader_load_root_config_into_shader(root_conf, config_get_ptr(), shader); video_shader_load_root_config_into_shader(root_conf,
config_get_ptr()->bools.video_shader_watch_files, shader);
goto end; goto end;
} }
@ -2308,7 +2309,8 @@ bool video_shader_load_preset_into_shader(const char *path,
} }
/* Load the config from the shader chain from the first reference into the shader */ /* Load the config from the shader chain from the first reference into the shader */
video_shader_load_root_config_into_shader(root_conf, config_get_ptr(), shader); video_shader_load_root_config_into_shader(root_conf,
config_get_ptr()->bools.video_shader_watch_files, shader);
/* Set Path for originally loaded preset because it is different than the root preset path */ /* Set Path for originally loaded preset because it is different than the root preset path */
strlcpy(shader->loaded_preset_path, path, sizeof(shader->loaded_preset_path)); strlcpy(shader->loaded_preset_path, path, sizeof(shader->loaded_preset_path));
@ -2827,12 +2829,13 @@ static bool video_shader_load_shader_preset_internal(
* *
* Returns: false if there was an error or no action was performed. * Returns: false if there was an error or no action was performed.
*/ */
static bool video_shader_load_auto_shader_preset(settings_t *settings, const char *core_name, static bool video_shader_load_auto_shader_preset(
const char *video_shader_directory,
const char *menu_config_directory,
const char *core_name,
char *s, size_t len) char *s, size_t len)
{ {
size_t i; size_t i;
const char *video_shader_directory = settings->paths.directory_video_shader;
const char *menu_config_directory = settings->paths.directory_menu_config;
const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME); const char *rarch_path_basename = path_get(RARCH_PATH_BASENAME);
bool has_content = !string_is_empty(rarch_path_basename); bool has_content = !string_is_empty(rarch_path_basename);
@ -2917,7 +2920,6 @@ success:
} }
bool video_shader_combine_preset_and_apply( bool video_shader_combine_preset_and_apply(
settings_t *settings,
enum rarch_shader_type type, enum rarch_shader_type type,
struct video_shader *menu_shader, struct video_shader *menu_shader,
const char *preset_path, const char *preset_path,
@ -3111,7 +3113,8 @@ const char *video_shader_get_current_shader_preset(void)
if (auto_shaders_enable) /* sets runtime_shader_preset_path */ if (auto_shaders_enable) /* sets runtime_shader_preset_path */
{ {
if (video_shader_load_auto_shader_preset( if (video_shader_load_auto_shader_preset(
settings, settings->paths.directory_video_shader,
settings->paths.directory_menu_config,
runloop_st->system.info.library_name, runloop_st->system.info.library_name,
runloop_st->runtime_shader_preset_path, runloop_st->runtime_shader_preset_path,
sizeof(runloop_st->runtime_shader_preset_path))) sizeof(runloop_st->runtime_shader_preset_path)))

View File

@ -275,7 +275,6 @@ void video_shader_dir_check_shader(
bool pressed_prev); bool pressed_prev);
bool video_shader_combine_preset_and_apply( bool video_shader_combine_preset_and_apply(
settings_t *settings,
enum rarch_shader_type type, enum rarch_shader_type type,
struct video_shader *menu_shader, struct video_shader *menu_shader,
const char *preset_path, const char *preset_path,

View File

@ -24,9 +24,7 @@
#include "menu_driver.h" #include "menu_driver.h"
#include "menu_displaylist.h" #include "menu_displaylist.h"
#include "../file_path_special.h" #include "../file_path_special.h"
#include "../retroarch.h"
#include "../core_info.h" #include "../core_info.h"
#include "../configuration.h"
#define CONTENTLESS_CORE_ICON_DEFAULT "default.png" #define CONTENTLESS_CORE_ICON_DEFAULT "default.png"
@ -402,12 +400,10 @@ void menu_contentless_cores_free(void)
contentless_cores_state = NULL; contentless_cores_state = NULL;
} }
unsigned menu_displaylist_contentless_cores(file_list_t *list, settings_t *settings) unsigned menu_displaylist_contentless_cores(file_list_t *list,
enum menu_contentless_cores_display_type core_display_type)
{ {
unsigned count = 0; unsigned count = 0;
enum menu_contentless_cores_display_type
core_display_type = (enum menu_contentless_cores_display_type)
settings->uints.menu_content_show_contentless_cores;
core_info_list_t *core_info_list = NULL; core_info_list_t *core_info_list = NULL;
/* Get core list */ /* Get core list */

View File

@ -1621,21 +1621,17 @@ static unsigned menu_displaylist_parse_remap_file_manager_list(file_list_t *list
return count; return count;
} }
static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *info, static unsigned menu_displaylist_parse_supported_cores(
settings_t *settings, const char *content_path, menu_displaylist_info_t *info,
bool enable_load_with_current,
const char *core_path_current,
const char *content_path,
enum msg_hash_enums core_enum_label, enum msg_hash_enums core_enum_label,
enum msg_hash_enums current_core_enum_label) enum msg_hash_enums current_core_enum_label)
{ {
unsigned count = 0; unsigned count = 0;
core_info_list_t *core_info_list = NULL; core_info_list_t *core_info_list = NULL;
bool core_available = false; bool core_available = false;
const char *core_path_current = path_get(RARCH_PATH_CORE);
#if defined(HAVE_DYNAMIC)
bool enable_load_with_current = !string_is_empty(core_path_current);
#else
bool enable_load_with_current = !string_is_empty(core_path_current)
&& !settings->bools.always_reload_core_on_run_content;
#endif
/* Get core list */ /* Get core list */
if ( core_info_get_list(&core_info_list) if ( core_info_get_list(&core_info_list)
@ -13710,10 +13706,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_CORES_SUPPORTED: case DISPLAYLIST_CORES_SUPPORTED:
menu_entries_clear(info->list); menu_entries_clear(info->list);
{
const char *core_path_current = path_get(RARCH_PATH_CORE);
#if defined(HAVE_DYNAMIC)
bool enable_load_with_current = !string_is_empty(core_path_current);
#else
bool enable_load_with_current = !string_is_empty(core_path_current)
&& !settings->bools.always_reload_core_on_run_content;
#endif
count = menu_displaylist_parse_supported_cores(info, count = menu_displaylist_parse_supported_cores(info,
settings, menu->deferred_path, enable_load_with_current, core_path_current,
menu->deferred_path,
MENU_ENUM_LABEL_DETECT_CORE_LIST_OK, MENU_ENUM_LABEL_DETECT_CORE_LIST_OK,
MENU_ENUM_LABEL_DETECT_CORE_LIST_OK_CURRENT_CORE); MENU_ENUM_LABEL_DETECT_CORE_LIST_OK_CURRENT_CORE);
}
info->flags &= ~MD_FLAG_NEED_SORT; info->flags &= ~MD_FLAG_NEED_SORT;
info->flags |= MD_FLAG_NEED_REFRESH info->flags |= MD_FLAG_NEED_REFRESH
@ -13722,10 +13728,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_CORES_COLLECTION_SUPPORTED: case DISPLAYLIST_CORES_COLLECTION_SUPPORTED:
menu_entries_clear(info->list); menu_entries_clear(info->list);
{
const char *core_path_current = path_get(RARCH_PATH_CORE);
#if defined(HAVE_DYNAMIC)
bool enable_load_with_current = !string_is_empty(core_path_current);
#else
bool enable_load_with_current = !string_is_empty(core_path_current)
&& !settings->bools.always_reload_core_on_run_content;
#endif
count = menu_displaylist_parse_supported_cores(info, count = menu_displaylist_parse_supported_cores(info,
settings, menu->deferred_path, enable_load_with_current, core_path_current,
menu->deferred_path,
MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION, MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION,
MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE); MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE);
}
info->flags &= ~MD_FLAG_NEED_SORT; info->flags &= ~MD_FLAG_NEED_SORT;
info->flags |= MD_FLAG_NEED_REFRESH info->flags |= MD_FLAG_NEED_REFRESH
@ -13884,7 +13900,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
size_t contentless_core_ptr = menu_st->contentless_core_ptr; size_t contentless_core_ptr = menu_st->contentless_core_ptr;
menu_entries_clear(info->list); menu_entries_clear(info->list);
count = menu_displaylist_contentless_cores(info->list, settings); count = menu_displaylist_contentless_cores(info->list,
(enum menu_contentless_cores_display_type)
settings->uints.menu_content_show_contentless_cores);
/* TODO/FIXME: Selecting an entry in the /* TODO/FIXME: Selecting an entry in the
* contentless cores list will cause the * contentless cores list will cause the

View File

@ -374,7 +374,8 @@ bool menu_displaylist_has_subsystems(void);
#if defined(HAVE_LIBRETRODB) #if defined(HAVE_LIBRETRODB)
unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings); unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings);
#endif #endif
unsigned menu_displaylist_contentless_cores(file_list_t *list, settings_t *settings); unsigned menu_displaylist_contentless_cores(file_list_t *list,
enum menu_contentless_cores_display_type core_display_type);
enum filebrowser_enums filebrowser_get_type(void); enum filebrowser_enums filebrowser_get_type(void);

View File

@ -6956,8 +6956,7 @@ bool menu_shader_manager_append_preset(struct video_shader *shader,
const char* preset_path, const bool prepend) const char* preset_path, const bool prepend)
{ {
bool ret = false; bool ret = false;
settings_t* settings = config_get_ptr(); const char *dir_video_shader = config_get_ptr()->paths.directory_video_shader;
const char *dir_video_shader = settings->paths.directory_video_shader;
enum rarch_shader_type type = menu_shader_manager_get_type(shader); enum rarch_shader_type type = menu_shader_manager_get_type(shader);
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;
@ -6967,7 +6966,7 @@ bool menu_shader_manager_append_preset(struct video_shader *shader,
goto clear; goto clear;
} }
if (!video_shader_combine_preset_and_apply(settings, if (!video_shader_combine_preset_and_apply(
type, shader, preset_path, dir_video_shader, prepend, true)) type, shader, preset_path, dir_video_shader, prepend, true))
goto clear; goto clear;
@ -7079,9 +7078,7 @@ static int generic_menu_iterate(
bind.s = menu->menu_state_msg; bind.s = menu->menu_state_msg;
bind.len = sizeof(menu->menu_state_msg); bind.len = sizeof(menu->menu_state_msg);
if (menu_input_key_bind_iterate( if (menu_input_key_bind_iterate(settings, &bind, current_time))
settings,
&bind, current_time))
{ {
size_t selection = menu_st->selection_ptr; size_t selection = menu_st->selection_ptr;
menu_entries_pop_stack(&selection, 0, 0); menu_entries_pop_stack(&selection, 0, 0);

View File

@ -1433,7 +1433,8 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_SEARCH_NAME), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_SEARCH_NAME),
EXPLORE_TYPE_SEARCH, explore_action_ok_find); EXPLORE_TYPE_SEARCH, explore_action_ok_find);
if (list->size) if (list->size)
((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel = explore_action_sublabel_spacer; ((menu_file_list_cbs_t*)list->list[list->size-1].actiondata)->action_sublabel =
explore_action_sublabel_spacer;
} }
for (cat = 0; cat < EXPLORE_CAT_COUNT; cat++) for (cat = 0; cat < EXPLORE_CAT_COUNT; cat++)

View File

@ -860,8 +860,6 @@ bool midi_driver_set_input(const char *input)
bool midi_driver_set_output(void *settings_data, const char *output) bool midi_driver_set_output(void *settings_data, const char *output)
{ {
settings_t *settings = (settings_t*)settings_data;
if (!rarch_midi_drv_data) if (!rarch_midi_drv_data)
{ {
#ifdef DEBUG #ifdef DEBUG
@ -884,10 +882,12 @@ bool midi_driver_set_output(void *settings_data, const char *output)
if (output) if (output)
{ {
settings_t *settings = (settings_t*)settings_data;
unsigned midi_volume = settings->uints.midi_volume;
rarch_midi_drv_output_enabled = true; rarch_midi_drv_output_enabled = true;
RARCH_LOG("[MIDI]: Output device changed to \"%s\".\n", output); RARCH_LOG("[MIDI]: Output device changed to \"%s\".\n", output);
midi_driver_set_volume(settings->uints.midi_volume); midi_driver_set_volume(midi_volume);
} }
else else
{ {
@ -3684,7 +3684,7 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_CHEATS_APPLY: case CMD_EVENT_CHEATS_APPLY:
#ifdef HAVE_CHEATS #ifdef HAVE_CHEATS
cheat_manager_apply_cheats(); cheat_manager_apply_cheats(settings->bools.notification_show_cheats_applied);
#endif #endif
break; break;
case CMD_EVENT_REWIND_DEINIT: case CMD_EVENT_REWIND_DEINIT:

View File

@ -3801,12 +3801,11 @@ static void runloop_audio_buffer_status_free(runloop_state_t *runloop_st)
runloop_st->audio_latency = 0; runloop_st->audio_latency = 0;
} }
static void runloop_fastmotion_override_free(runloop_state_t *runloop_st) static void runloop_fastmotion_override_free(runloop_state_t *runloop_st,
float fastforward_ratio)
{ {
video_driver_state_t video_driver_state_t
*video_st = video_state_get_ptr(); *video_st = video_state_get_ptr();
settings_t *settings = config_get_ptr();
float fastforward_ratio = settings->floats.fastforward_ratio;
bool reset_frame_limit = runloop_st->fastmotion_override.current.fastforward bool reset_frame_limit = runloop_st->fastmotion_override.current.fastforward
&& (runloop_st->fastmotion_override.current.ratio >= 0.0f) && (runloop_st->fastmotion_override.current.ratio >= 0.0f)
&& (runloop_st->fastmotion_override.current.ratio != fastforward_ratio); && (runloop_st->fastmotion_override.current.ratio != fastforward_ratio);
@ -3832,7 +3831,7 @@ void runloop_state_free(runloop_state_t *runloop_st)
runloop_frame_time_free(runloop_st); runloop_frame_time_free(runloop_st);
runloop_audio_buffer_status_free(runloop_st); runloop_audio_buffer_status_free(runloop_st);
input_game_focus_free(); input_game_focus_free();
runloop_fastmotion_override_free(runloop_st); runloop_fastmotion_override_free(runloop_st, config_get_ptr()->floats.fastforward_ratio);
/* Only a single core options callback is used at present */ /* Only a single core options callback is used at present */
runloop_st->core_options_callback.update_display = NULL; runloop_st->core_options_callback.update_display = NULL;