Index: trunk/src/brave.c =================================================================== --- trunk/src/brave.c (revision 12710) +++ trunk/src/brave.c (revision 12711) @@ -29,11 +29,14 @@ #include "brave.h" #include "conf_core.h" +#include "conf_hid.h" #include "compat_misc.h" #include "error.h" #include "hid_dad.h" pcb_brave_t pcb_brave = 0; +static const char brave_cookie[] = "brave"; +static conf_hid_id_t brave_conf_id; typedef struct { pcb_brave_t bit; @@ -73,11 +76,35 @@ /* truncate last comma */ gds_truncate(&tmp, gds_len(&tmp)-1); - conf_set(CFR_USER, "rc/brave", 0, tmp.array, POL_OVERWRITE); + conf_set(CFR_DESIGN, "rc/brave", 0, tmp.array, POL_OVERWRITE); gds_uninit(&tmp); } +static void brave_conf_chg(conf_native_t *cfg, int arr_idx) +{ + char *curr, *next, old; + desc_t *d; + + pcb_brave = 0; + if ((conf_core.rc.brave == NULL) || (*conf_core.rc.brave == '\0')) + return; + for(curr = (char *)conf_core.rc.brave; *curr != '\0'; curr = next) { + next = strpbrk(curr, ", "); + if (next == NULL) + next = curr + strlen(curr); + old = *next; + *next = '\0'; + d = find_by_name(curr); + + if (d != NULL) + pcb_brave |= d->bit; + *next = old; + next++; + while((*next == ',') || (*next == ' ')) next++; + } +} + static void brave_set(pcb_brave_t bit, int on) { int state = pcb_brave & bit; @@ -130,3 +157,16 @@ PCB_REGISTER_ACTIONS(brave_action_list, NULL) + +void pcb_brave_init(void) +{ + conf_native_t *n = conf_get_field("rc/brave"); + brave_conf_id = conf_hid_reg(brave_cookie, NULL); + + if (n != NULL) { + static conf_hid_callbacks_t cbs; + memset(&cbs, 0, sizeof(conf_hid_callbacks_t)); + cbs.val_change_post = brave_conf_chg; + conf_hid_set_cb(n, brave_conf_id, &cbs); + } +} Index: trunk/src/brave.h =================================================================== --- trunk/src/brave.h (revision 12710) +++ trunk/src/brave.h (revision 12711) @@ -8,4 +8,6 @@ extern pcb_brave_t pcb_brave; /* cache generated from the config */ +void pcb_brave_init(void); + #endif Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 12710) +++ trunk/src/main.c (revision 12711) @@ -40,6 +40,7 @@ #include #include "board.h" +#include "brave.h" #include "data.h" #include "error.h" #include "plug_io.h" @@ -335,6 +336,7 @@ conf_core_init(); conf_core_postproc(); /* to get all the paths initialized */ layer_vis_init(); + pcb_brave_init(); vtp0_init(&plugin_cli_conf);