Index: src/hid_cfg_input.c =================================================================== --- src/hid_cfg_input.c (revision 1563) +++ src/hid_cfg_input.c (revision 1564) @@ -245,7 +245,7 @@ } -int hid_cfg_keys_add_by_desc(hid_cfg_keys_t *km, const lht_node_t *keydescn, const lht_node_t *action_node, hid_cfg_keyseq_t **out_seq, int out_seq_len) +int hid_cfg_keys_add_by_strdesc(hid_cfg_keys_t *km, const char *keydesc, const lht_node_t *action_node, hid_cfg_keyseq_t **out_seq, int out_seq_len) { const char *curr, *next, *last, *k; hid_cfg_mod_t mods[HIDCFG_MAX_KEYSEQ_LEN]; @@ -252,8 +252,6 @@ unsigned short int key_chars[HIDCFG_MAX_KEYSEQ_LEN]; int n, slen, len; hid_cfg_keyseq_t *lasts; -#warning TODO: keydescn may be a list - const char *keydesc = keydescn->data.text.value; slen = 0; curr = keydesc; @@ -326,6 +324,29 @@ return slen; } +int hid_cfg_keys_add_by_desc(hid_cfg_keys_t *km, const lht_node_t *keydescn, const lht_node_t *action_node, hid_cfg_keyseq_t **out_seq, int out_seq_len) +{ + switch(keydescn->type) { + case LHT_TEXT: return hid_cfg_keys_add_by_strdesc(km, keydescn->data.text.value, action_node, out_seq, out_seq_len); + case LHT_LIST: + { + int ret = -1, cnt; + lht_node_t *n; + for(n = keydescn->data.list.first, cnt = 0; n != NULL; n = n->next, cnt++) { + if (n->type != LHT_TEXT) + break; + if (cnt == 0) + ret = hid_cfg_keys_add_by_strdesc(km, n->data.text.value, action_node, out_seq, out_seq_len); + else + hid_cfg_keys_add_by_strdesc(km, n->data.text.value, action_node, NULL, 0); + } + return ret; + } + default:; + } + return -1; +} + int hid_cfg_keys_input(hid_cfg_keys_t *km, hid_cfg_mod_t mods, unsigned short int key_char, hid_cfg_keyseq_t **seq, int *seq_len) { hid_cfg_keyseq_t *ns; Index: src/hid_cfg_input.h =================================================================== --- src/hid_cfg_input.h (revision 1563) +++ src/hid_cfg_input.h (revision 1564) @@ -100,9 +100,12 @@ /* Add a new key using a description (read from a lihata file usually) If out_seq is not NULL, load the array with pointers pointing to each key in the sequence, up to out_seq_len. + When key desc is a lihata node, it may be a list (multiple keys for the + same action). In this case return value and seq are set using the first key. Returns -1 on failure or the length of the sequence. */ int hid_cfg_keys_add_by_desc(hid_cfg_keys_t *km, const lht_node_t *keydesc, const lht_node_t *action_node, hid_cfg_keyseq_t **out_seq, int out_seq_len); +int hid_cfg_keys_add_by_strdesc(hid_cfg_keys_t *km, const char *keydesc, const lht_node_t *action_node, hid_cfg_keyseq_t **out_seq, int out_seq_len); /* Process next input key stroke. Seq and seq_len must not be NULL as they are the internal state of multi-key