forked from kofal.net/zmk
feat: Allow layer behaviors to "lock" layers on (#2717)
* refactor(core)!: Allow layer behaviors to "lock" layers on Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com> * docs: Added documentation note on locking layers Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com> --------- Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
This commit is contained in:
@@ -3,13 +3,23 @@
|
||||
#include <dt-bindings/zmk/kscan_mock.h>
|
||||
|
||||
/ {
|
||||
behaviors {
|
||||
tog_off: toggle_layer_off_only {
|
||||
compatible = "zmk,behavior-toggle-layer";
|
||||
#binding-cells = <1>;
|
||||
display-name = "Toggle Layer Off";
|
||||
toggle-mode = "off";
|
||||
locking;
|
||||
};
|
||||
};
|
||||
|
||||
keymap {
|
||||
compatible = "zmk,keymap";
|
||||
|
||||
default_layer {
|
||||
bindings = <
|
||||
&kp B &tog 1
|
||||
&kp D &to 1>;
|
||||
&mo 2 &to 1>;
|
||||
};
|
||||
|
||||
lower_layer {
|
||||
@@ -20,8 +30,8 @@
|
||||
|
||||
raise_layer {
|
||||
bindings = <
|
||||
&kp W &kp U
|
||||
&kp X &kp M>;
|
||||
&kp W &tog 2
|
||||
&tog_off 2 &mo 2>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
3
app/tests/toggle-layer/locking/events.patterns
Normal file
3
app/tests/toggle-layer/locking/events.patterns
Normal file
@@ -0,0 +1,3 @@
|
||||
s/.*hid_listener_keycode/kp/p
|
||||
s/.*tog_keymap_binding/tog/p
|
||||
s/.*mo_keymap_binding/mo/p
|
||||
16
app/tests/toggle-layer/locking/keycode_events.snapshot
Normal file
16
app/tests/toggle-layer/locking/keycode_events.snapshot
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
mo_pressed: position 2 layer 2
|
||||
tog_pressed: position 1 layer 2
|
||||
tog_released: position 1 layer 2
|
||||
mo_released: position 2 layer 2
|
||||
kp_pressed: usage_page 0x07 keycode 0x1A implicit_mods 0x00 explicit_mods 0x00
|
||||
kp_released: usage_page 0x07 keycode 0x1A implicit_mods 0x00 explicit_mods 0x00
|
||||
mo_pressed: position 3 layer 2
|
||||
mo_released: position 3 layer 2
|
||||
kp_pressed: usage_page 0x07 keycode 0x1A implicit_mods 0x00 explicit_mods 0x00
|
||||
kp_released: usage_page 0x07 keycode 0x1A implicit_mods 0x00 explicit_mods 0x00
|
||||
tog_pressed: position 1 layer 2
|
||||
tog_released: position 1 layer 2
|
||||
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
|
||||
25
app/tests/toggle-layer/locking/native_posix_64.keymap
Normal file
25
app/tests/toggle-layer/locking/native_posix_64.keymap
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <dt-bindings/zmk/keys.h>
|
||||
#include <behaviors.dtsi>
|
||||
#include <dt-bindings/zmk/kscan_mock.h>
|
||||
#include "../behavior_keymap.dtsi"
|
||||
|
||||
&kscan {
|
||||
events = <
|
||||
ZMK_MOCK_PRESS(0,0,10)
|
||||
ZMK_MOCK_RELEASE(0,0,10)
|
||||
ZMK_MOCK_PRESS(1,0,10)
|
||||
ZMK_MOCK_PRESS(0,1,10)
|
||||
ZMK_MOCK_RELEASE(0,1,10)
|
||||
ZMK_MOCK_RELEASE(1,0,10)
|
||||
ZMK_MOCK_PRESS(0,0,10)
|
||||
ZMK_MOCK_RELEASE(0,0,10)
|
||||
ZMK_MOCK_PRESS(1,1,10)
|
||||
ZMK_MOCK_RELEASE(1,1,10)
|
||||
ZMK_MOCK_PRESS(0,0,10)
|
||||
ZMK_MOCK_RELEASE(0,0,10)
|
||||
ZMK_MOCK_PRESS(0,1,10)
|
||||
ZMK_MOCK_RELEASE(0,1,10)
|
||||
ZMK_MOCK_PRESS(0,0,10)
|
||||
ZMK_MOCK_RELEASE(0,0,10)
|
||||
>;
|
||||
};
|
||||
@@ -3,12 +3,12 @@ tog_released: position 1 layer 1
|
||||
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
|
||||
to_pressed: position 3 layer 1
|
||||
layer_changed: layer 1 state 1
|
||||
layer_changed: layer 1 state 1 locked 1
|
||||
to_released: position 3 layer 1
|
||||
kp_pressed: usage_page 0x0C keycode 0xB5 implicit_mods 0x00 explicit_mods 0x00
|
||||
kp_released: usage_page 0x0C keycode 0xB5 implicit_mods 0x00 explicit_mods 0x00
|
||||
tog_pressed: position 1 layer 1
|
||||
layer_changed: layer 1 state 0
|
||||
layer_changed: layer 1 state 0 locked 1
|
||||
tog_released: position 1 layer 1
|
||||
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
|
||||
Reference in New Issue
Block a user