Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use Kconfig to conditionally compile behaviors #2106

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bryanforbes
Copy link

This pull request updates the current behaviors to use Kconfig.behaviors and target_sources_ifdef() within app/CMakeLists.txt to conditionally compile behaviors based on the behaviors used in the user's keymap

@bryanforbes bryanforbes requested a review from a team as a code owner January 10, 2024 15:12
Copy link
Contributor

@caksoylar caksoylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general from a docs perspective. Note that if you remove the #define as in the first comments the docs need to be updated for that too.

app/src/behaviors/behavior_transparent.c Show resolved Hide resolved
docs/docs/development/new-behavior.md Outdated Show resolved Hide resolved
Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few high level comments on how this fits with splits.

Comment on lines 75 to 78
config ZMK_BEHAVIOR_RESET
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_RESET_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this one is a bit tricky... This is needs to be enables a bit more specifically for the right side of splits, even if it's not referenced in a keymap. There's a few of those, like the RBG behavior, that are either "local" or "global" so need this special handling.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. I've removed the Kconfig options for the behaviors we talked about in Discord and reverted them back to using the main Kconfig option where available. This means the reset behaviors are always compiled in for both sides.

default y
depends on DT_HAS_ZMK_BEHAVIOR_RESET_ENABLED

config ZMK_BEHAVIOR_RGB_UNDERGLOW
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -7,7 +7,7 @@
/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
ext_power: extpower {
/omit-if-no-ref/ ext_power: extpower {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentional, so probably needs an added comment, instead of adding the omit-if-no-ref.

@@ -9,13 +9,13 @@
/ {
behaviors {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
sys_reset: sysreset {
/omit-if-no-ref/ sys_reset: sysreset {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto in this file.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants