Custom Devicetree
The SliceMK keymap configurator allows users to define custom Devicetree code to access features that are not yet implemented in the configurator.
This guide is for advanced users only. If you are new to ZMK, we recommend starting with the configurator's included features and revisiting this guide once you are comfortable with basic customization.
Macros
The keymap configurator has support for simple macros including for strings. However if you want to define a macro with arbitrary key sequences, you will need to use custom Devicetree code.
Please refer to ZMK documentation for full details on how to define macros. Some basic examples are provided below for convenience.
Suppose you want to define a macro that presses LCtrl-L, types test, then
presses enter. You can define it as follows:
/ {
ZMK_MACRO(
macro_1,
wait-ms = <10>;
tap-ms = <10>;
bindings =
<¯o_tap &kp LC(L)>,
<¯o_tap &kp T>,
<¯o_tap &kp E>,
<¯o_tap &kp S>,
<¯o_tap &kp T>,
<¯o_tap &kp RETURN>;
)
};
LC(L) is the keyboard shortcut for navigating to the browser address bar on
Windows and Linux. For macOS, you should use LG(L) instead. You can find the
full list of XX() modifier functions and key codes in the
ZMK documentation.
Suppose you want to define a macro that holds LShift while typing test. You
can define it as follows:
/ {
ZMK_MACRO(
macro_2,
wait-ms = <10>;
tap-ms = <10>;
bindings =
<¯o_press &kp LEFT_SHIFT>,
<¯o_tap &kp T>,
<¯o_tap &kp E>,
<¯o_tap &kp S>,
<¯o_tap &kp T>,
<¯o_release &kp LEFT_SHIFT>;
)
};
After adding the above code to the "Custom Devicetree Code" section of the
configurator, you can add a "Custom" key to your keymap with value ¯o_1 or
¯o_2.
Combos
To define a combo, start by determining the key position for the keys you want to bind. Key position references are available for the following keyboards:
Please refer to ZMK documentation for full details on how to define combos.
As a simple example, suppose you want F and J to trigger Enter when
pressed together on your ErgoDox. Using the key position diagram, you can see
that F is key 33 and J is key 36. You can define the combo with the
following Devicetree code:
/ {
combos {
compatible = "zmk,combos";
combo_return {
timeout-ms = <50>;
key-positions = <33 36>;
bindings = <&kp RETURN>;
};
};
};
RGB Underglow
RGB underglow is experimental on SliceMK keyboards when used with a dongle. In dongleless setups, it may work but SliceMK does not officially support it yet.
To make use of underglow, you must build your firmware with one of the *-rgb
releases. You can select the appropriate firmware version when using the
configurator, or point your repository at the appropriate branch when using
GitHub Actions.
The following &rgb_ug actions are supported:
&rgb_ug RGB_HUIto increase the hue&rgb_ug RGB_HUDto decrease the hue&rgb_ug RGB_SAIto increase the saturation&rgb_ug RGB_SADto decrease the saturation&rgb_ug RGB_BRIto increase the brightness&rgb_ug RGB_BRDto decrease the brightness&rgb_ug RGB_COLOR_HSB(h,s,b)to set the color using hue, saturation, and brightness
As a simple example, suppose you want underglow to be green. You can define a "Custom" key with value:
&rgb_ug RGB_COLOR_HSB(120,100,100)
To turn underglow off, you can define a "Custom" key that sets the brightness to 0%:
&rgb_ug RGB_COLOR_HSB(0,0,0)
When using the SliceMK peripheral firmware, you do not need to manage external power explicitly, unlike with most ZMK keyboards. Setting the brightness to zero is sufficient for turning off underglow and cutting off power at the same time.
As a more complex example, suppose you want underglow to be red while the fn
momentary layer is active. You can wrap &mo LAYER_FN with a macro in the
following manner:
/ {
ZMK_MACRO(
layer_fn_rgb,
wait-ms = <0>;
tap-ms = <0>;
bindings =
<¯o_press &mo LAYER_FN>,
<¯o_tap &rgb_ug RGB_COLOR_HSB(0,100,100)>,
<¯o_pause_for_release>,
<¯o_release &mo LAYER_FN>,
<¯o_tap &rgb_ug RGB_COLOR_HSB(0,0,0)>;
)
};