Battery (Windows): add flag --battery-use-setup-api

This commit is contained in:
李通洲
2023-10-30 14:49:00 +08:00
parent b462006280
commit ae34208247
6 changed files with 34 additions and 2 deletions
+23
View File
@@ -122,6 +122,14 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co
}
#endif
#ifdef _WIN32
if (ffStrEqualsIgnCase(subKey, "use-setup-api"))
{
options->useSetupApi = ffOptionParseBoolean(value);
return true;
}
#endif
return false;
}
@@ -146,6 +154,14 @@ void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module)
}
#endif
#ifdef _WIN32
if (ffStrEqualsIgnCase(key, "useSetupApi"))
{
options->useSetupApi = yyjson_get_bool(val);
continue;
}
#endif
if (ffStrEqualsIgnCase(key, "temp"))
{
options->temp = yyjson_get_bool(val);
@@ -168,6 +184,11 @@ void ffGenerateBatteryJsonConfig(FFBatteryOptions* options, yyjson_mut_doc* doc,
yyjson_mut_obj_add_strbuf(doc, module, "dir", &options->dir);
#endif
#ifdef _WIN32
if (defaultOptions.useSetupApi != options->useSetupApi)
yyjson_mut_obj_add_bool(doc, module, "useSetupApi", options->useSetupApi);
#endif
if (options->temp != defaultOptions.temp)
yyjson_mut_obj_add_bool(doc, module, "temp", options->temp);
}
@@ -233,6 +254,8 @@ void ffInitBatteryOptions(FFBatteryOptions* options)
#ifdef __linux__
ffStrbufInit(&options->dir);
#elif defined(_WIN32)
options->useSetupApi = false;
#endif
}
+2
View File
@@ -13,5 +13,7 @@ typedef struct FFBatteryOptions
#ifdef __linux__
FFstrbuf dir;
#elif defined(_WIN32)
bool useSetupApi;
#endif
} FFBatteryOptions;