From 79e6b7866988f3cfc1c5b6746e5f400b50704ce8 Mon Sep 17 00:00:00 2001 From: Jonas Avellana <14019120+ninjonas@users.noreply.github.com> Date: Mon, 17 Feb 2020 02:30:03 -0700 Subject: [Keymap] ninjonas keymap updates (#8170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [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 ⌘ --- users/ninjonas/tap_dances.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'users/ninjonas/tap_dances.c') diff --git a/users/ninjonas/tap_dances.c b/users/ninjonas/tap_dances.c index 0665a1607d..ece95887a7 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 -- cgit v1.2.3