diff options
Diffstat (limited to 'main/keyboard.h')
| -rw-r--r-- | main/keyboard.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/main/keyboard.h b/main/keyboard.h new file mode 100644 index 0000000..d7b3400 --- /dev/null +++ b/main/keyboard.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | #ifndef KEYBOARD_H | ||
| 2 | #define KEYBOARD_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | |||
| 7 | #define KB_INPUT_MAX 64 | ||
| 8 | #define KB_KEY_W 28 | ||
| 9 | #define KB_KEY_H 36 | ||
| 10 | #define KB_KEY_GAP 2 | ||
| 11 | #define KB_ROW_COUNT 4 | ||
| 12 | #define KB_START_Y 310 | ||
| 13 | |||
| 14 | typedef enum { | ||
| 15 | KB_ALPHA_LOWER, | ||
| 16 | KB_ALPHA_UPPER, | ||
| 17 | KB_NUMSYM | ||
| 18 | } kb_layer_t; | ||
| 19 | |||
| 20 | typedef enum { | ||
| 21 | KB_ACTION_NONE = 0, | ||
| 22 | KB_ACTION_CHAR, | ||
| 23 | KB_ACTION_SHIFT, | ||
| 24 | KB_ACTION_BACKSPACE, | ||
| 25 | KB_ACTION_DONE, | ||
| 26 | KB_ACTION_LAYER, | ||
| 27 | KB_ACTION_SPACE | ||
| 28 | } kb_action_t; | ||
| 29 | |||
| 30 | typedef struct { | ||
| 31 | kb_action_t action; | ||
| 32 | char ch; | ||
| 33 | } kb_result_t; | ||
| 34 | |||
| 35 | typedef struct { | ||
| 36 | char input[KB_INPUT_MAX + 1]; | ||
| 37 | int cursor; | ||
| 38 | bool reveal; | ||
| 39 | kb_layer_t layer; | ||
| 40 | } kb_state_t; | ||
| 41 | |||
| 42 | void kb_state_init(kb_state_t *st); | ||
| 43 | int kb_get_row_keys(int row, kb_layer_t layer, const char **keys_out); | ||
| 44 | kb_result_t kb_hit_test(int tx, int ty, kb_layer_t layer); | ||
| 45 | void kb_apply(kb_state_t *st, kb_result_t result); | ||
| 46 | |||
| 47 | #endif | ||