summaryrefslogtreecommitdiff
path: root/config/utils
diff options
context:
space:
mode:
Diffstat (limited to 'config/utils')
-rw-r--r--config/utils/common.h30
-rw-r--r--config/utils/homerow.h22
-rw-r--r--config/utils/keypos_42keys.h62
-rw-r--r--config/utils/unicode.h85
4 files changed, 199 insertions, 0 deletions
diff --git a/config/utils/common.h b/config/utils/common.h
new file mode 100644
index 0000000..babff13
--- /dev/null
+++ b/config/utils/common.h
@@ -0,0 +1,30 @@
+#define ___ &trans
+#define XXX &none
+
+#ifndef QUICK_TAP_MS
+ #define QUICK_TAP_MS 175
+#endif
+
+#define ZMK_HELPER_STRINGIFY(x) #x
+
+#define MO_TOG(layer) &mo_tog layer layer // Macro to apply momentary-layer-on-hold/toggle-layer-on-tap to a specific layer
+
+&sk { // sticky-key config
+ release-after-ms = <900>; // release after 0.6s
+ quick-release; // no double capitalization when rolling keys
+};
+
+&sl { // sticky-layer config
+ ignore-modifiers; // allow chording sticky mods & layers
+};
+
+&lt { // layer-tap config
+ flavor = "balanced";
+ tapping-term-ms = <200>;
+ quick-tap-ms = <QUICK_TAP_MS>;
+};
+
+
+#include "homerow.h"
+#include "unicode.h"
+
diff --git a/config/utils/homerow.h b/config/utils/homerow.h
new file mode 100644
index 0000000..c8fe06f
--- /dev/null
+++ b/config/utils/homerow.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#define MAKE_HRM(NAME, HOLD, TAP) \
+ / { \
+ behaviours { \
+ NAME: NAME { \
+ label = ZMK_HELPER_STRINGIFY(ZB_ ## NAME); \
+ compatible = "zmk,behavior-hold-tap"; \
+ #binding-cells = <2>; \
+ flavor = "balanced"; \
+ tapping-term-ms = <280>; \
+ quick-tap-ms = <QUICK_TAP_MS>; \
+ require-prior-idle-ms = <150>; \
+ bindings = <HOLD>, <TAP>; \
+ hold-trigger-on-release; \
+ }; \
+ }; \
+ };
+
+MAKE_HRM(hml, &kp, &kp)
+MAKE_HRM(hmr, &kp, &kp)
+
diff --git a/config/utils/keypos_42keys.h b/config/utils/keypos_42keys.h
new file mode 100644
index 0000000..21f7052
--- /dev/null
+++ b/config/utils/keypos_42keys.h
@@ -0,0 +1,62 @@
+// https://raw.githubusercontent.com/urob/zmk-nodefree-config/8506dbaaee9b46d200aa553a94b6dbca8560a5e1/keypos_def/keypos_42keys.h
+/* 42 KEY MATRIX / LAYOUT MAPPING
+
+ ╭────────────────────────┬────────────────────────╮ ╭─────────────────────────┬─────────────────────────╮
+ │ 0 1 2 3 4 5 │ 6 7 8 9 10 11 │ │ LT5 LT4 LT3 LT2 LT1 LT0 │ RT0 RT1 RT2 RT3 RT4 RT5 │
+ │ 12 13 14 15 16 17 │ 18 19 20 21 22 23 │ │ LM5 LM4 LM3 LM2 LM1 LM0 │ RM0 RM1 RM2 RM3 RM4 RM5 │
+ │ 24 25 26 27 28 29 │ 30 31 32 33 34 35 │ │ LB5 LB4 LB3 LB2 LB1 LB0 │ RB0 RB1 RB2 RB3 RB4 RB5 │
+ ╰───────────╮ 36 37 38 │ 39 40 41 ╭───────────╯ ╰───────────╮ LH2 LH1 LH0 │ RH0 RH1 RH2 ╭───────────╯
+ ╰────────────┴────────────╯ ╰─────────────┴─────────────╯ */
+
+#pragma once
+
+#define LT0 5 // left-top row
+#define LT1 4
+#define LT2 3
+#define LT3 2
+#define LT4 1
+#define LT5 0
+
+#define RT0 6 // right-top row
+#define RT1 7
+#define RT2 8
+#define RT3 9
+#define RT4 10
+#define RT5 11
+
+#define LM0 17 // left-middle row
+#define LM1 16
+#define LM2 15
+#define LM3 14
+#define LM4 13
+#define LM5 12
+
+#define RM0 18 // right-middle row
+#define RM1 19
+#define RM2 20
+#define RM3 21
+#define RM4 22
+#define RM5 23
+
+#define LB0 29 // left-bottom row
+#define LB1 28
+#define LB2 27
+#define LB3 26
+#define LB4 25
+#define LB5 24
+
+#define RB0 30 // right-bottom row
+#define RB1 31
+#define RB2 32
+#define RB3 33
+#define RB4 34
+#define RB5 35
+
+#define LH0 38 // left thumb keys
+#define LH1 37
+#define LH2 36
+
+#define RH0 39 // right thumb keys
+#define RH1 40
+#define RH2 41
+
diff --git a/config/utils/unicode.h b/config/utils/unicode.h
new file mode 100644
index 0000000..df2b298
--- /dev/null
+++ b/config/utils/unicode.h
@@ -0,0 +1,85 @@
+#pragma once
+
+#define COMBO(name, POS, LAYERS, BINDINGS) \
+ / { \
+ combos { \
+ compatible = "zmk,combos"; \
+ name { \
+ timeout-ms = <50>; \
+ key-positions = <POS>; \
+ layers = <LAYERS>; \
+ bindings = <BINDINGS>; \
+ }; \
+ }; \
+ };
+
+/* ZMK_UNICODE */
+#define UC_LEAD_MACWIN &macro_press &kp LALT // macOS/Windows-Alt-Codes
+#define UC_LEAD_LINUX &macro_tap &kp LS(LC(U)) // Linux
+#define UC_LEAD_WINDOWS &macro_tap &kp RALT &kp U // Windows + WinCompose (default)
+
+#define UC_TRAIL_MACWIN &macro_release &kp LALT // macOS/Windows-Alt-Codes
+#define UC_TRAIL_LINUX &macro_tap &kp SPACE // Linux
+#define UC_TRAIL_WINDOWS &macro_tap &kp RET // Windows + WinCompose (default)
+
+#define UC_MACRO_LINUX(name, unicode_bindings) \
+ / { \
+ macros { \
+ name: name { \
+ compatible = "zmk,behavior-macro"; \
+ label = ZMK_HELPER_STRINGIFY(UC_MACRO_ ## name); \
+ wait-ms = <0>; \
+ tap-ms = <0>; \
+ #binding-cells = <0>; \
+ bindings = <UC_LEAD_LINUX>, <&macro_tap unicode_bindings>, <UC_TRAIL_LINUX>; \
+ }; \
+ }; \
+ };
+#define UC_MACRO_MACWIN(name, unicode_bindings) \
+ / { \
+ macros { \
+ name: name { \
+ compatible = "zmk,behavior-macro"; \
+ label = ZMK_HELPER_STRINGIFY(UC_MACRO_ ## name); \
+ wait-ms = <0>; \
+ tap-ms = <0>; \
+ #binding-cells = <0>; \
+ bindings = <UC_LEAD_MACWIN>, <&macro_tap unicode_bindings>, <UC_TRAIL_MACWIN>; \
+ }; \
+ }; \
+ };
+
+#define UC_MODMORPH(name, uc_binding, shifted_uc_binding) \
+ / { \
+ behaviors { \
+ name: name { \
+ compatible = "zmk,behavior-mod-morph"; \
+ label = ZMK_HELPER_STRINGIFY(UC_MORPH_ ## name); \
+ #binding-cells = <0>; \
+ bindings = <uc_binding>, <shifted_uc_binding>; \
+ mods = <(MOD_LSFT|MOD_RSFT)>; \
+ }; \
+ }; \
+ };
+
+#define ZMK_UNICODE_SINGLE(name, L0, L1, L2, L3) \
+ UC_MACRO(name ## _lower, &kp L0 &kp L1 &kp L2 &kp L3) \
+ UC_MODMORPH(name, &name ## _lower, &none)
+
+#define ZMK_UNICODE_PAIR_LINUX(name, L0, L1, L2, L3, U0, U1, U2, U3) \
+ UC_MACRO_LINUX(name ## _lower, &kp L0 &kp L1 &kp L2 &kp L3) \
+ UC_MACRO_LINUX(name ## _upper, &kp U0 &kp U1 &kp U2 &kp U3) \
+ UC_MODMORPH(name, &name ## _lower, &name ## _upper)
+
+#define ZMK_UNICODE_PAIR_MACWIN(name, L0, L1, L2, L3, U0, U1, U2, U3) \
+ UC_MACRO_MACWIN(name ## _lower, &kp L0 &kp L1 &kp L2 &kp L3) \
+ UC_MACRO_MACWIN(name ## _upper, &kp U0 &kp U1 &kp U2 &kp U3) \
+ UC_MODMORPH(name, &name ## _lower, &name ## _upper)
+
+ZMK_UNICODE_PAIR_MACWIN(mwn_no_ae, N0, N0, E, N6, N0, N0, C, N6)
+ZMK_UNICODE_PAIR_MACWIN(mwn_no_ao, N0, N0, E, N5, N0, N0, C, N5)
+ZMK_UNICODE_PAIR_MACWIN(mwn_no_oe, N0, N0, F, N8, N0, N0, D, N8)
+ZMK_UNICODE_PAIR_LINUX(lnx_no_ae, N0, N0, E, N6, N0, N0, C, N6)
+ZMK_UNICODE_PAIR_LINUX(lnx_no_ao, N0, N0, E, N5, N0, N0, C, N5)
+ZMK_UNICODE_PAIR_LINUX(lnx_no_oe, N0, N0, F, N8, N0, N0, D, N8)
+