mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-07 21:50:08 +01:00
Modules: return bool to indicate whether the detection is succeeded
This commit is contained in:
@@ -21,7 +21,7 @@ static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, ui
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintMouse(FFMouseOptions* options)
|
||||
bool ffPrintMouse(FFMouseOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMouseDevice));
|
||||
|
||||
@@ -30,13 +30,13 @@ void ffPrintMouse(FFMouseOptions* options)
|
||||
if(error)
|
||||
{
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No devices detected");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t index = 0;
|
||||
@@ -46,6 +46,8 @@ void ffPrintMouse(FFMouseOptions* options)
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseMouseJsonObject(FFMouseOptions* options, yyjson_val* module)
|
||||
@@ -66,7 +68,7 @@ void ffGenerateMouseJsonConfig(FFMouseOptions* options, yyjson_mut_doc* doc, yyj
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
bool ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMouseDevice));
|
||||
|
||||
@@ -75,7 +77,7 @@ void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
if(error)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
|
||||
@@ -91,6 +93,8 @@ void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitMouseOptions(FFMouseOptions* options)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#define FF_MOUSE_MODULE_NAME "Mouse"
|
||||
|
||||
void ffPrintMouse(FFMouseOptions* options);
|
||||
bool ffPrintMouse(FFMouseOptions* options);
|
||||
void ffInitMouseOptions(FFMouseOptions* options);
|
||||
void ffDestroyMouseOptions(FFMouseOptions* options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user