aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-11 19:18:59 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-11 19:18:59 +0100
commit50b5427a8edbb8d59215334f5a250e7f8d6d7ca7 (patch)
tree7263505b2a6145256ce1f494108a4ceb853c4de0 /src/lib/include
parent0b76aff59b586d87ee0449bc7deda878f4633515 (diff)
downloadkogata-50b5427a8edbb8d59215334f5a250e7f8d6d7ca7.tar.gz
kogata-50b5427a8edbb8d59215334f5a250e7f8d6d7ca7.zip
Add keyboard handling code. New font thanks to Muazzam from OSDev!
Diffstat (limited to 'src/lib/include')
-rw-r--r--src/lib/include/keyboard.h37
-rw-r--r--src/lib/include/proto/keymap_file.h16
2 files changed, 53 insertions, 0 deletions
diff --git a/src/lib/include/keyboard.h b/src/lib/include/keyboard.h
new file mode 100644
index 0000000..2842936
--- /dev/null
+++ b/src/lib/include/keyboard.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <proto/keymap_file.h>
+
+
+#define KBD_CHAR 0x01
+#define KBD_ALT 0x02
+#define KBD_CTRL 0x04
+#define KBD_SUPER 0x08
+#define KBD_SHIFT 0x10
+#define KBD_CAPS 0x20
+#define KBD_MOD 0x40
+
+typedef struct {
+ union {
+ int chr; // if flags & KBD_CHAR, chr is a character number
+ int key; // if !(flags & KBD_CHAR), key is one of KBD_CODE_* defined in <proto/keyboard.h>
+ };
+ uint32_t flags; // one of kbd_*
+} key_t;
+
+typedef struct {
+ keymap_t km;
+ uint32_t status; // mask of alt/ctrl/super
+} keyboard_t;
+
+keyboard_t *init_keyboard();
+void free_keyboard(keyboard_t *t);
+
+bool load_keymap(keyboard_t *kb, const char* kmname);
+
+key_t keyboard_press(keyboard_t *t, int scancode); // what key is pressed?
+key_t keyboard_release(keyboard_t *t, int scancode); // what key is released?
+
+
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/src/lib/include/proto/keymap_file.h b/src/lib/include/proto/keymap_file.h
new file mode 100644
index 0000000..53ffeb7
--- /dev/null
+++ b/src/lib/include/proto/keymap_file.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+typedef struct {
+ int normal[128];
+ int shift[128];
+ int caps[128];
+ int mod[128];
+ int shiftmod[128];
+ bool ralt_is_mod; // true: right alt = alt-gr
+} keymap_t;
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/