Index: trunk/src/hid_cfg_input.c =================================================================== --- trunk/src/hid_cfg_input.c (revision 1454) +++ trunk/src/hid_cfg_input.c (revision 1455) @@ -83,6 +83,8 @@ static int keyeq_int(htip_key_t a, htip_key_t b) { return a == b; } static unsigned int keyhash_int(htip_key_t a) { return murmurhash32(a & 0xFFFF); } +/************************** MOUSE ***************************/ + int hid_cfg_mouse_init(hid_cfg_t *hr, hid_cfg_mouse_t *mouse) { lht_node_t *btn, *m; @@ -148,3 +150,44 @@ { hid_cfg_action(find_best_action(mouse, button_and_mask)); } + + +/************************** KEYBOARD ***************************/ +int hid_cfg_keys_init(hid_cfg_keys_t *km) +{ + htip_init(&km->keys, keyhash_int, keyeq_int); +} + +int hid_cfg_keys_uninit(hid_cfg_keys_t *km) +{ +#warning TODO: recursive free of nodes + htip_uninit(&km->keys); +} + +hid_cfg_keyseq_t *hid_cfg_keys_add_under(hid_cfg_keys_t *km, hid_cfg_keyseq_t *parent, hid_cfg_mod_t mods, short int key_char, int terminal) +{ + hid_cfg_keyseq_t *ns; + hid_cfg_keyhash_t addr; + htip_t *phash = (parent == NULL) ? &km->keys : &parent->seq_next; + + addr.details.mods = mods; + addr.details.key_char = key_char; + + /* already in the tree */ + ns = htip_get(phash, addr.hash); + if (ns != NULL) { + if (terminal) + return NULL; /* full-path-match is collision */ + return ns; + } + + /* new node on this level */ + ns = calloc(sizeof(hid_cfg_keyseq_t), 1); + htip_set(phash, addr.hash, ns); + return ns; +} + +int hid_cfg_keys_add_by_desc(hid_cfg_keys_t *km, const char *keydesc, hid_cfg_keyseq_t **out_seq, int out_seq_len) +{ + +} Index: trunk/src/hid_cfg_input.h =================================================================== --- trunk/src/hid_cfg_input.h (revision 1454) +++ trunk/src/hid_cfg_input.h (revision 1455) @@ -70,6 +70,12 @@ */ int hid_cfg_keys_init(hid_cfg_keys_t *km); +#warning TODO: desc +int hid_cfg_keys_uninit(hid_cfg_keys_t *km); + +#warning TODO: desc +hid_cfg_keyseq_t *hid_cfg_keys_add_under(hid_cfg_keys_t *km, hid_cfg_keyseq_t *parent, hid_cfg_mod_t mods, short int key_char, int terminal); + /* 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. @@ -87,7 +93,7 @@ + a positive integer means the lookup succeeded and the return value is the length of the resulting sequence. */ -int hid_cfg_keys_input(hid_cfg_keys_t *km, hid_cfg_mod_t mod, short int key_char, hid_cfg_keyseq_t **seq, int *seq_len, int seq_len_max); +int hid_cfg_keys_input(hid_cfg_keys_t *km, hid_cfg_mod_t mods, short int key_char, hid_cfg_keyseq_t **seq, int *seq_len, int seq_len_max); /* Run the action for a key sequence looked up by hid_cfg_keys_input(). Returns: the result of the action or -1 on error */