diff options
| author | Zach DeCook <zachdecook@librem.one> | 2022-06-24 11:10:18 -0400 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2022-06-24 11:10:18 -0400 |
| commit | 213187bbf419e847c50d49d0d1299935cbcd087f (patch) | |
| tree | c9b4d76edcbb8622c72e8af57cf99143edc0eca9 /keyboard.c | |
| parent | 534808211f04779ef87848f2b67daee333420bb3 (diff) | |
| download | suggpicker-213187bbf419e847c50d49d0d1299935cbcd087f.tar.gz | |
suggpicker: Allow changing mind about which one you want to pick
Diffstat (limited to 'keyboard.c')
| -rw-r--r-- | keyboard.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/keyboard.c b/keyboard.c index 5de8d6b..a02d5a2 100644 --- a/keyboard.c +++ b/keyboard.c @@ -15,9 +15,9 @@ void kbd_init(struct kbd *kb) { fprintf(stderr, "Initializing keyboard\n"); - kb->suggs[0].label = strdup("Hello"); - kb->suggs[1].label = strdup("Sugar"); - kb->suggs[2].label = strdup("Pie"); + kb->suggs[0].label = strdup("Hey"); + kb->suggs[1].label = strdup("Honey"); + kb->suggs[2].label = strdup("Bunches"); kb->suggs[3].label = NULL; } @@ -74,16 +74,25 @@ kbd_unpress_key(struct kbd *kb) { void kbd_release_key(struct kbd *kb) { - kbd_unpress_key(kb); - printf("\n"); - // Important so autocompleted words get typed in time - fflush(stdout); - kbd_draw_layout(kb); + if (kb->last_press) { + printf("%s\n", kb->last_press->label); + // Important so autocompleted words get typed in time + fflush(stdout); + kbd_unpress_key(kb); + kbd_draw_layout(kb); + } } void kbd_motion_key(struct kbd *kb, uint32_t x, uint32_t y) { - + struct key *next_key; + next_key = kbd_get_key(kb, x, y); + if (next_key != kb->last_press) { + kbd_unpress_key(kb); + if (next_key) { + kbd_press_key(kb, next_key); + } + } } void @@ -91,8 +100,6 @@ kbd_press_key(struct kbd *kb, struct key *k) { if (k->label) { kb->last_press = k; kbd_draw_key(kb, k, Press); - printf("%s", k->label); - fflush(stdout); } } |
