aboutsummaryrefslogtreecommitdiff
path: root/common/layer_switch.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/layer_switch.c')
-rw-r--r--common/layer_switch.c90
1 files changed, 2 insertions, 88 deletions
diff --git a/common/layer_switch.c b/common/layer_switch.c
index a5d426a89..359e6b9d8 100644
--- a/common/layer_switch.c
+++ b/common/layer_switch.c
@@ -24,7 +24,7 @@ void default_layer_set(uint8_t layer)
24} 24}
25 25
26 26
27#ifndef NO_ACTION_KEYMAP 27#ifndef NO_ACTION_LAYER
28/* 28/*
29 * Keymap Layer (0-15) 29 * Keymap Layer (0-15)
30 */ 30 */
@@ -100,98 +100,12 @@ void keymap_debug(void)
100 100
101 101
102 102
103#ifndef NO_ACTION_OVERLAY
104/*
105 * Overlay Layer (16-31 = 0-15|0x10)
106 */
107uint16_t overlay_stat = 0;
108
109/* return highest layer whose state is on */
110uint8_t overlay_get_layer(void)
111{
112 return biton16(overlay_stat);
113}
114
115static void overlay_stat_set(uint16_t stat)
116{
117 debug("overlay: ");
118 overlay_debug(); debug(" to ");
119
120 overlay_stat = stat;
121
122 overlay_debug(); debug("\n");
123
124 clear_keyboard_but_mods(); // To avoid stuck keys
125}
126
127void overlay_clear(void)
128{
129 overlay_stat_set(0);
130}
131
132
133void overlay_set(uint16_t stat)
134{
135 overlay_stat_set(stat);
136}
137
138void overlay_move(uint8_t layer)
139{
140 overlay_stat_set(1<<layer);
141}
142
143void overlay_on(uint8_t layer)
144{
145 overlay_stat_set(overlay_stat | (1<<layer));
146}
147
148void overlay_off(uint8_t layer)
149{
150 overlay_stat_set(overlay_stat & ~(1<<layer));
151}
152
153void overlay_invert(uint8_t layer)
154{
155 overlay_stat_set(overlay_stat ^ (1<<layer));
156}
157
158void overlay_or(uint16_t stat)
159{
160 overlay_stat_set(overlay_stat | stat);
161}
162void overlay_and(uint16_t stat)
163{
164 overlay_stat_set(overlay_stat & stat);
165}
166void overlay_xor(uint16_t stat)
167{
168 overlay_stat_set(overlay_stat ^ stat);
169}
170
171void overlay_debug(void)
172{
173 debug_hex16(overlay_stat); debug("("); debug_dec(overlay_get_layer()); debug(")");
174}
175#endif
176
177action_t layer_switch_get_action(key_t key) 103action_t layer_switch_get_action(key_t key)
178{ 104{
179 action_t action; 105 action_t action;
180 action.code = ACTION_TRANSPARENT; 106 action.code = ACTION_TRANSPARENT;
181 107
182#ifndef NO_ACTION_OVERLAY 108#ifndef NO_ACTION_LAYER
183 /* overlay: top layer first */
184 for (int8_t i = 15; i >= 0; i--) {
185 if (overlay_stat & (1<<i)) {
186 action = action_for_key(i | OVERLAY_BIT, key);
187 if (action.code != ACTION_TRANSPARENT) {
188 return action;
189 }
190 }
191 }
192#endif
193
194#ifndef NO_ACTION_KEYMAP
195 /* keymap: top layer first */ 109 /* keymap: top layer first */
196 for (int8_t i = 15; i >= 0; i--) { 110 for (int8_t i = 15; i >= 0; i--) {
197 if (keymap_stat & (1<<i)) { 111 if (keymap_stat & (1<<i)) {