refactor(keymaps): Rename layer label to "display-name"

Changed the property used to define a layer name for displays from
"label" (which affects other things in Zephyr and is deprecated) to
"display-name". (It cannot be named simply "name", because that has
special meaning in newer versions of the devicetree compiler.)

"label" is still supported as a fallback, so no changes need to be made
to existing keymaps.
This commit is contained in:
Joel Spadin 2023-10-06 20:04:41 -05:00
parent ba5637fdef
commit d4e8dee444
18 changed files with 51 additions and 44 deletions

View file

@ -21,7 +21,7 @@
compatible = "zmk,keymap";
default_layer {
label = "QWERTY";
display-name = "QWERTY";
// --------------------------------------------------------------------------------
// | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP |
// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' |
@ -36,7 +36,7 @@
};
lower_layer {
label = "NUMBER";
display-name = "NUMBER";
// -----------------------------------------------------------------------------------------
// | TAB | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP |
// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | |
@ -51,7 +51,7 @@
};
raise_layer {
label = "SYMBOL";
display-name = "SYMBOL";
// -----------------------------------------------------------------------------------------
// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP |
// | CTRL | | | | | | | - | = | [ | ] | \ | ` |

View file

@ -45,7 +45,7 @@ static void layer_status_update_cb(struct layer_status_state state) {
static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) {
uint8_t index = zmk_keymap_highest_layer_active();
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_label(index)};
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)};
}
ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb,

View file

@ -66,7 +66,7 @@
};
nav_layer {
label = "Nav";
display-name = "Nav";
bindings = <
&trans &trans &trans &trans &trans &trans &kp HOME &kp UARW &kp PG_UP &trans
&trans &trans &trans &trans &trans &trans &kp LARW &kp DARW &kp RARW &trans
@ -76,7 +76,7 @@
};
num_layer {
label = "Num";
display-name = "Num";
bindings = <
&kp LBKT &kp N7 &kp N8 &kp N9 &kp RBKT &trans &trans &trans &trans &trans
&kp SEMI &kp N4 &kp N5 &kp N6 &kp EQUAL &trans &trans &trans &trans &trans
@ -86,7 +86,7 @@
};
sym_layer {
label = "Sym";
display-name = "Sym";
bindings = <
&kp LBRC &kp LS(N7) &kp LS(N8) &kp LS(N9) &kp RBRC &trans &trans &trans &trans &trans
&kp COLON &kp LS(N4) &kp LS(N5) &kp LS(N6) &kp PLUS &trans &trans &trans &trans &trans

View file

@ -25,7 +25,7 @@
compatible = "zmk,keymap";
default_layer {
label = " QWERTY";
display-name = " QWERTY";
bindings = <
&kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSLH
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp GRAV
@ -38,7 +38,7 @@
};
lower_layer {
label = " Lower";
display-name = " Lower";
bindings = <
&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11
&trans &trans &trans &trans &trans &trans &kp PG_UP &kp HOME &kp UP &kp END &trans &kp F12
@ -51,7 +51,7 @@
};
raise_layer {
label = " Raise";
display-name = " Raise";
bindings = <
&trans &trans &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &sys_reset &bootloader

View file

@ -37,7 +37,7 @@
compatible = "zmk,keymap";
default_layer {
label = " QWERTY";
display-name = " QWERTY";
bindings = <
&kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSLH
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp GRAV
@ -50,7 +50,7 @@
};
lower_layer {
label = " Lower";
display-name = " Lower";
bindings = <
&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11
&trans &trans &trans &trans &trans &trans &kp PG_UP &kp HOME &kp UP &kp END &trans &kp F12
@ -63,7 +63,7 @@
};
raise_layer {
label = " Raise";
display-name = " Raise";
bindings = <
&trans &trans &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &sys_reset &bootloader

View file

@ -73,7 +73,7 @@
compatible = "zmk,keymap";
default_layer {
label = " QWERTY";
display-name = " QWERTY";
bindings = <
&kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P
&kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI
@ -85,7 +85,7 @@
};
lower_layer {
label = " Lower";
display-name = " Lower";
bindings = <
&kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0
&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp QUOT
@ -97,7 +97,7 @@
};
raise_layer {
label = " Raise";
display-name = " Raise";
bindings = <
&kp TAB &trans &trans &trans &trans &kp PG_UP &kp HOME &kp UP &kp END &kp BSLH
&kp CAPS &trans &trans &trans &trans &kp PG_DN &kp LEFT &kp DOWN &kp RIGHT &kp GRAVE
@ -109,7 +109,7 @@
};
adjust_layer {
label = " Adjust";
display-name = " Adjust";
bindings = <
&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &trans &trans &trans &trans &trans
@ -122,7 +122,7 @@
};
numpad_layer {
label = " NumPad";
display-name = " NumPad";
bindings = <
&trans &none &none &none &none &kp SLASH &kp N7 &kp N8 &kp N9 &kp MINUS
@ -135,7 +135,7 @@ RGBOFF RGBEFF RGBHUD RGBSAD RGBBRD &trans &trans &no
};
ble_layer {
label = " BLE";
display-name = " BLE";
bindings = <
&bt BT0 &bt BT1 &bt BT2 &bt BT3 &bt BT4 &bt BT0 &bt BT1 &bt BT2 &bt BT3 &bt BT4

View file

@ -56,7 +56,7 @@
compatible = "zmk,keymap";
default_layer {
label = "default layer";
display-name = "default layer";
bindings = <
&bt BT_CLR &kp TAB &kp F5 &kp LC(LA(C)) &kp LG(D)
&rgb_ug RGB_TOG &kp ESC &kp KP_DIVIDE &kp KP_MULTIPLY &kp KP_MINUS
@ -70,7 +70,7 @@
};
fn_layer {
label = "fn layer";
display-name = "fn layer";
bindings = <
&trans &trans &trans &trans &trans
&trans &kp KP_NUM &trans &trans &trans

View file

@ -19,7 +19,7 @@
compatible = "zmk,keymap";
default_layer {
label = "Default";
display-name = "Default";
sensor-bindings = <&inc_dec_kp C_VOLUME_UP C_VOLUME_DOWN>;
@ -32,7 +32,7 @@
>;
};
function_layer {
label = "Function";
display-name = "Function";
sensor-bindings = <&inc_dec_kp C_VOLUME_UP C_VOLUME_DOWN>;

View file

@ -276,7 +276,7 @@ static void layer_status_update_cb(struct layer_status_state state) {
static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) {
uint8_t index = zmk_keymap_highest_layer_active();
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_label(index)};
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)};
}
ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb,

View file

@ -25,7 +25,7 @@
compatible = "zmk,keymap";
base {
label = "Base";
display-name = "Base";
bindings = <
&kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P
&kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI
@ -35,7 +35,7 @@
};
lower {
label = "Lower";
display-name = "Lower";
bindings = <
&kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR
&trans &kp TILDE &kp DQT &kp PIPE &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC
@ -45,7 +45,7 @@
};
upper {
label = "Upper";
display-name = "Upper";
bindings = <
&kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0
&trans &kp GRAVE &kp SQT &kp BSLH &trans &trans &kp MINUS &kp EQUAL &kp LBKT &kp RBKT
@ -55,7 +55,7 @@
};
function {
label = "Function";
display-name = "Function";
bindings = <
&kp TAB &trans &kp C_VOL_UP &trans &trans &trans &trans &trans &trans &kp ENTER
&kp ESC &kp C_BRI_DN &kp C_VOL_DN &kp C_BRI_UP &trans &trans &kp LEFT &kp DOWN &kp UP &kp RIGHT
@ -65,7 +65,7 @@
};
meta {
label = "Meta";
display-name = "Meta";
bindings = <
&rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &none &none &none &none &none
&rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4

View file

@ -17,7 +17,7 @@
compatible = "zmk,keymap";
base_layer {
label = "BASE";
display-name = "BASE";
bindings = <
// ╭─────────────┬──────────────┬──────────────────┬─────────────┬─────────────╮
&mo BLE &kp C_PREVIOUS &kp C_PLAY_PAUSE &kp C_NEXT &kp C_MUTE
@ -27,7 +27,7 @@
};
ble_layer {
label = "BLE";
display-name = "BLE";
bindings = <
// ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
&trans &out OUT_TOG &bt BT_PRV &bt BT_NXT &bt BT_CLR

View file

@ -20,7 +20,7 @@
compatible = "zmk,keymap";
default_layer {
label = "Default";
display-name = "Default";
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp C_VOL_UP C_VOL_DN>;
bindings = <
&kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp KP_NUM &kp PAUSE_BREAK
@ -33,7 +33,7 @@
};
function_layer {
label = "Function";
display-name = "Function";
sensor-bindings = <&inc_dec_kp C_NEXT C_PREV &inc_dec_kp C_NEXT C_PREV>;
bindings = <
&bootloader &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &bootloader

View file

@ -30,7 +30,7 @@
compatible = "zmk,keymap";
default_layer {
label = "default";
display-name = "default";
// ------------------------------------------------------------------------------------------------------------
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
// | ESC | Q | W | E | R | T | | Y | U | I | O | P | BKSPC |
@ -49,7 +49,7 @@
};
lower_layer {
label = "lower";
display-name = "lower";
// TODO: Some binds are waiting for shifted keycode support.
// ------------------------------------------------------------------------------------------------------------
// | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
@ -69,7 +69,7 @@
};
raise_layer {
label = "raise";
display-name = "raise";
// ------------------------------------------------------------------------------------------------------------
// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | |
@ -94,7 +94,7 @@
// | | RGB_BRD | RGB_BRI | | | | | | | | | | |
// | | | | | | | RGB_TOG | | | | | | | | |
// | | | | | | | | | | | |
label = "adjust";
display-name = "adjust";
bindings = <
&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none &none &none &none &none &none
&ext_power EP_TOG &rgb_ug RGB_HUD &rgb_ug RGB_HUI &rgb_ug RGB_SAD &rgb_ug RGB_SAI &rgb_ug RGB_EFF &none &none &none &none &none &none

View file

@ -7,12 +7,19 @@ child-binding:
description: "A layer to be used in a keymap"
properties:
label:
display-name:
type: string
required: false
description: The name of this layer to show on displays
bindings:
type: phandle-array
required: true
sensor-bindings:
type: phandle-array
required: false
label:
type: string
required: false
deprecated: true
description: Deprecated. Use "name" instead.

View file

@ -22,7 +22,7 @@ int zmk_keymap_layer_activate(uint8_t layer);
int zmk_keymap_layer_deactivate(uint8_t layer);
int zmk_keymap_layer_toggle(uint8_t layer);
int zmk_keymap_layer_to(uint8_t layer);
const char *zmk_keymap_layer_label(uint8_t layer);
const char *zmk_keymap_layer_name(uint8_t layer);
int zmk_keymap_position_state_changed(uint8_t source, uint32_t position, bool pressed,
int64_t timestamp);

View file

@ -45,7 +45,7 @@ static void layer_status_update_cb(struct layer_status_state state) {
static struct layer_status_state layer_status_get_state(const zmk_event_t *eh) {
uint8_t index = zmk_keymap_highest_layer_active();
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_label(index)};
return (struct layer_status_state){.index = index, .label = zmk_keymap_layer_name(index)};
}
ZMK_DISPLAY_WIDGET_LISTENER(widget_layer_status, struct layer_status_state, layer_status_update_cb,

View file

@ -52,7 +52,7 @@ static uint8_t _zmk_keymap_layer_default = 0;
#endif /* ZMK_KEYMAP_HAS_SENSORS */
#define LAYER_LABEL(node) DT_PROP_OR(node, label, NULL)
#define LAYER_NAME(node) DT_PROP_OR(node, display_name, DT_PROP_OR(node, label, NULL))
// State
@ -65,7 +65,7 @@ static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_
DT_INST_FOREACH_CHILD_SEP(0, TRANSFORMED_LAYER, (, ))};
static const char *zmk_keymap_layer_names[ZMK_KEYMAP_LAYERS_LEN] = {
DT_INST_FOREACH_CHILD_SEP(0, LAYER_LABEL, (, ))};
DT_INST_FOREACH_CHILD_SEP(0, LAYER_NAME, (, ))};
#if ZMK_KEYMAP_HAS_SENSORS
@ -145,7 +145,7 @@ bool is_active_layer(uint8_t layer, zmk_keymap_layers_state_t layer_state) {
return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default;
}
const char *zmk_keymap_layer_label(uint8_t layer) {
const char *zmk_keymap_layer_name(uint8_t layer) {
if (layer >= ZMK_KEYMAP_LAYERS_LEN) {
return NULL;
}

View file

@ -19,7 +19,7 @@ Each child node can have the following properties:
| Property | Type | Description |
| ----------------- | ------------- | ---------------------------------------------------------------------- |
| `label` | string | Unique label for the node |
| `display-name` | string | Name for the layer on displays |
| `bindings` | phandle-array | List of [key behaviors](../features/keymaps.md#behaviors), one per key |
| `sensor-bindings` | phandle-array | List of sensor behaviors, one per sensor |