mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
fastforward_ratio - add improved clamping code
This commit is contained in:
parent
e12081c309
commit
86de91d718
@ -494,7 +494,7 @@ static const bool savestate_auto_load = true;
|
||||
static const float slowmotion_ratio = 3.0;
|
||||
|
||||
// Maximum fast forward ratio (Zero => no limit).
|
||||
static const float fastforward_ratio = 0.0;
|
||||
static const float fastforward_ratio = -1.0;
|
||||
|
||||
// Enable stdin/network command interface
|
||||
static const bool network_cmd_enable = false;
|
||||
|
@ -1919,32 +1919,56 @@ static void menu_common_setting_set_current_path_selection(rarch_setting_t *sett
|
||||
|
||||
static void menu_common_setting_set_current_fraction(rarch_setting_t *setting, unsigned action)
|
||||
{
|
||||
switch (action)
|
||||
if (!strcmp(setting->name, "fastforward_ratio"))
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
*setting->value.fraction = *setting->value.fraction - setting->step;
|
||||
bool clamp_value = false;
|
||||
if (action == MENU_ACTION_START)
|
||||
*setting->value.fraction = setting->default_value.fraction;
|
||||
else if (action == MENU_ACTION_LEFT)
|
||||
{
|
||||
*setting->value.fraction -= 0.1f;
|
||||
if (*setting->value.fraction < 0.95f) // Avoid potential rounding errors when going from 1.1 to 1.0.
|
||||
*setting->value.fraction = setting->default_value.fraction;
|
||||
else
|
||||
clamp_value = true;
|
||||
}
|
||||
else if (action == MENU_ACTION_RIGHT)
|
||||
{
|
||||
*setting->value.fraction += 0.1f;
|
||||
clamp_value = true;
|
||||
}
|
||||
if (clamp_value)
|
||||
g_settings.fastforward_ratio = max(min(*setting->value.fraction, 10.0f), 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
*setting->value.fraction = *setting->value.fraction - setting->step;
|
||||
|
||||
if (setting->enforce_minrange)
|
||||
{
|
||||
if (*setting->value.fraction < setting->min)
|
||||
*setting->value.fraction = setting->min;
|
||||
}
|
||||
break;
|
||||
if (setting->enforce_minrange)
|
||||
{
|
||||
if (*setting->value.fraction < setting->min)
|
||||
*setting->value.fraction = setting->min;
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_ACTION_RIGHT:
|
||||
case MENU_ACTION_OK:
|
||||
*setting->value.fraction = *setting->value.fraction + setting->step;
|
||||
case MENU_ACTION_RIGHT:
|
||||
case MENU_ACTION_OK:
|
||||
*setting->value.fraction = *setting->value.fraction + setting->step;
|
||||
|
||||
if (setting->enforce_maxrange)
|
||||
{
|
||||
if (*setting->value.fraction > setting->max)
|
||||
*setting->value.fraction = setting->max;
|
||||
}
|
||||
break;
|
||||
if (setting->enforce_maxrange)
|
||||
{
|
||||
if (*setting->value.fraction > setting->max)
|
||||
*setting->value.fraction = setting->max;
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_ACTION_START:
|
||||
*setting->value.fraction = setting->default_value.fraction;
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
*setting->value.fraction = setting->default_value.fraction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (setting->change_handler)
|
||||
|
13
retroarch.c
13
retroarch.c
@ -3077,19 +3077,14 @@ static inline void update_frame_time(void)
|
||||
|
||||
static inline void limit_frame_time(void)
|
||||
{
|
||||
retro_time_t current = 0;
|
||||
retro_time_t target = 0;
|
||||
retro_time_t to_sleep_ms = 0;
|
||||
|
||||
if (g_settings.fastforward_ratio <= 0.0f)
|
||||
if (g_settings.fastforward_ratio < 0.0f)
|
||||
return;
|
||||
|
||||
g_extern.frame_limit.minimum_frame_time = (retro_time_t)roundf(1000000.0f / (g_extern.system.av_info.timing.fps * g_settings.fastforward_ratio));
|
||||
|
||||
current = rarch_get_time_usec();
|
||||
target = g_extern.frame_limit.last_frame_time + g_extern.frame_limit.minimum_frame_time;
|
||||
to_sleep_ms = (target - current) / 1000;
|
||||
|
||||
retro_time_t current = rarch_get_time_usec();
|
||||
retro_time_t target = g_extern.frame_limit.last_frame_time + g_extern.frame_limit.minimum_frame_time;
|
||||
retro_time_t to_sleep_ms = (target - current) / 1000;
|
||||
if (to_sleep_ms > 0)
|
||||
{
|
||||
rarch_sleep((unsigned int)to_sleep_ms);
|
||||
|
@ -1647,7 +1647,7 @@ rarch_setting_t* setting_data_get_list(void)
|
||||
#endif
|
||||
CONFIG_BOOL(g_settings.video.disable_composition, "video_disable_composition", "Window Compositing", disable_composition, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_BOOL(g_settings.pause_nonactive, "pause_nonactive", "Window Unfocus Pause", pause_nonactive, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_FLOAT(g_settings.fastforward_ratio, "fastforward_ratio", "Maximum Run Speed", fastforward_ratio, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 10, 1.0, true, true)
|
||||
CONFIG_FLOAT(g_settings.fastforward_ratio, "fastforward_ratio", "Maximum Run Speed", fastforward_ratio, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, 10, 0.1, true, true)
|
||||
CONFIG_FLOAT(g_settings.slowmotion_ratio, "slowmotion_ratio", "Slow-Motion Ratio", slowmotion_ratio, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(1, 10, 1.0, true, true)
|
||||
CONFIG_BOOL(g_settings.savestate_auto_index, "savestate_auto_index", "Save State Auto Index", savestate_auto_index, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_BOOL(g_settings.savestate_auto_save, "savestate_auto_save", "Auto Save State", savestate_auto_save, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
|
Loading…
x
Reference in New Issue
Block a user