From 1e4557c09ac2d18d471d78ad01c128aaedcf0f8e Mon Sep 17 00:00:00 2001 From: sonninnos Date: Sat, 21 Aug 2021 18:20:15 +0300 Subject: [PATCH] Fix refresh rate 59Hz rounding --- menu/cbs/menu_cbs_ok.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index d240541df3..fe4752fcb3 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -6207,7 +6207,16 @@ int action_cb_push_dropdown_item_resolution(const char *path, { settings_t *settings = config_get_ptr(); - video_monitor_set_refresh_rate((float)refreshrate); + unsigned refresh_mod = round(refreshrate / 60.0f); + float refresh_exact = refreshrate; + + /* 59 Hz is an inaccurate representation of the real value (59.94). + * And since we at this point only have the integer to work with, + * the exact float needs to be calculated for 'video_refresh_rate' */ + if (refreshrate == (60.0f * refresh_mod) - 1) + refresh_exact = 59.94f * refresh_mod; + + video_monitor_set_refresh_rate(refresh_exact); settings->uints.video_fullscreen_x = width; settings->uints.video_fullscreen_y = height;