suggestion picker: a persistent layer to complement virtual keyboards like wvkbd
Diffstat (limited to 'keyboard.c')
| -rw-r--r-- | keyboard.c | 89 |
1 files changed, 11 insertions, 78 deletions
@@ -145,61 +145,26 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) { void kbd_release_key(struct kbd *kb, uint32_t time) { kbd_unpress_key(kb, time); - if (kb->print_intersect && kb->last_swipe) { - printf("\n"); - // Important so autocompleted words get typed in time - fflush(stdout); - kbd_draw_layout(kb); - kb->last_swipe = NULL; - } + printf("\n"); + // Important so autocompleted words get typed in time + fflush(stdout); + kbd_draw_layout(kb); } void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) { - // Output intersecting keys - // (for external 'swiping'-based accelerators). - if (kb->print_intersect) { - if (kb->last_press) { - kbd_unpress_key(kb, time); - // Redraw last press as a swipe. - kbd_draw_key(kb, kb->last_swipe, Swipe); - } - struct key *intersect_key; - intersect_key = kbd_get_key(kb, x, y); - if (intersect_key && - (!kb->last_swipe || intersect_key->label != kb->last_swipe->label)) { - kbd_print_key_stdout(kb, intersect_key); - kb->last_swipe = intersect_key; - kbd_draw_key(kb, kb->last_swipe, Swipe); - } - } else { - kbd_unpress_key(kb, time); - } + } void kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) { - if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) && - (k->layout)) { - kb->compose++; - if (kb->debug) - fprintf(stderr, "showing compose %d\n", kb->compose); - kbd_switch_layout(kb, k->layout); - return; - } + switch (k->type) { case Code: - - kb->last_swipe = kb->last_press = k; + kb->last_press = k; kbd_draw_key(kb, k, Press); - if (kb->print || kb->print_intersect) - kbd_print_key_stdout(kb, k); - if (kb->compose) { - if (kb->debug) - fprintf(stderr, "pressing composed key\n"); - kb->compose++; - } + kbd_print_key_stdout(kb, k); break; default: break; @@ -208,47 +173,15 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) { void kbd_print_key_stdout(struct kbd *kb, struct key *k) { - /* printed keys may slightly differ from the actual output - * we generally print what is on the key LABEL and only support the normal - * and shift layers. Other modifiers produce no output (Ctrl,Alt) - * */ - - bool handled = true; - if (k->type == Code) { - switch (k->code) { - case KEY_SPACE: - printf(" "); - break; - case KEY_ENTER: - printf("\n"); - break; - case KEY_BACKSPACE: - printf("\b"); - break; - case KEY_TAB: - printf("\t"); - break; - default: - handled = false; - break; - } - } else if (k->type != Copy) { - return; - } - - if (!handled) { - if ((kb->mods & Shift) || (kb->mods & CapsLock)) - printf("%s", k->shift_label); - else if (!(kb->mods & Ctrl) && !(kb->mods & Alt) && !(kb->mods & Super)) - printf("%s", k->label); - } + /* we generally print what is on the key LABEL and only support the normal */ + printf("%s", k->label); fflush(stdout); } void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) { struct drwsurf *d = kb->surf; - const char *label = (kb->mods & Shift) ? k->shift_label : k->label; + const char *label = k->label; if (kb->debug) fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h, label); |