Modules: return bool to indicate whether the detection is succeeded

This commit is contained in:
李通洲
2025-08-18 13:38:30 +08:00
parent a9aaa36b2c
commit 3b5e9c74d6
147 changed files with 869 additions and 538 deletions
+9 -5
View File
@@ -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)
+1 -1
View File
@@ -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);