refactor(behaviors)!: Remove labels from behaviors

Removed the label property from built-in behaviors, custom behaviors
defined in a few keymaps, and macros generated with ZMK_MACRO().

Now that node names are used to identify behaviors, and names only need
to be unique within the set of behaviors, the names of all behaviors
have been shortened to be similar to their original labels.

This means that any keymaps which reference behavior nodes by name
instead of by label will need to be updated. Keymaps typically use the
labels though, so most keymaps should be unaffected by this change.
This commit is contained in:
Joel Spadin 2023-11-18 00:47:01 -06:00
parent 36eda571b7
commit 23ecf08119
32 changed files with 54 additions and 91 deletions

View File

@ -20,7 +20,6 @@
behaviors {
hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
label = "homerow mods";
#binding-cells = <2>;
tapping_term_ms = <200>;
flavor = "tap-preferred";

View File

@ -12,7 +12,6 @@
/ {
behaviors {
ht: hold_tap {
label = "hold_tap";
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "tap-preferred";

View File

@ -19,7 +19,6 @@
behaviors {
hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
label = "homerow mods";
#binding-cells = <2>;
tapping_term_ms = <225>;
flavor = "tap-preferred";

View File

@ -23,21 +23,18 @@
behaviors {
fofunc: four_ffour {
compatible = "zmk,behavior-mod-morph";
label = "FOUR_FUNCFOUR";
#binding-cells = <0>;
bindings = <&kp N4>, <&kp F4>;
mods = <(MOD_LALT|MOD_RALT)>;
};
sleft: s_left {
compatible = "zmk,behavior-mod-morph";
label = "S_LEFT";
#binding-cells = <0>;
bindings = <&kp S>, <&kp LEFT>;
mods = <(MOD_LGUI|MOD_RGUI)>;
};
fright: f_right {
compatible = "zmk,behavior-mod-morph";
label = "R_RIGHT";
#binding-cells = <0>;
bindings = <&kp F>, <&kp RIGHT>;
mods = <(MOD_LGUI|MOD_RGUI)>;

View File

@ -16,7 +16,6 @@
behaviors {
hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
label = "homerow mods";
#binding-cells = <2>;
tapping-term-ms = <225>;
flavor = "tap-preferred";

View File

@ -12,7 +12,6 @@
behaviors {
ht: hold_tap {
compatible = "zmk,behavior-hold-tap";
label = "Hold Tap";
#binding-cells = <2>;
tapping-term-ms = <200>;
flavor = "tap-preferred";

View File

@ -6,9 +6,9 @@
/ {
behaviors {
/omit-if-no-ref/ bl: behavior_backlight {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
/omit-if-no-ref/ bl: bcklight {
compatible = "zmk,behavior-backlight";
label = "BCKLGHT";
#binding-cells = <2>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ bt: behavior_bluetooth {
/omit-if-no-ref/ bt: bluetooth {
compatible = "zmk,behavior-bluetooth";
label = "BLUETOOTH";
#binding-cells = <2>;
};
};

View File

@ -8,9 +8,8 @@
/ {
behaviors {
/omit-if-no-ref/ caps_word: behavior_caps_word {
/omit-if-no-ref/ caps_word: caps_word {
compatible = "zmk,behavior-caps-word";
label = "CAPS_WORD";
#binding-cells = <0>;
continue-list = <UNDERSCORE BACKSPACE DELETE>;
};

View File

@ -6,9 +6,9 @@
/ {
behaviors {
ext_power: behavior_ext_power {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
ext_power: extpower {
compatible = "zmk,behavior-ext-power";
label = "EXTPOWER";
#binding-cells = <1>;
};
};

View File

@ -10,7 +10,6 @@
behaviors {
/omit-if-no-ref/ gresc: grave_escape {
compatible = "zmk,behavior-mod-morph";
label = "GRAVE_ESCAPE";
#binding-cells = <0>;
bindings = <&kp ESC>, <&kp GRAVE>;
mods = <(MOD_LGUI|MOD_LSFT|MOD_RGUI|MOD_RSFT)>;

View File

@ -7,9 +7,8 @@
/ {
behaviors {
/* DEPRECATED: `cp` will be removed in the future */
/omit-if-no-ref/ cp: kp: behavior_key_press {
/omit-if-no-ref/ cp: kp: key_press {
compatible = "zmk,behavior-key-press";
label = "KEY_PRESS";
#binding-cells = <1>;
};
};

View File

@ -8,9 +8,8 @@
/ {
behaviors {
/omit-if-no-ref/ key_repeat: behavior_key_repeat {
/omit-if-no-ref/ key_repeat: key_repeat {
compatible = "zmk,behavior-key-repeat";
label = "KEY_REPEAT";
#binding-cells = <0>;
usage-pages = <HID_USAGE_KEY>;
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ kt: behavior_key_toggle {
/omit-if-no-ref/ kt: key_toggle {
compatible = "zmk,behavior-key-toggle";
label = "KEY_TOGGLE";
#binding-cells = <1>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ lt: behavior_layer_tap {
/omit-if-no-ref/ lt: layer_tap {
compatible = "zmk,behavior-hold-tap";
label = "LAYER_TAP";
#binding-cells = <2>;
flavor = "tap-preferred";
tapping-term-ms = <200>;

View File

@ -5,10 +5,8 @@
*/
#define MACRO_PLACEHOLDER 0
#define ZMK_MACRO_STRINGIFY(x) #x
#define ZMK_MACRO(name,...) \
name: name { \
label = ZMK_MACRO_STRINGIFY(ZM_ ## name); \
compatible = "zmk,behavior-macro"; \
#binding-cells = <0>; \
__VA_ARGS__ \
@ -16,7 +14,6 @@ name: name { \
#define ZMK_MACRO1(name,...) \
name: name { \
label = ZMK_MACRO_STRINGIFY(ZM_ ## name); \
compatible = "zmk,behavior-macro-one-param"; \
#binding-cells = <1>; \
__VA_ARGS__ \
@ -24,7 +21,6 @@ name: name { \
#define ZMK_MACRO2(name,...) \
name: name { \
label = ZMK_MACRO_STRINGIFY(ZM_ ## name); \
compatible = "zmk,behavior-macro-two-param"; \
#binding-cells = <2>; \
__VA_ARGS__ \
@ -32,63 +28,53 @@ name: name { \
/ {
behaviors {
macro_tap: macro_control_mode_tap {
macro_tap: macro_tap {
compatible = "zmk,macro-control-mode-tap";
label = "MAC_TAP";
#binding-cells = <0>;
};
macro_press: macro_control_mode_press {
macro_press: macro_press {
compatible = "zmk,macro-control-mode-press";
label = "MAC_PRESS";
#binding-cells = <0>;
};
macro_release: macro_control_mode_release {
macro_release: macro_release {
compatible = "zmk,macro-control-mode-release";
label = "MAC_REL";
#binding-cells = <0>;
};
macro_tap_time: macro_control_tap_time {
macro_tap_time: macro_tap_time {
compatible = "zmk,macro-control-tap-time";
label = "MAC_TAP_TIME";
#binding-cells = <1>;
};
macro_wait_time: macro_control_wait_time {
macro_wait_time: macro_wait_time {
compatible = "zmk,macro-control-wait-time";
label = "MAC_WAIT_TIME";
#binding-cells = <1>;
};
macro_pause_for_release: macro_pause_for_release {
compatible = "zmk,macro-pause-for-release";
label = "MAC_WAIT_REL";
#binding-cells = <0>;
};
macro_param_1to1: macro_param_1to1 {
compatible = "zmk,macro-param-1to1";
label = "MAC_PARAM_1TO1";
#binding-cells = <0>;
};
macro_param_1to2: macro_param_1to2 {
compatible = "zmk,macro-param-1to2";
label = "MAC_PARAM_1TO2";
#binding-cells = <0>;
};
macro_param_2to1: macro_param_2to1 {
compatible = "zmk,macro-param-2to1";
label = "MAC_PARAM_2TO1";
#binding-cells = <0>;
};
macro_param_2to2: macro_param_2to2 {
compatible = "zmk,macro-param-2to2";
label = "MAC_PARAM_2TO2";
#binding-cells = <0>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ mt: behavior_mod_tap {
/omit-if-no-ref/ mt: mod_tap {
compatible = "zmk,behavior-hold-tap";
label = "MOD_TAP";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ mo: behavior_momentary_layer {
/omit-if-no-ref/ mo: momentary_layer {
compatible = "zmk,behavior-momentary-layer";
label = "MO";
#binding-cells = <1>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ none: behavior_none {
/omit-if-no-ref/ none: none {
compatible = "zmk,behavior-none";
label = "NONE";
#binding-cells = <0>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ out: behavior_outputs {
/omit-if-no-ref/ out: outputs {
compatible = "zmk,behavior-outputs";
label = "OUTPUTS";
#binding-cells = <1>;
};
};

View File

@ -8,15 +8,15 @@
/ {
behaviors {
sys_reset: behavior_reset {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
sys_reset: sysreset {
compatible = "zmk,behavior-reset";
label = "SYSRESET";
#binding-cells = <0>;
};
bootloader: behavior_reset_dfu {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
bootloader: bootload {
compatible = "zmk,behavior-reset";
label = "BOOTLOAD";
type = <RST_UF2>;
#binding-cells = <0>;
};

View File

@ -6,9 +6,9 @@
/ {
behaviors {
rgb_ug: behavior_rgb_underglow {
// Behavior can be invoked on peripherals, so name must be <= 8 characters.
rgb_ug: rgb_ug {
compatible = "zmk,behavior-rgb-underglow";
label = "RGB_UG";
#binding-cells = <2>;
};
};

View File

@ -7,9 +7,8 @@
/ {
behaviors {
/* DEPRECATED: `inc_dec_cp` will be removed in the future */
/omit-if-no-ref/ inc_dec_cp: inc_dec_kp: behavior_sensor_rotate_key_press {
/omit-if-no-ref/ inc_dec_cp: inc_dec_kp: enc_key_press {
compatible = "zmk,behavior-sensor-rotate-var";
label = "ENC_KEY_PRESS";
#sensor-binding-cells = <2>;
bindings = <&kp>, <&kp>;
};

View File

@ -6,17 +6,15 @@
/ {
behaviors {
/omit-if-no-ref/ sk: behavior_sticky_key {
/omit-if-no-ref/ sk: sticky_key {
compatible = "zmk,behavior-sticky-key";
label = "STICKY_KEY";
#binding-cells = <1>;
release-after-ms = <1000>;
bindings = <&kp>;
ignore-modifiers;
};
/omit-if-no-ref/ sl: behavior_sticky_layer {
/omit-if-no-ref/ sl: sticky_layer {
compatible = "zmk,behavior-sticky-key";
label = "STICKY_LAYER";
#binding-cells = <1>;
release-after-ms = <1000>;
bindings = <&mo>;

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ to: behavior_to_layer {
/omit-if-no-ref/ to: to_layer {
compatible = "zmk,behavior-to-layer";
label = "TO_LAYER";
#binding-cells = <1>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ tog: behavior_toggle_layer {
/omit-if-no-ref/ tog: toggle_layer {
compatible = "zmk,behavior-toggle-layer";
label = "TOGGLE_LAYER";
#binding-cells = <1>;
};
};

View File

@ -6,9 +6,8 @@
/ {
behaviors {
/omit-if-no-ref/ trans: behavior_transparent {
/omit-if-no-ref/ trans: transparent {
compatible = "zmk,behavior-transparent";
label = "TRANS";
#binding-cells = <0>;
};
};

View File

@ -24,6 +24,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
#define KEY_PRESS DEVICE_DT_NAME(DT_INST(0, zmk_behavior_key_press))
#define ZMK_BHV_STICKY_KEY_MAX_HELD 10
#define ZMK_BHV_STICKY_KEY_POSITION_FREE UINT32_MAX
@ -202,7 +204,7 @@ static int sticky_key_keycode_state_changed_listener(const zmk_event_t *eh) {
continue;
}
if (strcmp(sticky_key->config->behavior.behavior_dev, "KEY_PRESS") == 0 &&
if (strcmp(sticky_key->config->behavior.behavior_dev, KEY_PRESS) == 0 &&
ZMK_HID_USAGE_ID(sticky_key->param1) == ev_copy.keycode &&
ZMK_HID_USAGE_PAGE(sticky_key->param1) == ev_copy.usage_page &&
SELECT_MODS(sticky_key->param1) == ev_copy.implicit_modifiers) {

View File

@ -1,18 +1,18 @@
queue_process_next: Invoking KEY_PRESS: 0x70004 0x00
queue_process_next: Invoking key_press: 0x70004 0x00
kp_pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms
queue_process_next: Invoking KEY_PRESS: 0x70004 0x00
queue_process_next: Invoking key_press: 0x70004 0x00
kp_released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 10ms
queue_process_next: Invoking KEY_PRESS: 0x70005 0x00
queue_process_next: Invoking key_press: 0x70005 0x00
kp_pressed: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms
queue_process_next: Invoking KEY_PRESS: 0x70005 0x00
queue_process_next: Invoking key_press: 0x70005 0x00
kp_released: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 10ms
queue_process_next: Invoking KEY_PRESS: 0x70006 0x00
queue_process_next: Invoking key_press: 0x70006 0x00
kp_pressed: usage_page 0x07 keycode 0x06 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms
queue_process_next: Invoking KEY_PRESS: 0x70006 0x00
queue_process_next: Invoking key_press: 0x70006 0x00
kp_released: usage_page 0x07 keycode 0x06 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 10ms

View File

@ -1,8 +1,8 @@
pos_state: layer: 0 position: 0, binding name: ZM_abc_macro
pos_state: layer: 0 position: 0, binding name: abc_macro
kp_pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
pos_state: layer: 0 position: 0, binding name: ZM_abc_macro
pos_state: layer: 0 position: 1, binding name: MO
pos_state: layer: 0 position: 1, binding name: MO
pos_state: layer: 0 position: 0, binding name: abc_macro
pos_state: layer: 0 position: 1, binding name: momentary_layer
pos_state: layer: 0 position: 1, binding name: momentary_layer
kp_released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
kp_pressed: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
kp_released: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00

View File

@ -1,18 +1,18 @@
queue_process_next: Invoking KEY_PRESS: 0x70004 0x00
queue_process_next: Invoking key_press: 0x70004 0x00
kp_pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 30ms
queue_process_next: Invoking KEY_PRESS: 0x70004 0x00
queue_process_next: Invoking key_press: 0x70004 0x00
kp_released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms
queue_process_next: Invoking KEY_PRESS: 0x70005 0x00
queue_process_next: Invoking key_press: 0x70005 0x00
kp_pressed: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 20ms
queue_process_next: Invoking KEY_PRESS: 0x70005 0x00
queue_process_next: Invoking key_press: 0x70005 0x00
kp_released: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms
queue_process_next: Invoking KEY_PRESS: 0x70006 0x00
queue_process_next: Invoking key_press: 0x70006 0x00
kp_pressed: usage_page 0x07 keycode 0x06 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 20ms
queue_process_next: Invoking KEY_PRESS: 0x70006 0x00
queue_process_next: Invoking key_press: 0x70006 0x00
kp_released: usage_page 0x07 keycode 0x06 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 50ms

View File

@ -1,16 +1,16 @@
qm: Iterating macro bindings - starting: 0, count: 4
queue_process_next: Invoking KEY_PRESS: 0x700e2 0x00
queue_process_next: Invoking key_press: 0x700e2 0x00
kp_pressed: usage_page 0x07 keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 10ms
queue_process_next: Invoking KEY_PRESS: 0x7002b 0x00
queue_process_next: Invoking key_press: 0x7002b 0x00
kp_pressed: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 40ms
queue_process_next: Invoking KEY_PRESS: 0x7002b 0x00
queue_process_next: Invoking key_press: 0x7002b 0x00
kp_released: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 10ms
kp_pressed: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
kp_released: usage_page 0x07 keycode 0x2B implicit_mods 0x00 explicit_mods 0x00
qm: Iterating macro bindings - starting: 5, count: 2
queue_process_next: Invoking KEY_PRESS: 0x700e2 0x00
queue_process_next: Invoking key_press: 0x700e2 0x00
kp_released: usage_page 0x07 keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00
queue_process_next: Processing next queued behavior in 0ms