Skip to content

Commit

Permalink
refactor(keymaps): Rename layer label to "display-name"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joelspadin committed Dec 5, 2023
1 parent ba5637f commit d4e8dee
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 44 deletions.
6 changes: 3 additions & 3 deletions app/boards/arm/corneish_zen/corneish_zen.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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 | ; | ' |
Expand All @@ -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 | | |
Expand All @@ -51,7 +51,7 @@
};

raise_layer {
label = "SYMBOL";
display-name = "SYMBOL";
// -----------------------------------------------------------------------------------------
// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP |
// | CTRL | | | | | | | - | = | [ | ] | \ | ` |
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/corneish_zen/widgets/layer_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/boards/shields/hummingbird/hummingbird.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/boards/shields/leeloo/leeloo.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/boards/shields/leeloo/leeloo_rev2.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app/boards/shields/leeloo_micro/leeloo_micro.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/boards/shields/murphpad/murphpad.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/boards/shields/nibble/nibble.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand All @@ -32,7 +32,7 @@
>;
};
function_layer {
label = "Function";
display-name = "Function";

sensor-bindings = <&inc_dec_kp C_VOLUME_UP C_VOLUME_DOWN>;

Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/nice_view/widgets/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions app/boards/shields/reviung34/reviung34.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/boards/shields/reviung5/reviung5.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/boards/shields/snap/snap.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions app/boards/shields/sofle/sofle.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand All @@ -69,7 +69,7 @@
};

raise_layer {
label = "raise";
display-name = "raise";
// ------------------------------------------------------------------------------------------------------------
// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | |
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion app/dts/bindings/zmk,keymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion app/include/zmk/keymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/display/widgets/layer_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions app/src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit d4e8dee

Please # to comment.