Skip to content

Commit

Permalink
refactor: Add kscan sideband behavior driver
Browse files Browse the repository at this point in the history
* Instead of gpio key behavior trigger, add new kscan driver that
  decorates/wraps a given kscan driver and will invoke basic system
  behavior assigned to a given row + column, without the need for keymap
  mapping in the matrix transform, bypassing keymaps entirely.
  • Loading branch information
petejohanson committed Mar 28, 2024
1 parent e78b25a commit a0ad1d4
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 209 deletions.
2 changes: 1 addition & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ target_sources(app PRIVATE src/stdlib.c)
target_sources(app PRIVATE src/activity.c)
target_sources(app PRIVATE src/behavior.c)
target_sources(app PRIVATE src/kscan.c)
target_sources_ifdef(CONFIG_ZMK_KSCAN_SIDEBAND_BEHAVIORS app PRIVATE src/kscan_sideband_behaviors.c)
target_sources(app PRIVATE src/matrix_transform.c)
target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/wpm.c)
target_sources(app PRIVATE src/event_manager.c)
target_sources_ifdef(CONFIG_ZMK_GPIO_KEY_BEHAVIOR_TRIGGER app PRIVATE src/gpio_key_behavior_trigger.c)
target_sources_ifdef(CONFIG_ZMK_PM app PRIVATE src/pm.c)
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c)
target_sources_ifdef(CONFIG_ZMK_GPIO_KEY_WAKEUP_TRIGGER app PRIVATE src/gpio_key_wakeup_trigger.c)
Expand Down
6 changes: 6 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ config ZMK_KSCAN_EVENT_QUEUE_SIZE

endif # ZMK_KSCAN

config ZMK_KSCAN_SIDEBAND_BEHAVIORS
bool
default y
depends on DT_HAS_ZMK_KSCAN_SIDEBAND_BEHAVIORS_ENABLED
select KSCAN

menu "Logging"

config ZMK_LOGGING_MINIMAL
Expand Down
5 changes: 0 additions & 5 deletions app/Kconfig.behaviors
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT

config ZMK_GPIO_KEY_BEHAVIOR_TRIGGER
bool
default y
depends on DT_HAS_ZMK_GPIO_KEY_BEHAVIOR_TRIGGER_ENABLED

config ZMK_BEHAVIOR_KEY_TOGGLE
bool
default y
Expand Down
19 changes: 14 additions & 5 deletions app/boards/shields/zmk_uno/boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,19 @@ encoder: &qdec0 {
wakeup-sources = <&wakeup_source>;
};

soft_off_behavior_key {
compatible = "zmk,gpio-key-behavior-trigger";
status = "okay";
bindings = <&soft_off>;
key = <&button0>;
soft_off_direct_kscan: soft_off_direct_kscan {
compatible = "zmk,kscan-gpio-direct";
input-keys = <&button0>;
};

soft_off_sideband_behaviors {
compatible = "zmk,kscan-sideband-behaviors";
kscan = <&soft_off_direct_kscan>;
soft_off {
row = <0>;
column = <0>;
bindings = <&soft_off>;
};
};

};
29 changes: 29 additions & 0 deletions app/dts/bindings/kscan/zmk,kscan-sideband-behaviors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2023, The ZMK Contributors
# SPDX-License-Identifier: MIT

description: |
kscan sideband behavior runner. Only basic system behavior should be used,
since no keymap processing occurs when using them.
compatible: "zmk,kscan-sideband-behaviors"

include: [kscan.yaml]

properties:
kscan:
type: phandle
required: true

child-binding:
description: "A sideband behavior tied to a row/column pair"

properties:
row:
type: int
required: true
column:
type: int
required: true
bindings:
type: phandle-array
required: true
31 changes: 0 additions & 31 deletions app/dts/bindings/zmk,gpio-key-behavior-trigger.yaml

This file was deleted.

167 changes: 0 additions & 167 deletions app/src/gpio_key_behavior_trigger.c

This file was deleted.

Loading

0 comments on commit a0ad1d4

Please sign in to comment.