diff options
author | Jonas Avellana <14019120+ninjonas@users.noreply.github.com> | 2020-02-17 02:30:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 01:30:03 -0800 |
commit | 79e6b7866988f3cfc1c5b6746e5f400b50704ce8 (patch) | |
tree | 79b72d2c165198fbd1715ac42b625dae1ab1e1a4 /users/ninjonas/tap_dances.c | |
parent | 5e79da9f321a7b50fc82201ad51b1f1bfa0e0114 (diff) | |
download | qmk_firmware-79e6b7866988f3cfc1c5b6746e5f400b50704ce8.tar.gz |
[Keymap] ninjonas keymap updates (#8170)
* [keymap] ninjonas keymap updates
* [refactor(kyria)] updating keymap for numpad layer to be transparent rather than ignores
* [keymap(lily58)] added numpad layer
* [keymap(crkbd)] added numpad layer activated through tapdance
* [fix(8170)] fixing code review changes requested by noroadsleft
* [fix(8170)] updating comments and .md files to use 'Cmd' instead of and ⌘
Diffstat (limited to 'users/ninjonas/tap_dances.c')
-rw-r--r-- | users/ninjonas/tap_dances.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/users/ninjonas/tap_dances.c b/users/ninjonas/tap_dances.c index 0665a1607..ece95887a 100644 --- a/users/ninjonas/tap_dances.c +++ b/users/ninjonas/tap_dances.c @@ -1,5 +1,87 @@ #include "ninjonas.h" +//// BEGIN: Advanced Tap Dances +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (!state->pressed) { + return SINGLE_TAP; + } else { + return SINGLE_HOLD; + } + } else if (state->count == 2) { + return DOUBLE_TAP; + } + else return 8; +} + +// BEGIN: Copy, Paste, NUMPAD +// https://beta.docs.qmk.fm/features/feature_tap_dance#example-6-using-tap-dance-for-momentary-layer-switch-and-layer-toggle-keys +static tap copy_paste_numpad_tap_state = { + .is_press_action = true, + .state = 0 +}; + +void copy_paste_numpad_finished (qk_tap_dance_state_t *state, void *user_data) { + copy_paste_numpad_tap_state.state = cur_dance(state); + switch (copy_paste_numpad_tap_state.state) { + case SINGLE_TAP: + tap_code16(LGUI(KC_V)); // Tap Cmd + V + break; + case SINGLE_HOLD: + tap_code16(LGUI(KC_C)); // Hold Cmd + C + break; + case DOUBLE_TAP: + if (layer_state_is(_NUMPAD)) { + layer_off(_NUMPAD); + } else { + layer_on(_NUMPAD); + } + break; + } +} + +void copy_paste_numpad_reset (qk_tap_dance_state_t *state, void *user_data) { + copy_paste_numpad_tap_state.state = 0; +} +// END: Copy, Paste, NUMPAD + +// BEGIN: Y, NUMPAD +static tap y_numpad_tap_state = { + .is_press_action = true, + .state = 0 +}; + +void y_numpad_finished (qk_tap_dance_state_t *state, void *user_data) { + y_numpad_tap_state.state = cur_dance(state); + switch (y_numpad_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_Y); + break; + case SINGLE_HOLD: + register_code16(KC_Y); + break; + case DOUBLE_TAP: + if (layer_state_is(_NUMPAD)) { + layer_off(_NUMPAD); + } else { + layer_on(_NUMPAD); + } + break; + } +} + +void y_numpad_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (y_numpad_tap_state.state) { + case SINGLE_HOLD: + unregister_code16(KC_Y); + break; + } + y_numpad_tap_state.state = 0; +} +// END: Y, NUMPAD + +//// END: Advanced Tap Dances + qk_tap_dance_action_t tap_dance_actions[] = { [TD_ESC_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_CAPS), [TD_LBRC_BACK] = ACTION_TAP_DANCE_DOUBLE(KC_LBRC, LGUI(KC_LBRC)), @@ -9,4 +91,8 @@ qk_tap_dance_action_t tap_dance_actions[] = { [TD_GUI_GUISPC] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, LGUI(KC_SPC)), [TD_W_CTRLW] = ACTION_TAP_DANCE_DOUBLE(KC_W, LGUI(KC_W)), [TD_Q_GUIQ] = ACTION_TAP_DANCE_DOUBLE(KC_Q, LGUI(KC_Q)), + + // Advanced Tap Dances + [TD_COPY_PASTE_NUMPAD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, copy_paste_numpad_finished, copy_paste_numpad_reset), + [TD_Y_NUMPAD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, y_numpad_finished, y_numpad_reset), };
\ No newline at end of file |