Gamepad / Keyboard / Mouse: improves device error handling and memory cleanup

This commit is contained in:
李通洲
2025-09-19 13:36:02 +08:00
parent 0bb5b4cc9c
commit 403900639c
3 changed files with 41 additions and 28 deletions
+16 -13
View File
@@ -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)
+12 -9
View File
@@ -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)
+13 -6
View File
@@ -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)