mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-01 02:22:52 +01:00
Merge branch 'dev' of github.com:LinusDierheimer/fastfetch into dev
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include "common/printing.h"
|
||||
#include "detection/gamepad/gamepad.h"
|
||||
|
||||
#define FF_GAMEPAD_MODULE_NAME "Gamepad"
|
||||
#define FF_GAMEPAD_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFinstance* instance, const FFGamepadDevice* device, uint8_t index)
|
||||
{
|
||||
if(instance->config.sound.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_GAMEPAD_MODULE_NAME, index, &instance->config.sound.key);
|
||||
ffStrbufPutTo(&device->name, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_GAMEPAD_MODULE_NAME, index, &instance->config.sound, FF_GAMEPAD_NUM_FORMAT_ARGS, (FFformatarg[]) {
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGamepad(FFinstance* instance)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result;
|
||||
ffListInit(&result, sizeof(FFGamepadDevice));
|
||||
const char* error = ffDetectGamepad(instance, &result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &instance->config.sound, "%s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(instance, FF_GAMEPAD_MODULE_NAME, 0, &instance->config.sound, "No devices detected");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice, device, result)
|
||||
{
|
||||
printDevice(instance, device, result.length > 1 ? ++index : 0);
|
||||
ffStrbufDestroy(&device->identifier);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user