keychron_qmk_firmware/users/pcoves/tapDance.c
Ryan c6f1b594a2
Remove legacy keycodes, part 2 (#18660)
* `KC_SYSREQ` -> `KC_SYRQ`

And one `KC_ALT_ERASE` -> `KC_ERAS`

* `KC_NONUS_BSLASH` -> `KC_NUBS`

* `KC_NUMLOCK` -> `KC_NUM`

* `KC_CLCK` -> `KC_CAPS`

* `KC_SCROLLLOCK` -> `KC_SCRL`

* `KC_LBRACKET` -> `KC_LBRC`

* `KC_RBRACKET` -> `KC_RBRC`

* `KC_CAPSLOCK` -> `KC_CAPS`
2022-10-10 20:06:26 +01:00

128 lines
3.1 KiB
C

#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_LEFT_BRACKET));
else
tap_code16(S(KC_9));
break;
case 2:
if (state->pressed)
tap_code16(S(KC_COMM));
else
tap_code(KC_LEFT_BRACKET);
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_RIGHT_BRACKET));
else
tap_code16(S(KC_0));
break;
case 2:
if (state->pressed)
tap_code16(S(KC_DOT));
else
tap_code(KC_RIGHT_BRACKET);
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),
};