Monitor (macOS): detect maximum refresh rate

This commit is contained in:
李通洲
2024-07-18 13:46:26 +08:00
parent 2a49f1d0eb
commit 0d71ae7f97
5 changed files with 23 additions and 1 deletions
+7 -1
View File
@@ -6,7 +6,7 @@
#include <math.h>
#define FF_MONITOR_NUM_FORMAT_ARGS 10
#define FF_MONITOR_NUM_FORMAT_ARGS 11
void ffPrintMonitor(FFMonitorOptions* options)
{
@@ -52,6 +52,8 @@ void ffPrintMonitor(FFMonitorOptions* options)
ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY);
printf("%ux%u px", display->width, display->height);
if (display->refreshRate > 0)
printf(" @ %.2f Hz", display->refreshRate);
if (inch > 0)
printf(" - %ux%u mm (%.2f inches, %.2f ppi)\n", display->physicalWidth, display->physicalHeight, inch, ppi);
else
@@ -79,6 +81,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureYear, "manufacture-year"},
{FF_FORMAT_ARG_TYPE_UINT16, &display->manufactureWeek, "manufacture-week"},
{FF_FORMAT_ARG_TYPE_STRING, buf, "serial"},
{FF_FORMAT_ARG_TYPE_DOUBLE, buf, "refresh-rate"},
}));
}
@@ -153,6 +156,8 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs
yyjson_mut_obj_add_uint(doc, physical, "height", item->physicalHeight);
yyjson_mut_obj_add_uint(doc, physical, "width", item->physicalWidth);
yyjson_mut_obj_add_real(doc, obj, "refreshRate", item->refreshRate);
if (item->manufactureYear)
{
yyjson_mut_val* manufactureDate = yyjson_mut_obj_add_obj(doc, obj, "manufactureDate");
@@ -190,6 +195,7 @@ void ffPrintMonitorHelpFormat(void)
"Year of manufacturing - manufacture-year",
"Nth week of manufacturing in the year - manufacture-week",
"Serial number - serial",
"Maximum refresh rate in Hz - refresh-rate",
}));
}