2021-06-27 21:09:18 +02:00
|
|
|
#include "fastfetch.h"
|
2022-07-25 13:15:01 +02:00
|
|
|
#include "common/printing.h"
|
2022-09-06 15:42:37 +02:00
|
|
|
#include "detection/displayserver/displayserver.h"
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
#define FF_RESOLUTION_MODULE_NAME "Display"
|
2021-06-27 21:09:18 +02:00
|
|
|
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
|
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
void ffPrintDisplay(FFinstance* instance)
|
2021-06-27 21:09:18 +02:00
|
|
|
{
|
2022-01-10 14:41:34 +01:00
|
|
|
#ifdef __ANDROID__
|
2023-01-18 01:37:47 +08:00
|
|
|
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.display, "Display detection is not supported on Android");
|
2022-01-10 14:41:34 +01:00
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-02 16:55:26 +01:00
|
|
|
const FFDisplayServerResult* dsResult = ffConnectDisplayServer(instance);
|
2021-07-02 22:43:58 +02:00
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
for(uint32_t i = 0; i < dsResult->displays.length; i++)
|
2021-07-02 22:43:58 +02:00
|
|
|
{
|
2023-01-18 01:37:47 +08:00
|
|
|
FFDisplayResult* result = ffListGet(&dsResult->displays, i);
|
|
|
|
|
uint8_t moduleIndex = dsResult->displays.length == 1 ? 0 : (uint8_t) (i + 1);
|
2021-07-06 21:15:08 +02:00
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
if(instance->config.display.outputFormat.length == 0)
|
2021-07-06 21:15:08 +02:00
|
|
|
{
|
2023-01-18 01:37:47 +08:00
|
|
|
ffPrintLogoAndKey(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.display.key);
|
2021-07-06 21:15:08 +02:00
|
|
|
printf("%ix%i", result->width, result->height);
|
|
|
|
|
|
|
|
|
|
if(result->refreshRate > 0)
|
|
|
|
|
printf(" @ %iHz", result->refreshRate);
|
|
|
|
|
|
|
|
|
|
putchar('\n');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-18 01:37:47 +08:00
|
|
|
ffPrintFormat(instance, FF_RESOLUTION_MODULE_NAME, moduleIndex, &instance->config.display, FF_RESOLUTION_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
2021-07-06 21:15:08 +02:00
|
|
|
{FF_FORMAT_ARG_TYPE_INT, &result->width},
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_INT, &result->height},
|
2023-01-09 19:53:41 +08:00
|
|
|
{FF_FORMAT_ARG_TYPE_INT, &result->refreshRate}
|
2021-07-06 21:15:08 +02:00
|
|
|
});
|
|
|
|
|
}
|
2021-07-02 22:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-18 01:37:47 +08:00
|
|
|
if(dsResult->displays.length == 0)
|
|
|
|
|
ffPrintError(instance, FF_RESOLUTION_MODULE_NAME, 0, &instance->config.display, "Couldn't detect display");
|
2021-06-27 21:09:18 +02:00
|
|
|
}
|