X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=users%2F333fred%2F333fred.c;h=79df8c4dea1cc500cde24339461185db9a8cf4c5;hb=810c8db7706f40f0436555fdffbaf849dc0a5641;hp=ef2d741e5b38e0d6454782b4c4d8055363a0590d;hpb=89357b96d40f6f8189da09c3d15131e22991ed4c;p=qmk_firmware.git diff --git a/users/333fred/333fred.c b/users/333fred/333fred.c index ef2d741e5..79df8c4de 100644 --- a/users/333fred/333fred.c +++ b/users/333fred/333fred.c @@ -9,7 +9,7 @@ typedef enum { static tap_dance_state_enum tap_dance_state; static bool tap_dance_active = false; -void tap_dance_layer_finished(qk_tap_dance_state_t *state, void *user_data) { +void tap_dance_sym_vim_finished(qk_tap_dance_state_t *state, void *user_data) { // Determine the current state if (state->count == 1) { if (state->interrupted || state->pressed == 0) tap_dance_state = SINGLE_TAP; @@ -34,11 +34,11 @@ void tap_dance_layer_finished(qk_tap_dance_state_t *state, void *user_data) { break; case DOUBLE: layer_on(VIM); + break; } } - -void tap_dance_layer_reset(qk_tap_dance_state_t *state, void *user_data) { +void tap_dance_sym_vim_reset(qk_tap_dance_state_t *state, void *user_data) { switch(tap_dance_state) { case SINGLE_TAP: clear_oneshot_layer_state(ONESHOT_PRESSED); @@ -52,12 +52,71 @@ void tap_dance_layer_reset(qk_tap_dance_state_t *state, void *user_data) { } } +void tap_dance_copy_paste_finished(qk_tap_dance_state_t *state, void *user_data) { + bool is_paste = state->count == 2; + // If either the one-shot shift is set, or if shift is being held, count as shift being held. + // We'll clear the one-shot shift if it was held + uint8_t one_shot_mods = get_oneshot_mods(); + bool is_shift = false; + + if (get_mods() & MOD_MASK_SHIFT) { + is_shift = true; + } else if (one_shot_mods & MOD_MASK_SHIFT) { + set_oneshot_mods(one_shot_mods & ~MOD_MASK_SHIFT); + is_shift = true; + } + + if (is_paste) { + if (is_shift) { + SEND_STRING(SS_LSFT(SS_TAP(X_INSERT))); + } else { + SEND_STRING(SS_LCTRL("v")); + } + } else { + if (is_shift) { + SEND_STRING(SS_LCTRL(SS_TAP(X_INSERT))); + } else { + SEND_STRING(SS_LCTRL("c")); + } + } +} + qk_tap_dance_action_t tap_dance_actions[] = { - [TD_SYM_VIM] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_layer_finished, tap_dance_layer_reset) + [TD_SYM_VIM] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_sym_vim_finished, tap_dance_sym_vim_reset), + [TD_COPY_PASTE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_copy_paste_finished, NULL) }; -void tap_dance_process_record(uint16_t keycode) { +void tap_dance_process_keycode(uint16_t keycode) { if (tap_dance_state == SINGLE_TAP && keycode != TD(TD_SYM_VIM)) { tap_dance_active = false; } } + +__attribute__ ((weak)) +void layer_state_set_rgb(uint32_t state) {} + +uint32_t layer_state_set_user(uint32_t state) { + layer_state_set_rgb(state); + return state; +} + +bool try_handle_macro(uint16_t keycode, keyrecord_t *record) { + switch (keycode) + { + case DLEFT: + if (record->event.pressed) + SEND_STRING(SS_LGUI(SS_LALT(SS_TAP(X_LEFT)))); + return true; + case DRIGHT: + if (record->event.pressed) + SEND_STRING(SS_LGUI(SS_LALT(SS_TAP(X_RIGHT)))); + return true; + case PSCREEN_APP: + if (record->event.pressed) + SEND_STRING(SS_LALT(SS_TAP(X_PSCREEN))); + return true; + + default: + return false; + } +}