Last active
July 1, 2017 10:04
-
-
Save h-youhei/c77d626a097799c1c6345d4cc0fa08b8 to your computer and use it in GitHub Desktop.
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
enum Layer { | |
L_BASE, | |
L_FN, | |
}; | |
#define TAP_CTRL_BS_HOLD_CTRL 0 | |
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |
[L_BASE] = KEYMAP( | |
..., CTL_T(KC_BSPC), ..., LT(L_FN, KC_SPC), | |
), | |
[L_FN] = KEYMAP( | |
..., F(TAP_CTRL_BS_HOLD_CTRL), ..., KC_TRNS, | |
), | |
}; | |
bool is_hold(keyrecord_t *record) { | |
return (record->tap.count <= 0 || record->tap.interrupted); | |
}; | |
void tap_ctrl_bs_hold_mod(keyrecord_t *record, uint8_t mod) { | |
if (record->event.pressed) { | |
if (is_hold(record)) { | |
register_mods(mod); | |
} | |
} | |
else { | |
if (is_hold(record)) { | |
unregister_mods(mod); | |
} | |
else { | |
register_mods(MOD_LCTL); | |
register_code(KC_BSPC); | |
unregister_code(KC_BSPC); | |
unregister_mods(MOD_LCTL); | |
} | |
} | |
}; | |
const uint16_t PROGMEM fn_actions[] = { | |
[TAP_CTRL_BS_HOLD_CTRL] = ACTION_FUNCTION_TAP(TAP_CTRL_BS_HOLD_CTRL), | |
}; | |
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { | |
switch(id) { | |
case TAP_CTRL_BS_HOLD_CTRL: | |
tap_ctrl_bs_hold_mod(record, MOD_LCTL); | |
break; | |
default: | |
break; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment