mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Gamepad / Keyboard / Mouse: improves device error handling and memory cleanup
This commit is contained in:
@@ -87,26 +87,29 @@ bool ffPrintGamepad(FFGamepadOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if(!filtered.length)
|
||||
{
|
||||
ffPrintError(FF_GAMEPAD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "All devices are ignored");
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice*, pdevice, filtered)
|
||||
else
|
||||
{
|
||||
FFGamepadDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice*, pdevice, filtered)
|
||||
{
|
||||
FFGamepadDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice, device, result)
|
||||
{
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFGamepadDevice, device, result)
|
||||
{
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ffParseGamepadJsonObject(FFGamepadOptions* options, yyjson_val* module)
|
||||
|
||||
@@ -58,22 +58,25 @@ bool ffPrintKeyboard(FFKeyboardOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if(!filtered.length)
|
||||
{
|
||||
ffPrintError(FF_KEYBOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "All devices are ignored");
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFKeyboardDevice*, pdevice, filtered)
|
||||
else
|
||||
{
|
||||
FFKeyboardDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFKeyboardDevice*, pdevice, filtered)
|
||||
{
|
||||
FFKeyboardDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ffParseKeyboardJsonObject(FFKeyboardOptions* options, yyjson_val* module)
|
||||
|
||||
@@ -58,22 +58,29 @@ bool ffPrintMouse(FFMouseOptions* options)
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if(!filtered.length)
|
||||
{
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "All devices are ignored");
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFMouseDevice*, pdevice, filtered)
|
||||
{
|
||||
FFMouseDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFMouseDevice*, pdevice, filtered)
|
||||
FF_LIST_FOR_EACH(FFMouseDevice, device, result)
|
||||
{
|
||||
FFMouseDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ffParseMouseJsonObject(FFMouseOptions* options, yyjson_val* module)
|
||||
|
||||
Reference in New Issue
Block a user