QMK/keymaps/default/tapdance/wmlayout.c

56 lines
1.1 KiB
C
Raw Normal View History

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) {
tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L));
tap_code16(LGUI(KC_L));
}
if(state->count > 3) {
tap_code16(LGUI(KC_L));
}
}
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:
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;
}
}
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:
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;
}