diff options
author | pcoves <33952527+pcoves@users.noreply.github.com> | 2020-07-08 22:57:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 21:57:11 +0100 |
commit | facca2331519d5d56a926f93f0cdf925fe0857da (patch) | |
tree | 575913db2ecb5a78eeb22acabd69825f54d31b0d /users/pcoves/tapDance.c | |
parent | 071e0c2029e7923cbaa6ff721365b2f61cdd08d8 (diff) | |
download | qmk_firmware-facca2331519d5d56a926f93f0cdf925fe0857da.tar.gz |
Add pcoves's userspace (#9354)
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Pablo COVES <pablo.coves@anatoscope.com>
Diffstat (limited to 'users/pcoves/tapDance.c')
-rw-r--r-- | users/pcoves/tapDance.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/users/pcoves/tapDance.c b/users/pcoves/tapDance.c new file mode 100644 index 000000000..f8c9aaf46 --- /dev/null +++ b/users/pcoves/tapDance.c @@ -0,0 +1,127 @@ +#include "tapDance.h" + +#include "quantum.h" + +void left(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) + tap_code16(S(KC_LBRACKET)); + else + tap_code16(S(KC_9)); + break; + case 2: + if (state->pressed) + tap_code16(S(KC_COMM)); + else + tap_code(KC_LBRACKET); + break; + default: + reset_tap_dance(state); + } +} + +void right(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) + tap_code16(S(KC_RBRACKET)); + else + tap_code16(S(KC_0)); + break; + case 2: + if (state->pressed) + tap_code16(S(KC_DOT)); + else + tap_code(KC_RBRACKET); + break; + default: + reset_tap_dance(state); + } +} + +enum { REST, HOLD1, HOLD2, HOLD3 }; + +static int Alt = REST; +void altFinish(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) { + register_code(KC_LALT); + Alt = HOLD1; + } + break; + case 2: + if (state->pressed) { + register_code(KC_RALT); + Alt = HOLD2; + } + break; + case 3: + if (state->pressed) { + register_code(KC_RALT); + register_code(KC_RSHIFT); + Alt = HOLD3; + } + break; + default: + reset_tap_dance(state); + } +} + +void altReset(qk_tap_dance_state_t* state, void* user_data) { + switch (Alt) { + case HOLD1: + unregister_code(KC_LALT); + break; + case HOLD2: + unregister_code(KC_RALT); + break; + case HOLD3: + unregister_code(KC_RSHIFT); + unregister_code(KC_RALT); + break; + } + Alt = REST; +} + +static int Ctrl = REST; +void ctrlFinish(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) { + register_code(KC_LCTL); + Ctrl = HOLD1; + } else { + tap_code(KC_ESC); + } + break; + case 2: + if (state->pressed) { + register_code(KC_LGUI); + Ctrl = HOLD2; + } + break; + default: + reset_tap_dance(state); + } +} + +void ctrlReset(qk_tap_dance_state_t* state, void* user_data) { + switch (Ctrl) { + case HOLD1: + unregister_code(KC_LCTL); + break; + case HOLD2: + unregister_code(KC_LGUI); + break; + } + Ctrl = REST; +} + +qk_tap_dance_action_t tap_dance_actions[] = { + [ALT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, altFinish, altReset), + [CTRL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctrlFinish, ctrlReset), + [LEFT] = ACTION_TAP_DANCE_FN(left), + [RIGHT] = ACTION_TAP_DANCE_FN(right), +}; |