blob: 31689c5b03e75c03698f5812ef5aab1bfcc40b81 (
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
44
45
46
|
#include QMK_KEYBOARD_H
#include "quad_tapdance.h"
#include "layer_dance.h"
//
// Definition for the layer key
//
// The only one usage is to activate the layer over the keyboard, but there is
// two way of doing it:
//
// The first mode, when hold, is to activate the layer as long as the key is
// pressed.
// The second one is to switch in the layer mode when tapped, in this mode,
// you can go back into the normal layer by a single press on the key.
//
// Functions that control what our tap dance key does
void tap_dance_layer_finished(tap_dance_state_t *state, void *user_data) {
tap_dance_layer_t *tap_layer = (tap_dance_layer_t *)user_data;
tap_layer->state = cur_dance(state);
switch (tap_layer->state) {
// Remove the layer with a single tap, this way I always have a key to
// remove the the layer, without knowing the previous state I had.
//
// Here, we control both the keypad or the arrow layers
case TD_SINGLE_TAP:
if (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) ) {
layer_clear();
} else {
layer_on(tap_layer->layer);
}
break;
case TD_SINGLE_HOLD: layer_on(tap_layer->layer); break;
default: break;
}
}
void tap_dance_layer_reset(tap_dance_state_t *state, void *user_data) {
tap_dance_layer_t *tap_layer = (tap_dance_layer_t *)user_data;
// If the key was held down and now is released then switch off the layer
if (tap_layer->state == TD_SINGLE_HOLD) {
layer_off(tap_layer->layer);
}
tap_layer->state = TD_NONE;
}
|