From 213187bbf419e847c50d49d0d1299935cbcd087f Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Fri, 24 Jun 2022 11:10:18 -0400 Subject: suggpicker: Allow changing mind about which one you want to pick --- keyboard.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'keyboard.c') 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); } } -- cgit 1.4.1