56 lines
1.2 KiB
C
56 lines
1.2 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_COMMA));
|
|
tap_code16(LGUI(KC_COMMA));
|
|
tap_code16(LGUI(KC_COMMA));
|
|
}
|
|
if(state->count > 3) {
|
|
tap_code16(LGUI(KC_COMMA));
|
|
}
|
|
}
|
|
|
|
// 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_COMMA));
|
|
break;
|
|
case DOUBLE_TAP:
|
|
register_code16(LGUI(KC_DOT));
|
|
break;
|
|
case DOUBLE_SINGLE_TAP:
|
|
tap_code16(LGUI(KC_COMMA));
|
|
register_code16(LGUI(KC_COMMA));
|
|
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_COMMA));
|
|
break;
|
|
case DOUBLE_TAP:
|
|
unregister_code16(LGUI(KC_DOT));
|
|
break;
|
|
case DOUBLE_SINGLE_TAP:
|
|
unregister_code16(LGUI(KC_COMMA));
|
|
break;
|
|
}
|
|
dance_state[0].step = 0;
|
|
}
|