forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(behaviors): Add mod-morph
keep-mods
* Update docs for mod-morph * Add unit tests for mod-morph * Add keep-mods to DT binding Co-authored-by: Martin Aumüller <[email protected]> Co-authored-by: Cem Aksoylar <[email protected]>
- Loading branch information
1 parent
18b8b9b
commit ef2e6e9
Showing
28 changed files
with
425 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ properties: | |
mods: | ||
type: int | ||
required: true | ||
keep-mods: | ||
type: int | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pressed: keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x00 | ||
released: keycode 0x04 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x00 | ||
unmask mods: Modifiers set to 0x00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#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,1,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
12 changes: 12 additions & 0 deletions
12
app/tests/mod-morph/2a-masked-morph/keycode_events.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pressed: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x02 | ||
reg implicit: Modifiers set to 0x02 | ||
mask mods: Modifiers set to 0x00 | ||
pressed: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x00 | ||
released: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x00 | ||
unmask mods: Modifiers set to 0x02 | ||
released: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x00 | ||
unreg implicit: Modifiers set to 0x00 |
13 changes: 13 additions & 0 deletions
13
app/tests/mod-morph/2a-masked-morph/native_posix_64.keymap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#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(1,0,10) | ||
ZMK_MOCK_PRESS(0,1,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
ZMK_MOCK_RELEASE(1,0,10) | ||
>; | ||
}; |
8 changes: 8 additions & 0 deletions
8
app/tests/mod-morph/2b-masked-morph-implicit-overwrite/events.patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
12 changes: 12 additions & 0 deletions
12
app/tests/mod-morph/2b-masked-morph-implicit-overwrite/keycode_events.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pressed: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x02 | ||
reg implicit: Modifiers set to 0x02 | ||
mask mods: Modifiers set to 0x00 | ||
pressed: keycode 0x05 implicit_mods 0x02 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x02 | ||
released: keycode 0x05 implicit_mods 0x02 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x00 | ||
unmask mods: Modifiers set to 0x02 | ||
released: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x00 | ||
unreg implicit: Modifiers set to 0x00 |
37 changes: 37 additions & 0 deletions
37
app/tests/mod-morph/2b-masked-morph-implicit-overwrite/native_posix_64.keymap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/kscan_mock.h> | ||
|
||
/ { | ||
behaviors { | ||
mod_morph: mod_morph { | ||
compatible = "zmk,behavior-mod-morph"; | ||
label = "MOD_MORPH_TEST"; | ||
#binding-cells = <0>; | ||
bindings = <&kp A>, <&kp LS(B)>; // implict mod overwrite | ||
mods = <(MOD_LSFT|MOD_RSFT)>; | ||
}; | ||
}; | ||
|
||
keymap { | ||
compatible = "zmk,keymap"; | ||
label ="Default keymap"; | ||
|
||
default_layer { | ||
bindings = < | ||
&kp LEFT_ALT &mod_morph | ||
&kp LEFT_SHIFT &kp RIGHT_SHIFT | ||
>; | ||
}; | ||
}; | ||
}; | ||
|
||
&kscan { | ||
events = < | ||
ZMK_MOCK_PRESS(1,0,10) | ||
ZMK_MOCK_PRESS(0,1,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
ZMK_MOCK_RELEASE(1,0,10) | ||
>; | ||
}; | ||
|
8 changes: 8 additions & 0 deletions
8
app/tests/mod-morph/2c-masked-morph-and-explicit-mods/events.patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
18 changes: 18 additions & 0 deletions
18
app/tests/mod-morph/2c-masked-morph-and-explicit-mods/keycode_events.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pressed: keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x04 | ||
reg implicit: Modifiers set to 0x04 | ||
pressed: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x06 | ||
reg implicit: Modifiers set to 0x06 | ||
mask mods: Modifiers set to 0x04 | ||
pressed: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x04 | ||
released: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x04 | ||
unmask mods: Modifiers set to 0x06 | ||
released: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x04 | ||
unreg implicit: Modifiers set to 0x04 | ||
released: keycode 0xE2 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x00 | ||
unreg implicit: Modifiers set to 0x00 |
15 changes: 15 additions & 0 deletions
15
app/tests/mod-morph/2c-masked-morph-and-explicit-mods/native_posix_64.keymap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#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_PRESS(1,0,10) | ||
ZMK_MOCK_PRESS(0,1,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
ZMK_MOCK_RELEASE(1,0,10) | ||
ZMK_MOCK_RELEASE(0,0,10) | ||
>; | ||
}; |
8 changes: 8 additions & 0 deletions
8
app/tests/mod-morph/2d-masked-morph-into-hold-tap-tap/events.patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
12 changes: 12 additions & 0 deletions
12
app/tests/mod-morph/2d-masked-morph-into-hold-tap-tap/keycode_events.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pressed: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x02 | ||
reg implicit: Modifiers set to 0x02 | ||
mask mods: Modifiers set to 0x00 | ||
pressed: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x00 | ||
released: keycode 0x05 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x00 | ||
unmask mods: Modifiers set to 0x02 | ||
released: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x00 | ||
unreg implicit: Modifiers set to 0x00 |
45 changes: 45 additions & 0 deletions
45
app/tests/mod-morph/2d-masked-morph-into-hold-tap-tap/native_posix_64.keymap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/kscan_mock.h> | ||
|
||
&kscan { | ||
events = < | ||
/* Shift + tap &mod_morph --> expect B (but get Shift + B) */ | ||
ZMK_MOCK_PRESS(0,0,10) | ||
ZMK_MOCK_PRESS(0,1,10) | ||
ZMK_MOCK_RELEASE(0,1,10) | ||
ZMK_MOCK_RELEASE(0,0,10) | ||
>; | ||
}; | ||
|
||
/ { | ||
behaviors { | ||
mod_morph: mod_morph { | ||
compatible = "zmk,behavior-mod-morph"; | ||
label = "MOD_MORPH_TEST"; | ||
#binding-cells = <0>; | ||
bindings = <&kp A>, << 1 B>; | ||
mods = <(MOD_LSFT|MOD_RSFT)>; | ||
}; | ||
|
||
}; | ||
|
||
keymap { | ||
compatible = "zmk,keymap"; | ||
label ="Default keymap"; | ||
|
||
default_layer { | ||
bindings = < | ||
&kp LEFT_SHIFT &mod_morph | ||
&kp C &none | ||
>; | ||
}; | ||
|
||
second_layer { | ||
bindings = < | ||
&trans &trans | ||
&kp D &trans | ||
>; | ||
}; | ||
}; | ||
}; |
8 changes: 8 additions & 0 deletions
8
app/tests/mod-morph/2e-masked-morph-into-hold-tap-hold/events.patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
s/.*hid_listener_keycode_pressed.*keycode/pressed: keycode/p | ||
s/.*hid_listener_keycode_released.*keycode/released: keycode/p | ||
s/.*hid_register_mod.*Modifiers set to /reg explicit: Modifiers set to /p | ||
s/.*hid_unregister_mod.*Modifiers set to /unreg explicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_press.*Modifiers set to /reg implicit: Modifiers set to /p | ||
s/.*hid_implicit_modifiers_release.*Modifiers set to /unreg implicit: Modifiers set to /p | ||
s/.*hid_masked_modifiers_set.*Modifiers set to /mask mods: Modifiers set to /p | ||
s/.*hid_masked_modifiers_clear.*Modifiers set to /unmask mods: Modifiers set to /p |
12 changes: 12 additions & 0 deletions
12
app/tests/mod-morph/2e-masked-morph-into-hold-tap-hold/keycode_events.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pressed: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
reg explicit: Modifiers set to 0x02 | ||
reg implicit: Modifiers set to 0x02 | ||
mask mods: Modifiers set to 0x00 | ||
pressed: keycode 0x07 implicit_mods 0x00 explicit_mods 0x00 | ||
reg implicit: Modifiers set to 0x00 | ||
released: keycode 0x07 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg implicit: Modifiers set to 0x00 | ||
unmask mods: Modifiers set to 0x02 | ||
released: keycode 0xE1 implicit_mods 0x00 explicit_mods 0x00 | ||
unreg explicit: Modifiers set to 0x00 | ||
unreg implicit: Modifiers set to 0x00 |
Oops, something went wrong.