2020-09-10 13:57:44 +10:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 The ZMK Contributors
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*/
|
|
|
|
|
2020-05-18 23:11:46 +10:00
|
|
|
#pragma once
|
2020-05-04 05:49:33 +10:00
|
|
|
|
2020-06-22 11:43:44 +10:00
|
|
|
#include <devicetree.h>
|
|
|
|
|
2020-05-07 00:04:19 +10:00
|
|
|
#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan)
|
2020-05-25 08:22:16 +10:00
|
|
|
|
2020-06-27 14:16:15 +10:00
|
|
|
#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)
|
|
|
|
|
2020-09-14 12:53:24 +10:00
|
|
|
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, rows)
|
|
|
|
#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, columns)
|
2020-06-27 14:16:15 +10:00
|
|
|
|
|
|
|
#else /* DT_HAS_CHOSEN(zmk_matrix_transform) */
|
|
|
|
|
2020-09-14 12:53:24 +10:00
|
|
|
#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)
|
2020-06-25 00:06:35 +10:00
|
|
|
#define ZMK_MATRIX_ROWS 1
|
2020-09-14 12:53:24 +10:00
|
|
|
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, input_gpios)
|
2020-05-25 08:22:16 +10:00
|
|
|
#else
|
2020-09-14 12:53:24 +10:00
|
|
|
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID, rows)
|
|
|
|
#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID, columns)
|
2020-05-25 08:22:16 +10:00
|
|
|
#endif
|
2020-05-04 05:49:33 +10:00
|
|
|
|
2020-06-27 14:16:15 +10:00
|
|
|
#define ZMK_KEYMAP_LEN (ZMK_MATRIX_COLS * ZMK_MATRIX_ROWS)
|
|
|
|
|
|
|
|
#endif /* !DT_HAS_CHOSEN(zmk_matrix_transform) */
|