2021-06-27 21:09:18 +02:00
#include "fastfetch.h"
2021-02-18 22:25:36 +01:00
2021-06-27 21:09:18 +02:00
#define FF_RESOLUTION_MODULE_NAME "Resolution"
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
2022-01-02 16:55:26 +01:00
void ffPrintResolution ( FFinstance * instance )
2021-06-27 21:09:18 +02:00
{
2022-01-10 14:41:34 +01:00
#ifdef __ANDROID__
ffPrintError ( instance , FF_RESOLUTION_MODULE_NAME , 0 , & instance -> config . resolutionKey , & instance -> config . resolutionFormat , FF_RESOLUTION_NUM_FORMAT_ARGS , "Resolution detection is not supported on Android" );
return ;
#endif
2022-01-02 16:55:26 +01:00
const FFDisplayServerResult * dsResult = ffConnectDisplayServer ( instance );
2021-07-02 22:43:58 +02:00
2022-01-02 16:55:26 +01:00
for ( uint32_t i = 0 ; i < dsResult -> resolutions . length ; i ++ )
2021-07-02 22:43:58 +02:00
{
2022-01-02 16:55:26 +01:00
FFResolutionResult * result = ffListGet ( & dsResult -> resolutions , i );
2022-01-22 23:01:09 +01:00
uint8_t moduleIndex = dsResult -> resolutions . length == 1 ? 0 : ( uint8_t ) ( i + 1 );
2021-07-06 21:15:08 +02:00
if ( instance -> config . resolutionFormat . length == 0 )
{
ffPrintLogoAndKey ( instance , FF_RESOLUTION_MODULE_NAME , moduleIndex , & instance -> config . resolutionKey );
printf ( "%ix%i" , result -> width , result -> height );
if ( result -> refreshRate > 0 )
printf ( " @ %iHz" , result -> refreshRate );
putchar ( '\n' );
}
else
{
ffPrintFormatString ( instance , FF_RESOLUTION_MODULE_NAME , moduleIndex , & instance -> config . resolutionKey , & instance -> config . resolutionFormat , NULL , FF_RESOLUTION_NUM_FORMAT_ARGS , ( FFformatarg []) {
{ FF_FORMAT_ARG_TYPE_INT , & result -> width },
{ FF_FORMAT_ARG_TYPE_INT , & result -> height },
{ FF_FORMAT_ARG_TYPE_INT , & result -> refreshRate }
});
}
2021-07-02 22:43:58 +02:00
}
2022-01-02 16:55:26 +01:00
if ( dsResult -> resolutions . length == 0 )
ffPrintError ( instance , FF_RESOLUTION_MODULE_NAME , 0 , & instance -> config . resolutionKey , & instance -> config . resolutionFormat , FF_RESOLUTION_NUM_FORMAT_ARGS , "Couldn't detect resolution" );
2021-06-27 21:09:18 +02:00
}