QMK/keyboards/betalupi_ergodox/keymaps/default/tapdance/wmlayout.c

56 lines
1.1 KiB
C

#include "keymap.h"
#include "tapdance.h"
typedef struct {
bool is_press_action;
uint8_t step;
} tap;
static tap dance_state[1];
// Called on every tap
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data) {
if(state->count == 3) {
tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L));
}
if(state->count > 3) {
tap_code16(LGUI(KC_L));
}
}
// Called when action finishes
void td_wmlayout_finished(qk_tap_dance_state_t *state, void *user_data) {
dance_state[0].step = dance_step(state);
switch (dance_state[0].step) {
case SINGLE_TAP:
register_code16(LGUI(KC_L));
break;
case DOUBLE_TAP:
register_code16(LGUI(KC_K));
break;
case DOUBLE_SINGLE_TAP:
tap_code16(LGUI(KC_L));
register_code16(LGUI(KC_L));
break;
}
}
// Called when action resets
void td_wmlayout_reset(qk_tap_dance_state_t *state, void *user_data) {
wait_ms(10);
switch (dance_state[0].step) {
case SINGLE_TAP:
unregister_code16(LGUI(KC_L));
break;
case DOUBLE_TAP:
unregister_code16(LGUI(KC_K));
break;
case DOUBLE_SINGLE_TAP:
unregister_code16(LGUI(KC_L));
break;
}
dance_state[0].step = 0;
}