summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/keymap.c2
-rw-r--r--app/src/matrix_transform.c22
2 files changed, 15 insertions, 9 deletions
diff --git a/app/src/keymap.c b/app/src/keymap.c
index dd0fee4..f951dd7 100644
--- a/app/src/keymap.c
+++ b/app/src/keymap.c
@@ -26,7 +26,7 @@ static u8_t zmk_keymap_layer_default = 0;
#define TRANSFORMED_LAYER(idx) \
{ UTIL_LISTIFY(DT_PROP_LEN(DT_PHANDLE_BY_IDX(ZMK_KEYMAP_NODE, layers, idx), bindings), _TRANSFORM_ENTRY, idx) }
-static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_MATRIX_ROWS * ZMK_MATRIX_COLS] = {
+static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = {
#if DT_PROP_HAS_IDX(ZMK_KEYMAP_NODE, layers, 0)
TRANSFORMED_LAYER(0),
#endif
diff --git a/app/src/matrix_transform.c b/app/src/matrix_transform.c
index 7e8b481..7ecf1ae 100644
--- a/app/src/matrix_transform.c
+++ b/app/src/matrix_transform.c
@@ -4,11 +4,7 @@
#include <zmk/matrix.h>
#include <dt-bindings/zmk/matrix-transform.h>
-#define HAS_TRANSFORM DT_HAS_CHOSEN(zmk_matrix_transform)
-
-#if HAS_TRANSFORM
-#define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform)
-#define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map)
+#ifdef ZMK_KEYMAP_TRANSFORM_NODE
#define _TRANSFORM_ENTRY(i, _) \
[(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i,
@@ -20,11 +16,21 @@ static u32_t transform[] =
u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column)
{
- u32_t matrix_index = (row * ZMK_MATRIX_COLS) + column;
+ u32_t matrix_index;
+
+#if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset)
+ column += DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset);
+#endif
+
+#if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, row_offset)
+ row += DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, row_offset);
+#endif
+
+ matrix_index = (row * ZMK_MATRIX_COLS) + column;
-#if HAS_TRANSFORM
+#ifdef ZMK_KEYMAP_TRANSFORM_NODE
return transform[matrix_index];
#else
return matrix_index;
-#endif /* HAS_TRANSFORM */
+#endif /* ZMK_KEYMAP_TRANSFORM_NODE */
};