blob: 9bc804e641c3f403dbda60a3381a3d9fce41a845 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include <stdint.h>
#include "keyboard.h"
#include "action.h"
#include "debug.h"
#include "layer_switch.h"
uint16_t layer_switch_stat = 0;
uint16_t layer_switch_stat_get(void)
{
return layer_switch_stat;
}
void layer_switch_stat_set(uint16_t stat)
{
layer_switch_stat = stat;
layer_switch_debug();
}
void layer_switch_clear(void)
{
layer_switch_stat = 0;
layer_switch_debug();
}
void layer_switch_on(uint8_t layer)
{
layer_switch_stat |= (1<<layer);
layer_switch_debug();
}
void layer_switch_off(uint8_t layer)
{
layer_switch_stat &= ~(1<<layer);
layer_switch_debug();
}
void layer_switch_inv(uint8_t layer)
{
layer_switch_stat ^= (1<<layer);
layer_switch_debug();
}
void layer_switch_debug(void)
{
debug("layer_switch_stat: "); debug_bin16(layer_switch_stat); debug("\n");
}
action_t layer_switch_get_action(key_t key)
{
action_t action;
action.code = ACTION_TRANSPARENT;
/* higher layer first */
for (int8_t i = 15; i >= 0; i--) {
if (layer_switch_stat & (1<<i)) {
action = action_for_key(i, key);
if (action.code != ACTION_TRANSPARENT) {
layer_switch_debug();
debug("layer_switch: used. "); debug_dec(i); debug("\n");
return action;
}
}
}
return action;
}
|