Skip to content

Commit

Permalink
Home-row mods with rollover prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
flmng0 committed Oct 10, 2023
1 parent 44409c4 commit dfb83a8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
42 changes: 36 additions & 6 deletions flmng0.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
*
* Open on left hand, close on right hand.
*/
const uint16_t PROGMEM c_lparen[] = {KC_T, BM_D, COMBO_END};
const uint16_t PROGMEM c_rparen[] = {KC_N, BM_H, COMBO_END};
const uint16_t PROGMEM c_lparen[] = {HM_T, KC_D, COMBO_END};
const uint16_t PROGMEM c_rparen[] = {HM_N, KC_H, COMBO_END};

const uint16_t PROGMEM c_lbracket[] = {KC_S, BM_C, COMBO_END};
const uint16_t PROGMEM c_rbracket[] = {KC_E, BM_COMM, COMBO_END};
const uint16_t PROGMEM c_lbracket[] = {HM_S, KC_C, COMBO_END};
const uint16_t PROGMEM c_rbracket[] = {HM_E, KC_COMM, COMBO_END};

const uint16_t PROGMEM c_lbrace[] = {KC_G, KC_V, COMBO_END};
const uint16_t PROGMEM c_rbrace[] = {KC_M, KC_K, COMBO_END};

const uint16_t PROGMEM c_langle[] = {KC_R, BM_X, COMBO_END};
const uint16_t PROGMEM c_rangle[] = {KC_I, BM_DOT, COMBO_END};
const uint16_t PROGMEM c_langle[] = {HM_R, KC_X, COMBO_END};
const uint16_t PROGMEM c_rangle[] = {HM_I, KC_DOT, COMBO_END};

/**
* Common symbols.
Expand Down Expand Up @@ -88,3 +88,33 @@ bool caps_word_press_user(uint16_t keycode) {
}
}

#define ROLLOVER(kca, kcb, modded_b, mod_a) \
case modded_b: \
if (record->event.pressed && record->tap.count > 0) { \
if (mods & MOD_BIT(mod_a)) { \
unregister_mods(MOD_BIT(mod_a)); \
tap_code(kca); \
tap_code(kcb); \
add_mods(MOD_BIT(mod_a)); \
return false; \
} \
} \
return true;

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t mods = get_mods();

switch (keycode) {
ROLLOVER(KC_A, KC_R, HM_R, KC_LGUI);
ROLLOVER(KC_R, KC_S, HM_S, KC_LALT);
ROLLOVER(KC_S, KC_T, HM_T, KC_LSFT);
ROLLOVER(KC_T, KC_G, KC_G, KC_LCTL);

ROLLOVER(KC_N, KC_M, KC_M, KC_RCTL);
ROLLOVER(KC_E, KC_N, HM_N, KC_RSFT);
ROLLOVER(KC_I, KC_E, HM_E, KC_LALT);
ROLLOVER(KC_O, KC_I, HM_I, KC_RGUI);
}

return true;
}
2 changes: 1 addition & 1 deletion keymaps/combo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"keymap": "flmng0",
"layout": "LAYOUT_a_dux_wrap",
"layers": [
[ "_BASE" ],
[ "_BASE_HRM" ],
[ "_NAV" ],
[ "_SYM" ],
[ "_NUM" ],
Expand Down
20 changes: 19 additions & 1 deletion layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,25 @@
#define BM_DOT LALT_T(KC_DOT)
#define BM_QUOT RGUI_T(KC_QUOT)

#define _BASE \

#define HM_A LGUI_T(KC_A)
#define HM_R LALT_T(KC_R)
#define HM_S LSFT_T(KC_S)
#define HM_T LCTL_T(KC_T)

#define HM_N RCTL_T(KC_N)
#define HM_E RSFT_T(KC_E)
#define HM_I LALT_T(KC_I)
#define HM_O RGUI_T(KC_O)


#define _BASE_HRM \
KC_Q , KC_W , KC_F , KC_P , KC_B , KC_J , KC_L , KC_U , KC_Y , KC_SCLN, \
HM_A , HM_R , HM_S , HM_T , KC_G , KC_M , HM_N , HM_E , HM_I , HM_O , \
KC_Z , KC_X , KC_C , KC_D , KC_V , KC_K , KC_H , KC_COMM, KC_DOT , KC_QUOT, \
L_NUM , L_NAV , L_SYM , KC_BSPC

#define _BASE_BRM \
KC_Q , KC_W , KC_F , KC_P , KC_B , KC_J , KC_L , KC_U , KC_Y , KC_SCLN, \
KC_A , KC_R , KC_S , KC_T , KC_G , KC_M , KC_N , KC_E , KC_I , KC_O , \
BM_Z , BM_X , BM_C , BM_D , KC_V , KC_K , BM_H , BM_COMM, BM_DOT , BM_QUOT, \
Expand Down

0 comments on commit dfb83a8

Please sign in to comment.