Skip to content

Commit

Permalink
Refactor homerow combos
Browse files Browse the repository at this point in the history
  • Loading branch information
urob committed Sep 16, 2024
1 parent b488a95 commit 0fefc47
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 53 deletions.
24 changes: 14 additions & 10 deletions config/base.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
#define UC 5
#define MOUSE 6

#include "combos.dtsi" // requires layer aliases
#include "mouse.dtsi"
#include "extra_keys.h"

#define XXX &none
#define ___ &trans

Expand Down Expand Up @@ -73,9 +69,17 @@
MAKE_HRM(hml, &kp, &kp, KEYS_R THUMBS) // left-hand HRMs
MAKE_HRM(hmr, &kp, &kp, KEYS_L THUMBS) // right-hand HRMs

MAKE_HRM(hml_repeat, &kp, &key_repeat, KEYS_R THUMBS) // used for HRM-combo
MAKE_HRM(hmr_lpar_lt, &kp, &lpar_lt, KEYS_L THUMBS) // " " " "
MAKE_HRM(hmr_rpar_gt, &kp, &rpar_gt, KEYS_L THUMBS) // " " " "
// HRM combo hack - workaround for lack of tap-only combos (ZMK issue #544)
#define ZMK_COMBO_8(NAME, TAP, KEYPOS, LAYERS, COMBO_TERM, COMBO_IDLE, HOLD, SIDE) \
MAKE_HRM(hm_combo_ ## NAME, &kp, TAP, SIDE THUMBS) \
ZMK_COMBO_6(NAME, &hm_combo_ ## NAME HOLD 0, KEYPOS, LAYERS, COMBO_TERM, COMBO_IDLE)

/* Combos, leader key sequences, mouse emulation */

#include "combos.dtsi" // must be sources after HRM-combo hack
#include "leader.dtsi"
#include "mouse.dtsi"
#include "extra_keys.h"

/* Nav cluster */

Expand Down Expand Up @@ -216,12 +220,12 @@ ZMK_MACRO(win_sleep,
)

// Sticky shift + leader
ZMK_MACRO(shift_leader, bindings = <&sk LSHFT &leader>;)
ZMK_MACRO(leader_sft, bindings = <&sk LSHFT &leader>;)

// misc aliases
#define CANCEL &kp K_CANCEL // cancel caps-word, num-word and smart-mouse
#define DSK_PREV &hmr LCTRL LG(LC(LEFT)) // previous desktop
#define DSK_NEXT &hmr LALT LG(LC(RIGHT)) // next desktop
#define DSK_PREV &hmr LCTRL LG(LC(LEFT)) // previous desktop
#define DSK_NEXT &hmr LALT LG(LC(RIGHT)) // next desktop
#define PIN_WIN &kp LG(LC(LS(Q))) // pin window across desktops
#define PIN_APP &kp LG(LC(LS(A))) // pin application across desktops
#define DSK_MGR &kp LA(GRAVE) // desktop manager
Expand Down
84 changes: 41 additions & 43 deletions config/combos.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,58 @@
#define COMBO_IDLE_FAST 150
#define COMBO_IDLE_SLOW 50

// make homerow combos tap-only (so HRMs can be chorded instantaneously)
#define HRC_TAB &hml LS(LALT) TAB
#define HRC_REPEAT &hml_repeat LS(LCTRL) 0
#define HRC_LPAR &hmr_lpar_lt RS(LCTRL) 0
#define HRC_RPAR &hmr_rpar_gt RS(LALT) 0

/* Horizontal combos - left hand */
ZMK_COMBO(esc, &kp ESC, LT3 LT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(ret, &kp RETURN, LT2 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(mouse, &smart_mouse, LT3 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(esc, &kp ESC, LT3 LT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(ret, &kp RETURN, LT2 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(mouse, &smart_mouse, LT3 LT1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)

ZMK_COMBO(tab, HRC_TAB, LM3 LM2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(repeat,HRC_REPEAT, LM2 LM1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
// Combos overlapping HRMs are set up as hold-taps themselves to allow for instantaneous
// chording of mods. Custom hold-tap instances can be bootstrapped on the go using the
// 8-argument version of ZMK_COMBO defined in base.keymap.
ZMK_COMBO(tab, &hml LS(LALT)TAB, LM3 LM2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(ldr, &leader, LM2 LM1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST, LS(LCTRL), KEYS_R)
ZMK_COMBO(ldrsh, &leader_sft, LM3 LM2 LM1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST, LS(LC(LALT)), KEYS_R)

ZMK_COMBO(cut, &kp LC(X), LB3 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(copy, &kp LC(INS), LB3 LB2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(paste, &kp LS(INS), LB2 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(cut, &kp LC(X), LB3 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(copy, &kp LC(INS), LB3 LB2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(paste, &kp LS(INS), LB2 LB1, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)

/* Horizontal combos - right hand */
ZMK_COMBO(bspc, &kp BSPC, RT1 RT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(del, &kp DEL, RT2 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(bspc, &kp BSPC, RT1 RT2, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(del, &kp DEL, RT2 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)

ZMK_COMBO(lpar, HRC_LPAR, RM1 RM2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(rpar, HRC_RPAR, RM2 RM3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(lt, &kp LT, RM1 RM2, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(gt, &kp GT, RM2 RM3, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(lpar, &lpar_lt, RM1 RM2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST, RS(LCTRL), KEYS_L)
ZMK_COMBO(rpar, &rpar_gt, RM2 RM3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST, RS(LALT), KEYS_L)
ZMK_COMBO(lt, &kp LT, RM1 RM2, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(gt, &kp GT, RM2 RM3, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)

ZMK_COMBO(lbkt, &kp LBKT, RB1 RB2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(rbkt, &kp RBKT, RB2 RB3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(lbrc, &kp LBRC, RB1 RB2, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(rbrc, &kp RBRC, RB2 RB3, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(lbkt, &kp LBKT, RB1 RB2, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(rbkt, &kp RBKT, RB2 RB3, DEF NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(lbrc, &kp LBRC, RB1 RB2, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(rbrc, &kp RBRC, RB2 RB3, NAV , COMBO_TERM_FAST, COMBO_IDLE_FAST)

ZMK_COMBO(grk, &sl UC, RT1 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(cpgrk, &sls 0, RT1 RT2 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(grk, &sl UC, RT1 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)
ZMK_COMBO(cpgrk, &sls 0, RT1 RT2 RT3, DEF NAV NUM, COMBO_TERM_FAST, COMBO_IDLE_FAST)

/* Vertical combos - left hand */
ZMK_COMBO(at, &kp AT, LT3 LM3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(hash, &kp HASH, LT2 LM2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(dllr, &kp DLLR, LT1 LM1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(prcnt, &kp PRCNT, LT0 LM0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(at, &kp AT, LT3 LM3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(hash, &kp HASH, LT2 LM2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(dllr, &kp DLLR, LT1 LM1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(prcnt, &kp PRCNT, LT0 LM0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)

ZMK_COMBO(grave, &kp GRAVE, LM3 LB3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(bslh, &kp BSLH, LM2 LB2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(equal, &kp EQUAL, LM1 LB1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(tilde, &kp TILDE, LM0 LB0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(grave, &kp GRAVE, LM3 LB3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(bslh, &kp BSLH, LM2 LB2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(equal, &kp EQUAL, LM1 LB1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(tilde, &kp TILDE, LM0 LB0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)

/* Vertical combos - right hand */
ZMK_COMBO(caret, &kp CARET, RT0 RM0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(plus, &kp PLUS, RT1 RM1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(star, &kp STAR, RT2 RM2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(amps, &kp AMPS, RT3 RM3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)

ZMK_COMBO(under, &kp UNDER, RM0 RB0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(minus, &kp MINUS, RM1 RB1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(fslh, &kp FSLH, RM2 RB2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(pipe, &kp PIPE, RM3 RB3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(caret, &kp CARET, RT0 RM0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(plus, &kp PLUS, RT1 RM1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(star, &kp STAR, RT2 RM2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(amps, &kp AMPS, RT3 RM3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)

ZMK_COMBO(under, &kp UNDER, RM0 RB0, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(minus, &kp MINUS, RM1 RB1, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(fslh, &kp FSLH, RM2 RB2, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)
ZMK_COMBO(pipe, &kp PIPE, RM3 RB3, DEF NAV NUM, COMBO_TERM_SLOW, COMBO_IDLE_SLOW)

0 comments on commit 0fefc47

Please sign in to comment.