Update global behaviors to be compiled in based on their Kconfig option

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.
This commit is contained in:
Bryan Forbes 2024-03-06 11:40:49 -06:00
parent 1ce7670e57
commit 72f8c5072e
6 changed files with 19 additions and 34 deletions

View file

@ -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)
@ -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)

View file

@ -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
@ -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
@ -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

View file

@ -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>;
};

View file

@ -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>;
};

View file

@ -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>;

View file

@ -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>;
};