summaryrefslogtreecommitdiff
path: root/src/keymap.c
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-05-03 15:49:33 -0400
committerPete Johanson <peter@peterjohanson.com>2020-05-03 15:49:33 -0400
commitfe961d54a351a793c9037f78a42ae07eddec7d69 (patch)
tree32a2c446adb875c4027d6935e1e27b0e7774c8a0 /src/keymap.c
parent7b4394b3e775e4be06dd80a3f967b0c28ba74d14 (diff)
Start to get layers + keymaps pulled in from DTS.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/keymap.c b/src/keymap.c
new file mode 100644
index 0000000..ecfce59
--- /dev/null
+++ b/src/keymap.c
@@ -0,0 +1,34 @@
+
+#include "keymap.h"
+
+static enum hid_kbd_code zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_MATRIX_ROWS * ZMK_MATRIX_COLS] = {
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,0)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,0,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,1)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,1,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,2)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,2,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,3)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,3,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,4)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,4,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,5)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,5,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,6)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,6,keys),
+#endif
+#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE,layers,7)
+ DT_PROP_BY_PHANDLE_IDX(ZMK_KEYMAP_NODE,layers,7,keys),
+#endif
+};
+
+enum hid_kbd_code zmk_keymap_keycode_from_position(u32_t row, u32_t column)
+{
+ return zmk_keymap[0][(row * ZMK_MATRIX_ROWS) + column];
+}