Sanity check automatic input rate for deviations > 5%.

This commit is contained in:
Brandon Wright 2018-06-07 09:42:25 -05:00
parent 0f41b70324
commit 692c8f58b7
2 changed files with 16 additions and 2 deletions

View File

@ -1620,7 +1620,14 @@ Snes9xWindow::get_refresh_rate (void)
int
Snes9xWindow::get_auto_input_rate (void)
{
return (int) (get_refresh_rate () * 32040.0 / 60.09881389744051 + 0.5);
double new_input_rate = get_refresh_rate () * 32040.0 / 60.09881389744051 + 0.5;
if (new_input_rate > 32040.0 * 1.05)
new_input_rate = 32040.0;
if (new_input_rate < 32040.0 * 0.95)
new_input_rate = 32040.0 * 0.95;
return new_input_rate;
}
static void set_bypass_compositor (Display *dpy, Window window, unsigned char bypass)

View File

@ -752,7 +752,14 @@ double WinGetRefreshRate(void)
int WinGetAutomaticInputRate(void)
{
return (int)(WinGetRefreshRate() * 32040.0 / 60.09881389744051 + 0.5);
double newInputRate = WinGetRefreshRate() * 32040.0 / 60.09881389744051 + 0.5;
if (newInputRate > 32040.0 * 1.05)
newInputRate = 32040.0;
if (newInputRate < 32040.0 * 0.95)
newInputRate = 32040.0 * 0.95;
return newInputRate;
}
/* Depth conversion functions begin */