Refactor settings

This commit is contained in:
twinaphex 2016-07-25 11:59:38 +02:00
parent 1b057a0c71
commit afcc9657d2
7 changed files with 28 additions and 28 deletions

View File

@ -315,7 +315,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
/* Accomodate rewind since at some point we might have two full buffers. */ /* Accomodate rewind since at some point we might have two full buffers. */
outsamples_max = max_bufsamples * AUDIO_MAX_RATIO * outsamples_max = max_bufsamples * AUDIO_MAX_RATIO *
settings->slowmotion_ratio; settings->slowmotion_ratio.value;
audio_driver_data.output_samples.conv_buf = audio_driver_data.output_samples.conv_buf =
(int16_t*)malloc(outsamples_max * sizeof(int16_t)); (int16_t*)malloc(outsamples_max * sizeof(int16_t));
@ -577,7 +577,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
src_data.ratio = audio_driver_data.audio_rate.source_ratio.current; src_data.ratio = audio_driver_data.audio_rate.source_ratio.current;
if (runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) if (runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL))
src_data.ratio *= settings->slowmotion_ratio; src_data.ratio *= settings->slowmotion_ratio.value;
audio_driver_process_resampler(&src_data); audio_driver_process_resampler(&src_data);

View File

@ -2164,7 +2164,7 @@ bool command_event(enum event_command cmd, void *data)
break; break;
case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR: case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR:
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
input_overlay_set_scale_factor(NULL, settings->input.overlay_scale); input_overlay_set_scale_factor(NULL, settings->input.overlay_scale.value);
#endif #endif
break; break;
case CMD_EVENT_OVERLAY_SET_ALPHA_MOD: case CMD_EVENT_OVERLAY_SET_ALPHA_MOD:

View File

@ -578,8 +578,8 @@ static void config_set_defaults(void)
settings->rewind_enable = rewind_enable; settings->rewind_enable = rewind_enable;
settings->rewind_buffer_size = rewind_buffer_size; settings->rewind_buffer_size = rewind_buffer_size;
settings->rewind_granularity = rewind_granularity; settings->rewind_granularity = rewind_granularity;
settings->slowmotion_ratio = slowmotion_ratio; settings->slowmotion_ratio.value = slowmotion_ratio;
settings->fastforward_ratio = fastforward_ratio; settings->fastforward_ratio.value = fastforward_ratio;
settings->pause_nonactive = pause_nonactive; settings->pause_nonactive = pause_nonactive;
settings->autosave_interval = autosave_interval; settings->autosave_interval = autosave_interval;
@ -695,7 +695,7 @@ static void config_set_defaults(void)
settings->input.overlay_enable_autopreferred = true; settings->input.overlay_enable_autopreferred = true;
settings->input.overlay_hide_in_menu = overlay_hide_in_menu; settings->input.overlay_hide_in_menu = overlay_hide_in_menu;
settings->input.overlay_opacity = 0.7f; settings->input.overlay_opacity = 0.7f;
settings->input.overlay_scale = 1.0f; settings->input.overlay_scale.value = 1.0f;
settings->input.autodetect_enable = input_autodetect_enable; settings->input.autodetect_enable = input_autodetect_enable;
*settings->input.keyboard_layout = '\0'; *settings->input.keyboard_layout = '\0';
@ -1421,9 +1421,9 @@ static bool config_load_file(const char *path, bool set_defaults)
struct config_float_setting_ptr float_settings[] = { struct config_float_setting_ptr float_settings[] = {
{ "input_overlay_opacity", &settings->input.overlay_opacity}, { "input_overlay_opacity", &settings->input.overlay_opacity},
{ "input_overlay_scale", &settings->input.overlay_scale}, { "input_overlay_scale", &settings->input.overlay_scale.value},
{ "slowmotion_ratio", &settings->slowmotion_ratio}, { "slowmotion_ratio", &settings->slowmotion_ratio.value},
{ "fastforward_ratio", &settings->fastforward_ratio}, { "fastforward_ratio", &settings->fastforward_ratio.value},
{ "menu_wallpaper_opacity", &settings->menu.wallpaper.opacity}, { "menu_wallpaper_opacity", &settings->menu.wallpaper.opacity},
{ "menu_footer_opacity", &settings->menu.footer.opacity}, { "menu_footer_opacity", &settings->menu.footer.opacity},
{ "menu_header_opacity", &settings->menu.header.opacity}, { "menu_header_opacity", &settings->menu.header.opacity},
@ -1898,13 +1898,13 @@ static bool config_load_file(const char *path, bool set_defaults)
if (string_is_equal(settings->directory.system, "default")) if (string_is_equal(settings->directory.system, "default"))
*settings->directory.system = '\0'; *settings->directory.system = '\0';
if (settings->slowmotion_ratio < 1.0f) if (settings->slowmotion_ratio.value < 1.0f)
settings->slowmotion_ratio = 1.0f; settings->slowmotion_ratio.value = 1.0f;
/* Sanitize fastforward_ratio value - previously range was -1 /* Sanitize fastforward_ratio value - previously range was -1
* and up (with 0 being skipped) */ * and up (with 0 being skipped) */
if (settings->fastforward_ratio < 0.0f) if (settings->fastforward_ratio.value < 0.0f)
settings->fastforward_ratio = 0.0f; settings->fastforward_ratio.value = 0.0f;
#ifdef HAVE_LAKKA #ifdef HAVE_LAKKA
settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH); settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH);
@ -2827,7 +2827,7 @@ bool config_save_file(const char *path)
{ "video_font_size", settings->video.font_size}, { "video_font_size", settings->video.font_size},
#ifdef HAVE_OVERLAY #ifdef HAVE_OVERLAY
{ "input_overlay_opacity", settings->input.overlay_opacity}, { "input_overlay_opacity", settings->input.overlay_opacity},
{ "input_overlay_scale", settings->input.overlay_scale}, { "input_overlay_scale", settings->input.overlay_scale.value},
#endif #endif
#ifdef HAVE_MENU #ifdef HAVE_MENU
{ "menu_wallpaper_opacity", settings->menu.wallpaper.opacity}, { "menu_wallpaper_opacity", settings->menu.wallpaper.opacity},
@ -2837,8 +2837,8 @@ bool config_save_file(const char *path)
{ "video_message_pos_x", settings->video.msg_pos_x}, { "video_message_pos_x", settings->video.msg_pos_x},
{ "video_message_pos_y", settings->video.msg_pos_y}, { "video_message_pos_y", settings->video.msg_pos_y},
{ "video_font_size", settings->video.font_size}, { "video_font_size", settings->video.font_size},
{ "fastforward_ratio", settings->fastforward_ratio}, { "fastforward_ratio", settings->fastforward_ratio.value},
{ "slowmotion_ratio", settings->slowmotion_ratio}, { "slowmotion_ratio", settings->slowmotion_ratio.value},
{ "input_axis_threshold", settings->input.axis_threshold}, { "input_axis_threshold", settings->input.axis_threshold},
}; };

View File

@ -320,7 +320,7 @@ typedef struct settings
bool overlay_enable_autopreferred; bool overlay_enable_autopreferred;
bool overlay_hide_in_menu; bool overlay_hide_in_menu;
float overlay_opacity; float overlay_opacity;
float overlay_scale; struct config_float_setting overlay_scale;
unsigned bind_timeout; unsigned bind_timeout;
bool input_descriptor_label_show; bool input_descriptor_label_show;
@ -437,8 +437,8 @@ typedef struct settings
size_t rewind_buffer_size; size_t rewind_buffer_size;
unsigned rewind_granularity; unsigned rewind_granularity;
float slowmotion_ratio; struct config_float_setting slowmotion_ratio;
float fastforward_ratio; struct config_float_setting fastforward_ratio;
bool pause_nonactive; bool pause_nonactive;
unsigned autosave_interval; unsigned autosave_interval;

View File

@ -543,7 +543,7 @@ void input_overlay_loaded(void *task_data, void *user_data, const char *err)
input_overlay_enable(ol, settings->osk.enable); input_overlay_enable(ol, settings->osk.enable);
else else
input_overlay_enable(ol, settings->input.overlay_enable); input_overlay_enable(ol, settings->input.overlay_enable);
input_overlay_set_scale_factor(ol, settings->input.overlay_scale); input_overlay_set_scale_factor(ol, settings->input.overlay_scale.value);
ol->next_index = (ol->index + 1) % ol->size; ol->next_index = (ol->index + 1) % ol->size;
ol->state = OVERLAY_STATUS_NONE; ol->state = OVERLAY_STATUS_NONE;

View File

@ -6283,7 +6283,7 @@ static bool setting_append_list(
CONFIG_FLOAT( CONFIG_FLOAT(
list, list_info, list, list_info,
&settings->fastforward_ratio, &settings->fastforward_ratio.value,
msg_hash_to_str(MENU_ENUM_LABEL_FASTFORWARD_RATIO), msg_hash_to_str(MENU_ENUM_LABEL_FASTFORWARD_RATIO),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FASTFORWARD_RATIO), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FASTFORWARD_RATIO),
fastforward_ratio, fastforward_ratio,
@ -6299,7 +6299,7 @@ static bool setting_append_list(
CONFIG_FLOAT( CONFIG_FLOAT(
list, list_info, list, list_info,
&settings->slowmotion_ratio, &settings->slowmotion_ratio.value,
msg_hash_to_str(MENU_ENUM_LABEL_SLOWMOTION_RATIO), msg_hash_to_str(MENU_ENUM_LABEL_SLOWMOTION_RATIO),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SLOWMOTION_RATIO), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SLOWMOTION_RATIO),
slowmotion_ratio, slowmotion_ratio,
@ -6539,7 +6539,7 @@ static bool setting_append_list(
CONFIG_FLOAT( CONFIG_FLOAT(
list, list_info, list, list_info,
&settings->input.overlay_scale, &settings->input.overlay_scale.value,
msg_hash_to_str(MENU_ENUM_LABEL_OVERLAY_SCALE), msg_hash_to_str(MENU_ENUM_LABEL_OVERLAY_SCALE),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OVERLAY_SCALE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OVERLAY_SCALE),
1.0f, 1.0f,

View File

@ -1329,7 +1329,7 @@ static int runloop_iterate_menu(enum menu_action action, unsigned *sleep_ms)
return 1; return 1;
} }
if (!settings->menu.throttle_framerate && !settings->fastforward_ratio) if (!settings->menu.throttle_framerate && !settings->fastforward_ratio.value)
return 0; return 0;
return -1; return -1;
@ -1367,8 +1367,8 @@ int runloop_iterate(unsigned *sleep_ms)
struct retro_system_av_info *av_info = struct retro_system_av_info *av_info =
video_viewport_get_system_av_info(); video_viewport_get_system_av_info();
float fastforward_ratio = float fastforward_ratio =
(settings->fastforward_ratio == 0.0f) (settings->fastforward_ratio.value == 0.0f)
? 1.0f : settings->fastforward_ratio; ? 1.0f : settings->fastforward_ratio.value;
frame_limit_last_time = cpu_features_get_time_usec(); frame_limit_last_time = cpu_features_get_time_usec();
frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f
@ -1408,7 +1408,7 @@ int runloop_iterate(unsigned *sleep_ms)
delta = runloop_frame_time.reference; delta = runloop_frame_time.reference;
if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL))
delta /= settings->slowmotion_ratio; delta /= settings->slowmotion_ratio.value;
runloop_frame_time_last = current; runloop_frame_time_last = current;
@ -1541,7 +1541,7 @@ int runloop_iterate(unsigned *sleep_ms)
autosave_unlock(); autosave_unlock();
#endif #endif
if (!settings->fastforward_ratio) if (!settings->fastforward_ratio.value)
return 0; return 0;
#ifdef HAVE_MENU #ifdef HAVE_MENU
end: end: