zmk_mf68/app/include/zmk/matrix.h
Pete Johanson 5ffd95694f Kyria left/right overlays, matrix transform fixes
* Refactor Kyria into separate left/right "revisions"
  of the Kyria shield, and include central
  kyria.dtsi file with common definition.
* Fixes for keymaps to work fully with matrix
  transforms that override effective rows/columns.
* Add ability for matrix transform to do row/col
  offsets, which is needed for split keyboards.
2020-06-27 00:16:15 -04:00

30 lines
No EOL
1,016 B
C

#pragma once
#include <devicetree.h>
#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan)
#if DT_HAS_CHOSEN(zmk_matrix_transform)
#define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform)
#define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map)
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,rows)
#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,columns)
#else /* DT_HAS_CHOSEN(zmk_matrix_transform) */
#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,row_gpios)
#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios)
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios)
#elif DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,input_gpios)
#define ZMK_MATRIX_ROWS 1
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,input_gpios)
#else
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID,rows)
#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID,columns)
#endif
#define ZMK_KEYMAP_LEN (ZMK_MATRIX_COLS * ZMK_MATRIX_ROWS)
#endif /* !DT_HAS_CHOSEN(zmk_matrix_transform) */