aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/module/drivers/kscan/kscan_gpio_direct.c11
-rw-r--r--app/module/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml6
2 files changed, 14 insertions, 3 deletions
diff --git a/app/module/drivers/kscan/kscan_gpio_direct.c b/app/module/drivers/kscan/kscan_gpio_direct.c
index a10190da9e..e05eb2f3da 100644
--- a/app/module/drivers/kscan/kscan_gpio_direct.c
+++ b/app/module/drivers/kscan/kscan_gpio_direct.c
@@ -42,9 +42,14 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#define COND_POLL_OR_INTERRUPTS(pollcode, intcode) \
COND_CODE_1(CONFIG_ZMK_KSCAN_DIRECT_POLLING, pollcode, intcode)
-#define INST_INPUTS_LEN(n) DT_INST_PROP_LEN(n, input_gpios)
+#define INST_INPUTS_LEN(n) \
+ COND_CODE_1(DT_INST_NODE_HAS_PROP(n, input_gpios), (DT_INST_PROP_LEN(n, input_gpios)), \
+ (DT_INST_PROP_LEN(n, input_keys)))
+
#define KSCAN_DIRECT_INPUT_CFG_INIT(idx, inst_idx) \
KSCAN_GPIO_GET_BY_IDX(DT_DRV_INST(inst_idx), input_gpios, idx)
+#define KSCAN_KEY_DIRECT_INPUT_CFG_INIT(idx, inst_idx) \
+ KSCAN_GPIO_GET_BY_IDX(DT_INST_PROP_BY_IDX(inst_idx, input_keys, idx), gpios, 0)
struct kscan_direct_irq_callback {
const struct device *dev;
@@ -347,7 +352,9 @@ static const struct kscan_driver_api kscan_direct_api = {
"ZMK_KSCAN_DEBOUNCE_RELEASE_MS or debounce-release-ms is too large"); \
\
static struct kscan_gpio kscan_direct_inputs_##n[] = { \
- LISTIFY(INST_INPUTS_LEN(n), KSCAN_DIRECT_INPUT_CFG_INIT, (, ), n)}; \
+ COND_CODE_1(DT_INST_NODE_HAS_PROP(n, input_gpios), \
+ (LISTIFY(INST_INPUTS_LEN(n), KSCAN_DIRECT_INPUT_CFG_INIT, (, ), n)), \
+ (LISTIFY(INST_INPUTS_LEN(n), KSCAN_KEY_DIRECT_INPUT_CFG_INIT, (, ), n)))}; \
\
static struct zmk_debounce_state kscan_direct_state_##n[INST_INPUTS_LEN(n)]; \
\
diff --git a/app/module/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml b/app/module/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml
index f477b591f8..4953d5cfaf 100644
--- a/app/module/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml
+++ b/app/module/dts/bindings/kscan/zmk,kscan-gpio-direct.yaml
@@ -10,7 +10,11 @@ include: kscan.yaml
properties:
input-gpios:
type: phandle-array
- required: true
+ required: false
+ input-keys:
+ type: phandles
+ required: false
+ description: List of gpio-key references
debounce-period:
type: int
required: false