From 06558064013c61477a41c0821586c4443638cc2b Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 3 Aug 2025 16:34:25 -0400 Subject: liboda: input: Add constant 'ODA_KEY_*' defines Signed-off-by: Ian Moffett --- lib/liboda/src/input.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/liboda/src') diff --git a/lib/liboda/src/input.c b/lib/liboda/src/input.c index 88c4256..797a9d4 100644 --- a/lib/liboda/src/input.c +++ b/lib/liboda/src/input.c @@ -27,12 +27,38 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include +#include #include #include #include #include +/* + * Convert key scancode/char values to fixed + * ODA key constants + */ +static inline uint16_t +oda_map_key(const struct oda_key *key) +{ + uint16_t type = ODA_KEY_OTHER; + + switch (key->ch) { + case ASCII_ESC: + type = ODA_KEY_ESCAPE; + break; + case ASCII_HT: + type = ODA_KEY_TAB; + break; + case ASCII_BS: + type = ODA_KEY_BACKSPACE; + break; + } + + return type; +} + /* * Dispatch keyboard events. This is typically * called in an event loop so that keyboard events @@ -57,5 +83,6 @@ oda_kbd_dispatch(struct oda_kbd *kbd) key.scancode = ODA_SCANCODE(input); key.ch = ODA_KEYCHAR(input); + key.type = oda_map_key(&key); return kbd->handle_keyev(kbd, &key); } -- cgit v1.2.3