feat: Add the ability to keep/omit behaviors for a given build.
* Use defines to keep either all behaviors with omits, or selective behaviors with explicit kept behavior, before including `behavior.dtsi` in keymaps. * Default ZMK_BEHAVIORS_KEEP_ALL when building with the studio RPC endpoint snippet.
This commit is contained in:
parent
051deb50fe
commit
f584318ddc
22 changed files with 129 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
|||
#include <behaviors.dtsi>
|
||||
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
#include <dt-bindings/zmk/kscan_mock.h>
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#define ZMK_BEHAVIORS_KEEP_ALL
|
||||
|
||||
#include <behaviors.dtsi>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
|
|
|
@ -4,10 +4,15 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
#if ZMK_BEHAVIOR_OMIT(BL)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
|
||||
/omit-if-no-ref/ bl: bcklight {
|
||||
bl: bcklight {
|
||||
compatible = "zmk,behavior-backlight";
|
||||
#binding-cells = <2>;
|
||||
display-name = "Backlight";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ bt: bluetooth {
|
||||
#if ZMK_BEHAVIOR_OMIT(BT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
bt: bluetooth {
|
||||
compatible = "zmk,behavior-bluetooth";
|
||||
#binding-cells = <2>;
|
||||
display-name = "Bluetooth";
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ caps_word: caps_word {
|
||||
#if ZMK_BEHAVIOR_OMIT(CAPS_WORD)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
caps_word: caps_word {
|
||||
compatible = "zmk,behavior-caps-word";
|
||||
#binding-cells = <0>;
|
||||
continue-list = <UNDERSCORE BACKSPACE DELETE>;
|
||||
|
|
|
@ -4,11 +4,16 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ gresc: grave_escape {
|
||||
#if ZMK_BEHAVIOR_OMIT(GRESC)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
gresc: grave_escape {
|
||||
compatible = "zmk,behavior-mod-morph";
|
||||
#binding-cells = <0>;
|
||||
bindings = <&kp ESC>, <&kp GRAVE>;
|
||||
|
|
|
@ -4,10 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/* DEPRECATED: `cp` will be removed in the future */
|
||||
/omit-if-no-ref/ cp: kp: key_press {
|
||||
#if ZMK_BEHAVIOR_OMIT(KP)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
kp: key_press {
|
||||
compatible = "zmk,behavior-key-press";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Key Press";
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ key_repeat: key_repeat {
|
||||
#if ZMK_BEHAVIOR_OMIT(KEY_REPEAT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
key_repeat: key_repeat {
|
||||
compatible = "zmk,behavior-key-repeat";
|
||||
#binding-cells = <0>;
|
||||
usage-pages = <HID_USAGE_KEY>;
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ kt: key_toggle {
|
||||
#if ZMK_BEHAVIOR_OMIT(KT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
kt: key_toggle {
|
||||
compatible = "zmk,behavior-key-toggle";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Key Toggle";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ lt: layer_tap {
|
||||
#if ZMK_BEHAVIOR_OMIT(LT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
lt: layer_tap {
|
||||
compatible = "zmk,behavior-hold-tap";
|
||||
#binding-cells = <2>;
|
||||
flavor = "tap-preferred";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ mt: mod_tap {
|
||||
#if ZMK_BEHAVIOR_OMIT(MT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
mt: mod_tap {
|
||||
compatible = "zmk,behavior-hold-tap";
|
||||
#binding-cells = <2>;
|
||||
flavor = "hold-preferred";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ mo: momentary_layer {
|
||||
#if ZMK_BEHAVIOR_OMIT(MO)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
mo: momentary_layer {
|
||||
compatible = "zmk,behavior-momentary-layer";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Momentary Layer";
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2023 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ mkp: mouse_key_press {
|
||||
#if ZMK_BEHAVIOR_OMIT(MKP)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
mkp: mouse_key_press {
|
||||
compatible = "zmk,behavior-mouse-key-press";
|
||||
#binding-cells = <1>;
|
||||
};
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ none: none {
|
||||
#if ZMK_BEHAVIOR_OMIT(NONE)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
none: none {
|
||||
compatible = "zmk,behavior-none";
|
||||
#binding-cells = <0>;
|
||||
display-name = "None";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ out: outputs {
|
||||
#if ZMK_BEHAVIOR_OMIT(OUT)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
out: outputs {
|
||||
compatible = "zmk,behavior-outputs";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Output Selection";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ soft_off: z_so_off {
|
||||
#if ZMK_BEHAVIOR_OMIT(SOFT_OFF)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
soft_off: z_so_off {
|
||||
compatible = "zmk,behavior-soft-off";
|
||||
#binding-cells = <0>;
|
||||
split-peripheral-off-on-press;
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ sk: sticky_key {
|
||||
#if ZMK_BEHAVIOR_OMIT(SK)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
sk: sticky_key {
|
||||
compatible = "zmk,behavior-sticky-key";
|
||||
#binding-cells = <1>;
|
||||
release-after-ms = <1000>;
|
||||
|
@ -14,7 +19,10 @@
|
|||
ignore-modifiers;
|
||||
display-name = "Sticky Key";
|
||||
};
|
||||
/omit-if-no-ref/ sl: sticky_layer {
|
||||
#if ZMK_BEHAVIOR_OMIT(STICKY_LAYER)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
sl: sticky_layer {
|
||||
compatible = "zmk,behavior-sticky-key";
|
||||
#binding-cells = <1>;
|
||||
release-after-ms = <1000>;
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ to: to_layer {
|
||||
#if ZMK_BEHAVIOR_OMIT(TO)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
to: to_layer {
|
||||
compatible = "zmk,behavior-to-layer";
|
||||
#binding-cells = <1>;
|
||||
display-name = "To Layer";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ tog: toggle_layer {
|
||||
#if ZMK_BEHAVIOR_OMIT(TOG)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
tog: toggle_layer {
|
||||
compatible = "zmk,behavior-toggle-layer";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Toggle Layer";
|
||||
|
|
|
@ -4,9 +4,14 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <dt-bindings/zmk/behaviors.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
/omit-if-no-ref/ trans: transparent {
|
||||
#if ZMK_BEHAVIOR_OMIT(TRANS)
|
||||
/omit-if-no-ref/
|
||||
#endif
|
||||
trans: transparent {
|
||||
compatible = "zmk,behavior-transparent";
|
||||
#binding-cells = <0>;
|
||||
display-name = "Transparent";
|
||||
|
|
9
app/include/dt-bindings/zmk/behaviors.h
Normal file
9
app/include/dt-bindings/zmk/behaviors.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright (c) 2024 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#define ZMK_BEHAVIOR_OMIT(_name) \
|
||||
!(defined(ZMK_BEHAVIORS_KEEP_##_name) || \
|
||||
(defined(ZMK_BEHAVIORS_KEEP_ALL) && !defined(ZMK_BEHAVIORS_OMIT_##_name)))
|
|
@ -3,5 +3,6 @@
|
|||
|
||||
name: studio-rpc-usb-uart
|
||||
append:
|
||||
DTS_EXTRA_CPPFLAGS: -DZMK_BEHAVIORS_KEEP_ALL
|
||||
EXTRA_DTC_OVERLAY_FILE: studio-rpc-usb-uart.overlay
|
||||
EXTRA_CONF_FILE: studio-rpc-usb-uart.conf
|
||||
|
|
Loading…
Add table
Reference in a new issue