Skip to content

Commit

Permalink
Update global behaviors to be compiled in based on their Kconfig option
Browse files Browse the repository at this point in the history
Because global behaviors have to exist on both the central and split
regardless if the user references them in their keymap, we can't omit
the behavior declaration if the user doen't reference it and decide to
compile it later based on the existence of the behavior declaration. The
best option seems to be to decide whether to compile those behaviors
based on the feature Kconfig flag. This also means that the two reset
behaviors will always be compiled into both sides.
  • Loading branch information
bryanforbes committed Mar 6, 2024
1 parent 1ce7670 commit 72f8c50
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 34 deletions.
8 changes: 4 additions & 4 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ target_sources(app PRIVATE src/events/sensor_event.c)
target_sources(app PRIVATE src/events/mouse_button_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_WPM app PRIVATE src/events/wpm_state_changed.c)
target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/events/usb_conn_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_RESET app PRIVATE src/behaviors/behavior_reset.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
target_sources(app PRIVATE src/behaviors/behavior_reset.c)
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources(app PRIVATE src/hid.c)
target_sources_ifdef(CONFIG_ZMK_MOUSE app PRIVATE src/mouse.c)
Expand Down Expand Up @@ -80,8 +80,8 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
endif()
endif()

target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c)
target_sources_ifdef(CONFIG_ZMK_BEHAVIOR_BACKLIGHT app PRIVATE src/behaviors/behavior_backlight.c)
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c)
target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/behaviors/behavior_backlight.c)

target_sources_ifdef(CONFIG_ZMK_BATTERY_REPORTING app PRIVATE src/events/battery_state_changed.c)
target_sources_ifdef(CONFIG_ZMK_BATTERY_REPORTING app PRIVATE src/battery.c)
Expand Down
20 changes: 0 additions & 20 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_BEHAVIOR_BACKLIGHT
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_BACKLIGHT_ENABLED && ZMK_BACKLIGHT

config ZMK_BEHAVIOR_BLUETOOTH
bool
default y
Expand All @@ -16,11 +11,6 @@ config ZMK_BEHAVIOR_CAPS_WORD
default y
depends on DT_HAS_ZMK_BEHAVIOR_CAPS_WORD_ENABLED

config ZMK_BEHAVIOR_EXT_POWER
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_EXT_POWER_ENABLED && ZMK_EXT_POWER

config ZMK_BEHAVIOR_HOLD_TAP
bool
default y
Expand Down Expand Up @@ -72,16 +62,6 @@ config ZMK_BEHAVIOR_OUTPUTS
default y
depends on DT_HAS_ZMK_BEHAVIOR_OUTPUTS_ENABLED

config ZMK_BEHAVIOR_RESET
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_RESET_ENABLED

config ZMK_BEHAVIOR_RGB_UNDERGLOW
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_RGB_UNDERGLOW_ENABLED && ZMK_RGB_UNDERGLOW

config ZMK_BEHAVIOR_SENSOR_ROTATE_COMMON
bool

Expand Down
5 changes: 3 additions & 2 deletions app/dts/behaviors/backlight.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ bl: bcklight {
// Behavior can be invoked on peripherals, so name must be <= 8 characters
// and cannot be /omit-if-no-ref/
bl: bcklight {
compatible = "zmk,behavior-backlight";
#binding-cells = <2>;
};
Expand Down
5 changes: 3 additions & 2 deletions app/dts/behaviors/ext_power.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ ext_power: extpower {
// Behavior can be invoked on peripherals, so name must be <= 8 characters
// and cannot be /omit-if-no-ref/
ext_power: extpower {
compatible = "zmk,behavior-ext-power";
#binding-cells = <1>;
};
Expand Down
10 changes: 6 additions & 4 deletions app/dts/behaviors/reset.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ sys_reset: sysreset {
// Behavior can be invoked on peripherals, so name must be <= 8 characters
// and cannot be /omit-if-no-ref/
sys_reset: sysreset {
compatible = "zmk,behavior-reset";
#binding-cells = <0>;
};

// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ bootloader: bootload {
// Behavior can be invoked on peripherals, so name must be <= 8 characters
// and cannot be /omit-if-no-ref/
bootloader: bootload {
compatible = "zmk,behavior-reset";
type = <RST_UF2>;
#binding-cells = <0>;
Expand Down
5 changes: 3 additions & 2 deletions app/dts/behaviors/rgb_underglow.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ rgb_ug: rgb_ug {
// Behavior can be invoked on peripherals, so name must be <= 8 characters
// and cannot be /omit-if-no-ref/
rgb_ug: rgb_ug {
compatible = "zmk,behavior-rgb-underglow";
#binding-cells = <2>;
};
Expand Down

0 comments on commit 72f8c50

Please sign in to comment.