]>
git.gir.st - tmk_keyboard.git/blob - common/layer_switch.c
5 #include "layer_switch.h"
8 uint16_t layer_switch_stat
= 0;
11 uint16_t layer_switch_stat_get(void)
13 return layer_switch_stat
;
16 void layer_switch_stat_set(uint16_t stat
)
18 layer_switch_stat
= stat
;
22 void layer_switch_clear(void)
24 layer_switch_stat
= 0;
28 void layer_switch_on(uint8_t layer
)
30 layer_switch_stat
|= (1<<layer
);
34 void layer_switch_off(uint8_t layer
)
36 layer_switch_stat
&= ~(1<<layer
);
40 void layer_switch_inv(uint8_t layer
)
42 layer_switch_stat
^= (1<<layer
);
46 void layer_switch_debug(void)
48 debug("layer_switch_stat: "); debug_bin16(layer_switch_stat
); debug("\n");
51 action_t
layer_switch_get_action(key_t key
)
54 action
.code
= ACTION_TRANSPARENT
;
56 /* higher layer first */
57 for (int8_t i
= 15; i
>= 0; i
--) {
58 if (layer_switch_stat
& (1<<i
)) {
59 action
= action_for_key(i
, key
);
60 if (action
.code
!= ACTION_TRANSPARENT
) {
62 debug("layer_switch: used. "); debug_dec(i
); debug("\n");