2022-02-06 19:47:50 -08:00
|
|
|
#include "keymap.h"
|
|
|
|
#include "tapdance.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
bool is_press_action;
|
|
|
|
uint8_t step;
|
|
|
|
} tap;
|
|
|
|
|
|
|
|
static tap dance_state[1];
|
|
|
|
|
2022-02-09 13:45:27 -08:00
|
|
|
// Called on every tap
|
2022-02-06 19:47:50 -08:00
|
|
|
void td_wmlayout_dance(qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
if(state->count == 3) {
|
2022-07-17 21:02:01 -07:00
|
|
|
tap_code16(LGUI(KC_COMMA));
|
|
|
|
tap_code16(LGUI(KC_COMMA));
|
|
|
|
tap_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
}
|
|
|
|
if(state->count > 3) {
|
2022-07-17 21:02:01 -07:00
|
|
|
tap_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:45:27 -08:00
|
|
|
// Called when action finishes
|
2022-02-06 19:47:50 -08:00
|
|
|
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:
|
2022-07-17 21:02:01 -07:00
|
|
|
register_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
case DOUBLE_TAP:
|
2022-07-17 21:02:01 -07:00
|
|
|
register_code16(LGUI(KC_DOT));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
case DOUBLE_SINGLE_TAP:
|
2022-07-17 21:02:01 -07:00
|
|
|
tap_code16(LGUI(KC_COMMA));
|
|
|
|
register_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:45:27 -08:00
|
|
|
// Called when action resets
|
2022-02-06 19:47:50 -08:00
|
|
|
void td_wmlayout_reset(qk_tap_dance_state_t *state, void *user_data) {
|
|
|
|
wait_ms(10);
|
|
|
|
switch (dance_state[0].step) {
|
|
|
|
case SINGLE_TAP:
|
2022-07-17 21:02:01 -07:00
|
|
|
unregister_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
case DOUBLE_TAP:
|
2022-07-17 21:02:01 -07:00
|
|
|
unregister_code16(LGUI(KC_DOT));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
case DOUBLE_SINGLE_TAP:
|
2022-07-17 21:02:01 -07:00
|
|
|
unregister_code16(LGUI(KC_COMMA));
|
2022-02-06 19:47:50 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
dance_state[0].step = 0;
|
|
|
|
}
|