Add PAL threshold option for automatic refresh rate switch (#15636)

This commit is contained in:
sonninnos 2023-08-23 00:56:15 +03:00 committed by GitHub
parent 6b0a5c978e
commit ab1e5c37ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 4 deletions

View File

@ -237,6 +237,7 @@
/* Enable automatic switching of the screen refresh rate when using the specified screen mode(s),
* based on running core/content */
#define DEFAULT_AUTOSWITCH_REFRESH_RATE AUTOSWITCH_REFRESH_RATE_EXCLUSIVE_FULLSCREEN
#define DEFAULT_AUTOSWITCH_PAL_THRESHOLD 54.50f
/* Which monitor to prefer. 0 is any monitor, 1 and up selects
* specific monitors, 1 being the first monitor. */

View File

@ -2199,6 +2199,7 @@ static struct config_float_setting *populate_settings_float(
SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, DEFAULT_ASPECT_RATIO, false);
SETTING_FLOAT("video_refresh_rate", &settings->floats.video_refresh_rate, true, DEFAULT_REFRESH_RATE, false);
SETTING_FLOAT("video_autoswitch_pal_threshold", &settings->floats.video_autoswitch_pal_threshold, true, DEFAULT_AUTOSWITCH_PAL_THRESHOLD, false);
SETTING_FLOAT("crt_video_refresh_rate", &settings->floats.crt_video_refresh_rate, true, DEFAULT_CRT_REFRESH_RATE, false);
SETTING_FLOAT("video_message_pos_x", &settings->floats.video_msg_pos_x, true, DEFAULT_MESSAGE_POS_OFFSET_X, false);
SETTING_FLOAT("video_message_pos_y", &settings->floats.video_msg_pos_y, true, DEFAULT_MESSAGE_POS_OFFSET_Y, false);

View File

@ -359,6 +359,7 @@ typedef struct settings
float placeholder;
float video_aspect_ratio;
float video_refresh_rate;
float video_autoswitch_pal_threshold;
float crt_video_refresh_rate;
float video_font_size;
float video_msg_pos_x;

View File

@ -1232,6 +1232,7 @@ void video_switch_refresh_rate_maybe(
float refresh_rate = *refresh_rate_suggest;
float video_refresh_rate = settings->floats.video_refresh_rate;
float pal_threshold = settings->floats.video_autoswitch_pal_threshold;
unsigned crt_switch_resolution = settings->uints.crt_switch_resolution;
unsigned autoswitch_refresh_rate = settings->uints.video_autoswitch_refresh_rate;
unsigned video_swap_interval = runloop_get_video_swap_interval(
@ -1243,7 +1244,7 @@ void video_switch_refresh_rate_maybe(
bool all_fullscreen = settings->bools.video_fullscreen || settings->bools.video_windowed_fullscreen;
/* Roundings to PAL & NTSC standards */
if (refresh_rate > 49.00 && refresh_rate < 54.50)
if (refresh_rate > 49.00 && refresh_rate <= pal_threshold)
refresh_rate = 50.00f;
else if (refresh_rate > 54.00 && refresh_rate < 60.00)
refresh_rate = 59.94f;

View File

@ -2135,11 +2135,11 @@ MSG_HASH(
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_REFRESH_RATE,
"Switch Refresh Rate Automatically"
"Automatic Refresh Rate Switch"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_VIDEO_AUTOSWITCH_REFRESH_RATE,
"Switch the refresh rate of the screen automatically when using the specified screen mode, based on the core and/or content being run."
"Switch screen refresh rate automatically based on current content."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_REFRESH_RATE_EXCLUSIVE_FULLSCREEN,
@ -2153,6 +2153,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_REFRESH_RATE_ALL_FULLSCREEN,
"All Fullscreen Modes"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_PAL_THRESHOLD,
"Automatic Refresh Rate PAL Threshold"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_VIDEO_AUTOSWITCH_PAL_THRESHOLD,
"Maximum refresh rate to be considered PAL."
)
#if defined(DINGUX) && defined(DINGUX_BETA)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIDEO_DINGUX_REFRESH_RATE,

View File

@ -680,6 +680,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_force_srgb_enable, MENU_
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_fullscreen, MENU_ENUM_SUBLABEL_VIDEO_FULLSCREEN)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_windowed_fullscreen, MENU_ENUM_SUBLABEL_VIDEO_WINDOWED_FULLSCREEN)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_autoswitch_refresh_rate, MENU_ENUM_SUBLABEL_VIDEO_AUTOSWITCH_REFRESH_RATE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_autoswitch_pal_threshold,MENU_ENUM_SUBLABEL_VIDEO_AUTOSWITCH_PAL_THRESHOLD)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_gpu_record, MENU_ENUM_SUBLABEL_VIDEO_GPU_RECORD)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_savestate_auto_index, MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_INDEX)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_block_sram_overwrite, MENU_ENUM_SUBLABEL_BLOCK_SRAM_OVERWRITE)
@ -4047,6 +4048,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_VIDEO_AUTOSWITCH_REFRESH_RATE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_autoswitch_refresh_rate);
break;
case MENU_ENUM_LABEL_VIDEO_AUTOSWITCH_PAL_THRESHOLD:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_autoswitch_pal_threshold);
break;
case MENU_ENUM_LABEL_VIDEO_FORCE_SRGB_DISABLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_force_srgb_enable);
break;

View File

@ -9245,6 +9245,11 @@ unsigned menu_displaylist_build_list(
MENU_ENUM_LABEL_VIDEO_AUTOSWITCH_REFRESH_RATE,
PARSE_ONLY_UINT, false) == 0)
count++;
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_AUTOSWITCH_PAL_THRESHOLD,
PARSE_ONLY_FLOAT, false) == 0)
count++;
}
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_FORCE_SRGB_DISABLE,

View File

@ -11049,7 +11049,7 @@ static bool setting_append_list(
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_uint_replay_checkpoint_interval;
menu_settings_list_current_add_range(list, list_info, 0, 3600, 60, true, false);
menu_settings_list_current_add_range(list, list_info, 0, 3600, 60, true, true);
#endif
CONFIG_BOOL(
@ -12242,6 +12242,21 @@ static bool setting_append_list(
menu_settings_list_current_add_range(list, list_info, 0, AUTOSWITCH_REFRESH_RATE_LAST - 1, 1, true, true);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX;
CONFIG_FLOAT(
list, list_info,
&settings->floats.video_autoswitch_pal_threshold,
MENU_ENUM_LABEL_VIDEO_AUTOSWITCH_PAL_THRESHOLD,
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_PAL_THRESHOLD,
DEFAULT_AUTOSWITCH_PAL_THRESHOLD,
"%.3f Hz",
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 50, 56, 0.1, true, true);
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ALLOW_INPUT);
if (string_is_equal(settings->arrays.video_driver, "gl"))
{
CONFIG_BOOL(

View File

@ -1305,6 +1305,7 @@ enum msg_hash_enums
MENU_LBL_H(VIDEO_HARD_SYNC_FRAMES),
MENU_LABEL(VIDEO_WINDOWED_FULLSCREEN),
MENU_LABEL(VIDEO_AUTOSWITCH_REFRESH_RATE),
MENU_LABEL(VIDEO_AUTOSWITCH_PAL_THRESHOLD),
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_REFRESH_RATE_EXCLUSIVE_FULLSCREEN,
MENU_ENUM_LABEL_VALUE_VIDEO_AUTOSWITCH_REFRESH_RATE_WINDOWED_FULLSCREEN,