Fix/extend parsing of -resolution command line arg

In both Windows and SDL builds, format of -resolution can now be any of:

<width>x<height>
<width>x<height>x<depth>
<width>x<height>x<depth>@<refresh>
<width>x<height>@<refresh>

Omitted values are defaulted to 0, at the point of parsing (as before).
This commit is contained in:
Daniel Lopez 2015-06-14 20:02:48 +01:00
parent d77295b722
commit 6ccbaeda7e
2 changed files with 13 additions and 2 deletions

View File

@ -756,6 +756,11 @@ static void get_resolution(const char *defdata, const char *data, osd_window_con
data = defdata;
}
if (sscanf(data, "%dx%d@%d", &config->width, &config->height, &config->refresh) < 2 && report_error)
if (sscanf(data, "%dx%dx%d", &config->width, &config->height, &config->depth) < 2 && report_error)
osd_printf_error("Illegal resolution value = %s\n", data);
const char * at_pos = strchr(data, '@');
if (at_pos)
if (sscanf(at_pos + 1, "%d", &config->refresh) < 1 && report_error)
osd_printf_error("Illegal refresh rate in resolution value = %s\n", data);
}

View File

@ -508,6 +508,12 @@ static void get_resolution(const char *defdata, const char *data, osd_window_con
return;
data = defdata;
}
if (sscanf(data, "%dx%d@%d", &config->width, &config->height, &config->refresh) < 2 && report_error)
if (sscanf(data, "%dx%dx%d", &config->width, &config->height, &config->depth) < 2 && report_error)
osd_printf_error("Illegal resolution value = %s\n", data);
const char * at_pos = strchr(data, '@');
if (at_pos)
if (sscanf(at_pos + 1, "%d", &config->refresh) < 1 && report_error)
osd_printf_error("Illegal refresh rate in resolution value = %s\n", data);
}