blob: 1008ffce31f5cc1506686324d4a0137fa1518478 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include QMK_KEYBOARD_H
#include "quad_tapdance.h"
#include "tap_hold_dance.h"
void tap_hold_dance_released(tap_dance_state_t *state, void *user_data) {
if (state->finished || state->interrupted) return;
tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data;
tap_code(tap_hold_dance->tap);
}
void tap_hold_dance_finished(tap_dance_state_t *state, void *user_data) {
tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data;
tap_hold_dance->state = cur_dance(state);
switch (tap_hold_dance->state) {
case TD_SINGLE_HOLD:
/* If a key is pressed before the TAPPING_TERM delay, consider a
* tap instead of switching to the mod.
*/
if (state->interrupted) {
tap_hold_dance->held = tap_hold_dance->tap;
} else {
tap_hold_dance->held = tap_hold_dance->hold;
}
register_code(tap_hold_dance->held);
break;
case TD_DOUBLE_HOLD:
tap_hold_dance->held = tap_hold_dance->tap;
register_code(tap_hold_dance->tap);
default:
break;
}
}
void tap_hold_dance_reset(tap_dance_state_t *state, void *user_data) {
tap_hold_dance_t *tap_hold_dance = (tap_hold_dance_t *)user_data;
if (tap_hold_dance->state != TD_NONE && tap_hold_dance->held) {
unregister_code(tap_hold_dance->held);
tap_hold_dance->held = 0;
}
tap_hold_dance->state = TD_NONE;
}
|