Skip to content

Commit

Permalink
feat(sweep): shortcut behaviour functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JJGadgets committed Mar 14, 2024
1 parent 27f6b7d commit 22fe8ea
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 100 deletions.
121 changes: 21 additions & 100 deletions config/cradio.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <dt-bindings/zmk/outputs.h>
#include <dt-bindings/zmk/ext_power.h>

// my own code
#include "../functions/behaviours.dtsi"

// Layers name to integer definition
#define DEFAULT 0
#define NUM_KEYS 1
Expand All @@ -24,10 +27,10 @@
#define MT 10

#define EMPTYLAYER \
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans \
&trans &trans &trans &trans

&mt {
bindings = <&sk>, <&kp>;
Expand All @@ -46,102 +49,20 @@

/ {
behaviors {
/omit-if-no-ref/ mmsc: mod_morph_semicolon {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp COLON>, <&kp SEMICOLON>;
mods = <(MOD_LSFT)>;
};
/omit-if-no-ref/ mmsa: mod_morph_delete_semicolon {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&mmsc>, <&kp APOSTROPHE>;
mods = <(MOD_RALT)>;
};
/omit-if-no-ref/ mmgrave: mod_morph_grave {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp TILDE>, <&kp GRAVE>;
mods = <(MOD_LSFT)>;
};
/omit-if-no-ref/ mmqgr: mod_morph_q_grave {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp Q>, <&mmgrave>;
mods = <(MOD_RALT)>;
};
/omit-if-no-ref/ mmat: mod_morph_a_tab {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp A>, <&kp TAB>;
mods = <(MOD_RALT|MOD_RGUI)>;
keep-mods = <(MOD_RALT|MOD_RGUI)>;
};
/omit-if-no-ref/ mmec: mod_morph_esc_caps {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp ESC>, <&caps_word>;
mods = <(MOD_LSFT)>;
};
/omit-if-no-ref/ esc: esc_ctrl {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;
bindings = <&kp>, <&mmec>;
};
/omit-if-no-ref/ rm: repeat_mod {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;
bindings = <&kp>, <&key_repeat>;
};
/omit-if-no-ref/ mto: mod_tap_to_layer {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;
bindings = <&sk>, <&to>;
};
/omit-if-no-ref/ mtog: mod_tap_toggle_layer {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;
bindings = <&sk>, <&tog>;
};
/omit-if-no-ref/ lt2: layer_tap_2 {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "hold-preferred";
tapping-term-ms = <200>;
bindings = <&mo>, <&to>;
};
/omit-if-no-ref/ mmzd: mod_morph_z_delete {
compatible = "zmk,behavior-mod-morph";
#binding-cells = <0>;
bindings = <&kp Z>, <&kp DEL>;
mods = <(MOD_RALT)>;
};
/omit-if-no-ref/ ltz: layer_tap_z {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "tap-preferred";
tapping-term-ms = <280>;
quick-tap-ms = <175>;
require-prior-idle-ms = <150>;
bindings = <&mo>, <&mmzd>;
};
/omit-if-no-ref/ hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
#binding-cells = <2>;
flavor = "tap-preferred";
tapping-term-ms = <280>;
quick-tap-ms = <175>;
require-prior-idle-ms = <150>;
bindings = <&kp>, <&kp>;
};
JJ_MM(mmsc, mod_morph_semicolon, mods = <(MOD_LSFT)>; bindings = <&kp COLON>, <&kp SEMICOLON>;)
JJ_MM(mmsa, mod_morph_delete_semicolon, mods = <(MOD_RALT)>; bindings = <&mmsc>, <&kp APOSTROPHE>;)
JJ_MM(mmgrave, mod_morph_grave, mods = <(MOD_LSFT)>; bindings = <&kp TILDE>, <&kp GRAVE>;)
JJ_MM(mmqgr, mod_morph_q_grave, mods = <(MOD_RALT)>; bindings = <&kp Q>, <&mmgrave>;)
JJ_MM(mmat, mod_morph_a_tab, mods = <(MOD_RALT|MOD_RGUI)>; keep-mods = <(MOD_RALT|MOD_RGUI)>; bindings = <&kp A>, <&kp TAB>;)
JJ_MM(mmec, mod_morph_esc_caps, mods = <(MOD_LSFT)>; bindings = <&kp ESC>, <&caps_word>;)
JJ_HT_HOLD(esc, esc_ctrl, bindings = <&kp>, <&mmec>;)
JJ_HT_HOLD(rm, repeat_mod, bindings = <&kp>, <&key_repeat>;)
JJ_HT_HOLD(mto, mod_tap_to_layer, bindings = <&sk>, <&to>;)
JJ_HT_HOLD(mtog, mod_tap_toggle_layer, bindings = <&sk>, <&tog>;)
JJ_HT_HOLD(lt2, layer_tap_2, bindings = <&mo>, <&to>;)
JJ_MM(mmzd, mod_morph_z_delete, mods = <(MOD_RALT)>; bindings = <&kp Z>, <&kp DEL>;)
JJ_HT_TAP(ltz, layer_tap_z, bindings = <&mo>, <&mmzd>;)
JJ_HT_TAP(hm, homerow_mods, bindings = <&kp>, <&kp>;)
};
keymap {
compatible = "zmk,keymap";
Expand Down
42 changes: 42 additions & 0 deletions functions/behaviours.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// vi: ft=c
#define JJ(name,desc,compat,cells...) \
/omit-if-no-ref/ name: desc { \
compatible = compat; \
#binding-cells = <cells>; \
__VA_ARGS__ \
};

#define JJ_MM(name,desc,...) \
/omit-if-no-ref/ name: desc { \
compatible = "zmk,behavior-mod-morph"; \
#binding-cells = <0>; \
__VA_ARGS__ \
};

#define JJ_HT(name,desc,flav...) \
/omit-if-no-ref/ name: desc { \
compatible = "zmk,behavior-hold-tap"; \
#binding-cells = <2>; \
flavor = flav; \
__VA_ARGS__ \
};

#define JJ_HT_HOLD(name,desc,...) \
/omit-if-no-ref/ name: desc { \
compatible = "zmk,behavior-hold-tap"; \
#binding-cells = <2>; \
flavor = "hold-preferred"; \
tapping-term-ms = <200>; \
__VA_ARGS__ \
};

#define JJ_HT_TAP(name,desc,...) \
/omit-if-no-ref/ name: desc { \
compatible = "zmk,behavior-hold-tap"; \
#binding-cells = <2>; \
flavor = "tap-preferred"; \
tapping-term-ms = <280>; \
quick-tap-ms = <175>; \
require-prior-idle-ms = <150>; \
__VA_ARGS__ \
};

0 comments on commit 22fe8ea

Please sign in to comment.