mirror of https://github.com/nirenjan/libx52.git
Add a callback to apply one configuration item immediately
The configuration processing works as follows - the configuration parameters are set in memory, and an apply function applies all the changes directly to the device. While this works during startup and reload, it adds a needless overhead when processing config set commands from the command socket. This change makes it such that a `config set` command would update the configuration for that particular key, and then immediately call the callback function for that key. This has the effect that individual configuration changes are visible immediately, without having to reapply every other configuration that hasn't changed. This commit also removes the `config apply` command, since it is no longer needed. The `config load` and `config reload` already handle applying the configuration after reading it.reverse-scroll
parent
cf6811d923
commit
98822190ed
|
@ -273,6 +273,7 @@ static void cmd_config(char *buffer, int *buflen, int argc, char **argv)
|
|||
ERR_fmt("Error %d setting '%s.%s'='%s': %s", rc,
|
||||
argv[2], argv[3], argv[4], strerror(rc));
|
||||
} else {
|
||||
x52d_config_apply_immediate(argv[2], argv[3]);
|
||||
OK("config", "set", argv[2], argv[3], argv[4]);
|
||||
}
|
||||
} else {
|
||||
|
@ -295,16 +296,6 @@ static void cmd_config(char *buffer, int *buflen, int argc, char **argv)
|
|||
return;
|
||||
}
|
||||
|
||||
MATCH(1, "apply") {
|
||||
if (argc == 2) {
|
||||
x52d_config_apply();
|
||||
OK("config", "apply");
|
||||
} else {
|
||||
ERR_fmt("Unexpected arguments for 'config apply' command; got %d, expected 2", argc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_fmt("Unknown subcommand '%s' for 'config' command", argv[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,20 @@ void x52d_cfg_set_Profiles_Directory(char* param) { (void)param; }
|
|||
void x52d_cfg_set_Profiles_ClutchEnabled(bool param) { (void)param; }
|
||||
void x52d_cfg_set_Profiles_ClutchLatched(bool param) { (void)param; }
|
||||
|
||||
void x52d_config_apply_immediate(const char *section, const char *key)
|
||||
{
|
||||
#define CFG(c_sec, c_key, name, parser, def) \
|
||||
if (!strcasecmp(section, #c_sec) && !strcasecmp(key, #c_key)) { \
|
||||
PINELOG_TRACE("Invoking " #c_sec "." #c_key " callback"); \
|
||||
x52d_cfg_set_ ## c_sec ## _ ## c_key(x52d_config . name); \
|
||||
} else
|
||||
|
||||
#include "x52d_config.def"
|
||||
// Dummy to capture the trailing else
|
||||
// Wrap it in braces in case tracing has been disabled
|
||||
{ PINELOG_TRACE("Ignoring apply_immediate(%s.%s)", section, key); }
|
||||
}
|
||||
|
||||
void x52d_config_apply(void)
|
||||
{
|
||||
#define CFG(section, key, name, parser, def) \
|
||||
|
|
|
@ -89,6 +89,7 @@ int x52d_config_apply_overrides(struct x52d_config *cfg);
|
|||
void x52d_config_clear_overrides(void);
|
||||
|
||||
void x52d_config_load(const char *cfg_file);
|
||||
void x52d_config_apply_immediate(const char *section, const char *key);
|
||||
void x52d_config_apply(void);
|
||||
|
||||
int x52d_config_save_file(struct x52d_config *cfg, const char *cfg_file);
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: libx52 0.2.3\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
||||
"POT-Creation-Date: 2022-02-03 11:11-0800\n"
|
||||
"POT-Creation-Date: 2022-02-11 13:23-0800\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -678,12 +678,12 @@ msgstr ""
|
|||
msgid "Timed out when polling for command"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_command.c:499
|
||||
#: daemon/x52d_command.c:490
|
||||
#, c-format
|
||||
msgid "Error reading from client %d: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_command.c:510
|
||||
#: daemon/x52d_command.c:501
|
||||
#, c-format
|
||||
msgid "Short write to client %d; expected %d bytes, wrote %d bytes"
|
||||
msgstr ""
|
||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: libx52 0.2.3\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
||||
"POT-Creation-Date: 2022-02-03 11:11-0800\n"
|
||||
"POT-Creation-Date: 2022-02-11 13:23-0800\n"
|
||||
"PO-Revision-Date: 2021-11-04 15:35-0700\n"
|
||||
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
|
||||
"Language-Team: Dummy Language for testing i18n\n"
|
||||
|
@ -729,12 +729,12 @@ msgstr "Erroray enwhay ollingpay orfay ommandcay: %s"
|
|||
msgid "Timed out when polling for command"
|
||||
msgstr "Imedtay outay enwhay ollingpay orfay ommandcay"
|
||||
|
||||
#: daemon/x52d_command.c:499
|
||||
#: daemon/x52d_command.c:490
|
||||
#, c-format
|
||||
msgid "Error reading from client %d: %s"
|
||||
msgstr "Erroray eadingray omfray ientclay %d: %s"
|
||||
|
||||
#: daemon/x52d_command.c:510
|
||||
#: daemon/x52d_command.c:501
|
||||
#, c-format
|
||||
msgid "Short write to client %d; expected %d bytes, wrote %d bytes"
|
||||
msgstr ""
|
||||
|
|
Loading…
Reference in New Issue