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
44
45
46
47
48
49
50
51
52
53
54
|
/* Return an integer that corresponds to what kind of tap dance should be executed.
*
* How to figure out tap dance state: interrupted and pressed.
*
* Interrupted: If the state of a dance is "interrupted", that means that another key has been hit
* under the tapping term. This is typically indicitive that you are trying to "tap" the key.
*
* Pressed: Whether or not the key is still being pressed. If this value is true, that means the tapping term
* has ended, but the key is still being pressed down. This generally means the key is being "held".
*
* One thing that is currenlty not possible with qmk software in regards to tap dance is to mimic the "permissive hold"
* feature. In general, advanced tap dances do not work well if they are used with commonly typed letters.
* For example "A". Tap dances are best used on non-letter keys that are not hit while typing letters.
*
* Good places to put an advanced tap dance:
* z,q,x,j,k,v,b, any function key, home/end, comma, semi-colon
*
* Criteria for "good placement" of a tap dance key:
* Not a key that is hit frequently in a sentence
* Not a key that is used frequently to double tap, for example 'tab' is often double tapped in a terminal, or
* in a web form. So 'tab' would be a poor choice for a tap dance.
* Letters used in common words as a double. For example 'p' in 'pepper'. If a tap dance function existed on the
* letter 'p', the word 'pepper' would be quite frustating to type.
*
* For the third point, there does exist the 'TD_DOUBLE_SINGLE_TAP', however this is not fully tested
*
*/
#include QMK_KEYBOARD_H
#include "quad_tapdance.h"
td_state_t cur_dance(tap_dance_state_t *state) {
if (state->count == 1) {
// The function can be called when the delay is over, or because of
// another tap.
// I do not check here if the delay is over, as soon as another tap
// occurs, I check the state of the key and switch in hold mode if the
// key is still pressed.
//
if (!state->pressed) return TD_SINGLE_TAP;
// Key has not been interrupted, but the key is still held.
// Means you want to send a 'HOLD'.
else return TD_SINGLE_HOLD;
} else if (state->count == 2) {
// TD_DOUBLE_SINGLE_TAP is to distinguish between typing "pepper",
// and actually wanting a double tap
// action when hitting 'pp'. Suggested use case for this return value
// is when you want to send two
// keystrokes of the key, and not the 'double tap' action/macro.
if (state->interrupted) return TD_DOUBLE_SINGLE_TAP;
else if (state->pressed) return TD_DOUBLE_HOLD;
else return TD_DOUBLE_TAP;
} else return TD_UNKNOWN;
}
|