2 Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 /* default layer indicates base layer */
30 uint8_t default_layer = 0;
31 /* current layer indicates active layer at this time */
32 uint8_t current_layer = 0;
35 static void process_action(keyrecord_t *record);
36 static bool process_tapping(keyrecord_t *record);
37 static void waiting_buffer_scan_tap(void);
39 static void debug_event(keyevent_t event);
40 static void debug_record(keyrecord_t record);
41 static void debug_action(action_t action);
42 static void debug_tapping_key(void);
43 static void debug_waiting_buffer(void);
49 /* period of tapping(ms) */
51 #define TAPPING_TERM 200
54 /* tap count needed for toggling a feature */
55 #ifndef TAPPING_TOGGLE
56 #define TAPPING_TOGGLE 5
59 /* stores a key event of current tap. */
60 static keyrecord_t tapping_key = {};
62 #define IS_TAPPING() !IS_NOEVENT(tapping_key.event)
63 #define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
64 #define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
65 #define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
66 #define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
72 * stores key events waiting for settling current tap.
74 #define WAITING_BUFFER_SIZE 8
75 static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
77 /* point to empty cell to enq */
78 static uint8_t waiting_buffer_head = 0;
80 /* point to the oldest data cell to deq */
81 static uint8_t waiting_buffer_tail = 0;
83 static bool waiting_buffer_enq(keyrecord_t record)
85 if (IS_NOEVENT(record.event)) {
89 if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) {
90 debug("waiting_buffer_enq: Over flow.\n");
94 waiting_buffer[waiting_buffer_head] = record;
95 waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE;
97 debug("waiting_buffer_enq: "); debug_waiting_buffer();
101 static void waiting_buffer_clear(void)
103 waiting_buffer_head = 0;
104 waiting_buffer_tail = 0;
107 #if TAPPING_TERM >= 500
108 static bool waiting_buffer_typed(keyevent_t event)
110 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
111 if (KEYEQ(event.key, waiting_buffer[i].event.key) && event.pressed != waiting_buffer[i].event.pressed) {
119 bool waiting_buffer_has_anykey_pressed(void)
121 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
122 if (waiting_buffer[i].event.pressed) return true;
130 * Problem: Want to capitalize like 'The' but the result tends to be 'THe'.
131 * Solution: Oneshot modifier have its effect on only one key coming next.
132 * Tap Shift, then type 't', 'h' and 'e'. Not need to hold Shift key.
134 * Hold: works as normal modifier.
135 * Tap: one shot modifier.
136 * 2 Tap: cancel one shot modifier.
137 * 5-Tap: toggles enable/disable oneshot feature.
146 static void oneshot_start(uint8_t mods, uint16_t time)
148 oneshot_state.mods = mods;
149 oneshot_state.time = time;
150 oneshot_state.ready = true;
153 static void oneshot_cancel(void)
155 oneshot_state.mods = 0;
156 oneshot_state.time = 0;
157 oneshot_state.ready = false;
160 static void oneshot_toggle(void)
162 oneshot_state.disabled = !oneshot_state.disabled;
169 #define LAYER_STACK_SIZE 8
176 static uint8_t top_layer = 0;
177 // [0] is sentinel and not used. [0] is null item.
178 static layer_item_t layer_stack[LAYER_STACK_SIZE] = {};
180 static bool layer_push(uint8_t layer)
182 for (uint8_t i = 1; i < LAYER_STACK_SIZE; i++) {
183 if (!layer_stack[i].used) {
184 layer_stack[i] = (layer_item_t){ .layer = layer,
193 static bool layer_pop(void)
195 if (layer_stack[top_layer].used) {
196 uint8_t popped = top_layer;
197 top_layer = layer_stack[popped].next;
198 layer_stack[popped] = (layer_item_t){};
203 static bool layer_remove(uint8_t layer)
205 if (layer_stack[top_layer].used && layer_stack[top_layer].layer == layer) {
207 debug("layer_remove: top_layer\n");
211 for (uint8_t i = top_layer; layer_stack[i].used; i = layer_stack[i].next) {
212 debug("layer_remove: ["); debug_dec(i); debug("]");
213 debug_dec(layer_stack[i].layer); debug("\n");
214 uint8_t removed = layer_stack[i].next;
215 if (layer_stack[removed].used && layer_stack[removed].layer == layer) {
216 layer_stack[i].next = layer_stack[removed].next;
217 layer_stack[removed] = (layer_item_t){};
218 debug("layer_remove: removed.\n");
224 static bool layer_remove_then_push(uint8_t layer)
227 return layer_push(layer);
229 static bool layer_remove_or_push(uint8_t layer)
231 return (layer_remove(layer)) || layer_push(layer);
233 static void debug_layer_stack(void)
235 debug("layer_stack: ");
236 layer_item_t item = layer_stack[top_layer];
238 debug_dec(item.layer);
239 debug("["); debug_dec(item.next); debug("]");
240 item = layer_stack[item.next];
246 void action_exec(keyevent_t event)
248 if (!IS_NOEVENT(event)) {
249 debug("\n---- action_exec: start -----\n");
250 debug("EVENT: "); debug_event(event); debug("\n");
253 keyrecord_t record = { .event = event };
255 // pre-process on tapping
256 if (process_tapping(&record)) {
257 if (!IS_NOEVENT(record.event)) {
258 debug("processed: "); debug_record(record); debug("\n");
262 if (!waiting_buffer_enq(record)) {
263 // clear all in case of overflow.
264 debug("OVERFLOW: CLEAR ALL STATES\n");
266 waiting_buffer_clear();
267 tapping_key = (keyrecord_t){};
271 // process waiting_buffer
272 if (!IS_NOEVENT(event) && waiting_buffer_head != waiting_buffer_tail) {
273 debug("---- action_exec: process waiting_buffer -----\n");
276 for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
277 if (process_tapping(&waiting_buffer[waiting_buffer_tail])) {
278 debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = ");
279 debug_record(waiting_buffer[waiting_buffer_tail]); debug("\n\n");
284 if (!IS_NOEVENT(event)) {
289 static action_t get_action(key_t key)
294 for (layer_item_t i = layer_stack[top_layer]; i.used; i = layer_stack[i.next]) {
295 action = action_for_key(i.layer, key);
296 if (action.code != ACTION_TRANSPARENT) {
298 debug("layer_stack: used. "); debug_dec(i.layer); debug("\n");
301 debug("layer_stack: through. "); debug_dec(i.layer); debug("\n");
305 action = action_for_key(current_layer, key);
308 if (action.code == ACTION_TRANSPARENT) {
309 debug("TRNASPARENT: "); debug_hex16(action.code); debug("\n");
310 action = action_for_key(default_layer, key);
315 static void process_action(keyrecord_t *record)
317 keyevent_t event = record->event;
318 uint8_t tap_count = record->tap_count;
320 if (IS_NOEVENT(event)) { return; }
322 action_t action = get_action(event.key);
323 debug("ACTION: "); debug_action(action); debug("\n");
325 switch (action.kind.id) {
330 uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods :
333 uint8_t tmp_mods = host_get_mods();
336 host_send_keyboard_report();
338 register_code(action.key.code);
339 if (mods && action.key.code) {
340 host_set_mods(tmp_mods);
341 host_send_keyboard_report();
344 if (mods && !action.key.code) {
346 host_send_keyboard_report();
348 unregister_code(action.key.code);
355 uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
357 switch (action.layer.code) {
361 if (tap_count == 0) {
362 debug("MODS_TAP: Oneshot: add_mods\n");
365 else if (tap_count == 1) {
366 debug("MODS_TAP: Oneshot: start\n");
367 oneshot_start(mods, event.time);
369 else if (tap_count == TAPPING_TOGGLE) {
370 debug("MODS_TAP: Oneshot: toggle\n");
374 debug("MODS_TAP: Oneshot: cancel&add_mods\n");
375 // double tap cancels oneshot and works as normal modifier.
380 if (tap_count == 0) {
381 debug("MODS_TAP: Oneshot: cancel/del_mods\n");
382 // cancel oneshot on hold
386 else if (tap_count == 1) {
387 debug("MODS_TAP: Oneshot: del_mods\n");
392 debug("MODS_TAP: Oneshot: del_mods\n");
401 if (waiting_buffer_has_anykey_pressed()) {
402 debug("MODS_TAP: Tap: Cancel: add_mods\n");
403 // ad hoc: set 0 to cancel tap
404 record->tap_count = 0;
407 debug("MODS_TAP: Tap: register_code\n");
408 register_code(action.key.code);
411 debug("MODS_TAP: No tap: add_mods\n");
416 debug("MODS_TAP: Tap: unregister_code\n");
417 unregister_code(action.key.code);
419 debug("MODS_TAP: No tap: add_mods\n");
428 /* other HID usage */
430 #ifdef EXTRAKEY_ENABLE
431 switch (action.usage.page) {
434 host_system_send(action.usage.code);
441 host_consumer_send(action.usage.code);
443 host_consumer_send(0);
452 #ifdef MOUSEKEY_ENABLE
454 mousekey_on(action.key.code);
457 mousekey_off(action.key.code);
465 switch (action.layer.code) {
466 case LAYER_MOMENTARY: /* momentary */
468 layer_switch(action.layer.val);
471 // NOTE: This is needed by legacy keymap support
472 layer_switch(default_layer);
477 layer_switch(action.layer.val);
480 case LAYER_ON_RELEASE:
481 if (!event.pressed) {
482 layer_switch(action.layer.val);
486 layer_switch(action.layer.val);
488 case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */
490 if (tap_count < TAPPING_TOGGLE) {
491 layer_switch(action.layer.val);
494 if (tap_count >= TAPPING_TOGGLE) {
495 debug("LAYER_PRESSED: tap toggle.\n");
496 layer_switch(action.layer.val);
500 case LAYER_SET_DEFAULT_ON_PRESS:
502 default_layer = action.layer.val;
503 layer_switch(default_layer);
506 case LAYER_SET_DEFAULT_ON_RELEASE:
507 if (!event.pressed) {
508 default_layer = action.layer.val;
509 layer_switch(default_layer);
512 case LAYER_SET_DEFAULT_ON_BOTH:
513 default_layer = action.layer.val;
514 layer_switch(default_layer);
519 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
520 debug("LAYER_SET: Tap: register_code\n");
521 register_code(action.layer.code);
523 debug("LAYER_SET: No tap: layer_set(on press)\n");
524 layer_switch(action.layer.val);
527 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
528 debug("LAYER_SET: Tap: unregister_code\n");
529 unregister_code(action.layer.code);
531 // NOTE: This is needed by legacy keymap support
532 debug("LAYER_SET: No tap: return to default layer(on release)\n");
533 layer_switch(default_layer);
540 switch (action.layer.code) {
541 case LAYER_MOMENTARY: /* momentary */
543 layer_switch(current_layer | action.layer.val);
545 layer_switch(current_layer & ~action.layer.val);
550 layer_switch(current_layer ^ action.layer.val);
553 case LAYER_ON_RELEASE:
554 if (!event.pressed) {
555 layer_switch(current_layer ^ action.layer.val);
559 layer_switch(current_layer ^ action.layer.val);
561 case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */
563 if (tap_count < TAPPING_TOGGLE) {
564 debug("LAYER_BIT: tap toggle(press).\n");
565 layer_switch(current_layer ^ action.layer.val);
568 if (tap_count <= TAPPING_TOGGLE) {
569 debug("LAYER_BIT: tap toggle(release).\n");
570 layer_switch(current_layer ^ action.layer.val);
574 case LAYER_SET_DEFAULT_ON_PRESS:
576 default_layer = current_layer ^ action.layer.val;
577 layer_switch(default_layer);
580 case LAYER_SET_DEFAULT_ON_RELEASE:
581 if (!event.pressed) {
582 default_layer = current_layer ^ action.layer.val;
583 layer_switch(default_layer);
586 case LAYER_SET_DEFAULT_ON_BOTH:
587 default_layer = current_layer ^ action.layer.val;
588 layer_switch(default_layer);
593 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
594 debug("LAYER_BIT: Tap: register_code\n");
595 register_code(action.layer.code);
597 debug("LAYER_BIT: No tap: layer_bit(on press)\n");
598 layer_switch(current_layer ^ action.layer.val);
601 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
602 debug("LAYER_BIT: Tap: unregister_code\n");
603 unregister_code(action.layer.code);
605 debug("LAYER_BIT: No tap: layer_bit(on release)\n");
606 layer_switch(current_layer ^ action.layer.val);
612 case ACT_LAYER_STACK:
613 switch (action.layer.code) {
614 case LAYER_MOMENTARY: /* momentary */
616 layer_remove_then_push(action.layer.val);
619 layer_remove(action.layer.val);
625 layer_remove_or_push(action.layer.val);
629 case LAYER_ON_RELEASE:
630 if (!event.pressed) {
631 layer_remove_or_push(action.layer.val);
636 layer_remove_or_push(action.layer.val);
639 case LAYER_TAP_TOGGLE: /* switch on hold and toggle on several taps */
641 if (tap_count < TAPPING_TOGGLE) {
642 debug("LAYER_STACK: tap toggle(press).\n");
643 layer_remove_or_push(action.layer.val);
647 if (tap_count <= TAPPING_TOGGLE) {
648 debug("LAYER_STACK: tap toggle(release).\n");
649 layer_remove_or_push(action.layer.val);
657 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
658 debug("LAYER_STACK: Tap: register_code\n");
659 register_code(action.layer.code);
661 debug("LAYER_STACK: No tap: layer_stack(on press)\n");
662 layer_remove_or_push(action.layer.val);
666 if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
667 debug("LAYER_STACK: Tap: unregister_code\n");
668 unregister_code(action.layer.code);
670 debug("LAYER_STACK: No tap: layer_stack(on release)\n");
671 layer_remove_or_push(action.layer.val);
686 action_function(record, action.func.id, action.func.opt);
695 * Rule: Tap key is typed(pressed and released) within TAPPING_TERM.
696 * (without interfering by typing other key)
698 /* return true when key event is processed or consumed. */
699 static bool process_tapping(keyrecord_t *keyp)
701 keyevent_t event = keyp->event;
704 if (IS_TAPPING_PRESSED()) {
705 if (WITHIN_TAPPING_TERM(event)) {
706 if (tapping_key.tap_count == 0) {
707 if (IS_TAPPING_KEY(event.key) && !event.pressed) {
709 debug("Tapping: First tap(0->1).\n");
710 tapping_key.tap_count = 1;
712 process_action(&tapping_key);
715 keyp->tap_count = tapping_key.tap_count;
718 #if TAPPING_TERM >= 500
719 /* This can prevent from typing some tap keys in a row at a time. */
720 else if (!event.pressed && waiting_buffer_typed(event)) {
721 // other key typed. not tap.
722 debug("Tapping: End. No tap. Interfered by typing key\n");
723 process_action(&tapping_key);
724 tapping_key = (keyrecord_t){};
732 // other key events shall be enq'd till tapping state settles.
738 if (IS_TAPPING_KEY(event.key) && !event.pressed) {
739 debug("Tapping: Tap release("); debug_dec(tapping_key.tap_count); debug(")\n");
740 keyp->tap_count = tapping_key.tap_count;
741 process_action(keyp);
746 else if (is_tap_key(keyp->event.key) && event.pressed) {
747 if (tapping_key.tap_count > 1) {
748 debug("Tapping: Start new tap with releasing last tap(>1).\n");
750 process_action(&(keyrecord_t){
751 .tap_count = tapping_key.tap_count,
752 .event.key = tapping_key.event.key,
753 .event.time = event.time,
754 .event.pressed = false
757 debug("Tapping: Start while last tap(1).\n");
760 waiting_buffer_scan_tap();
765 if (!IS_NOEVENT(keyp->event)) {
766 debug("Tapping: key event while last tap(>0).\n");
768 process_action(keyp);
773 // after TAPPING_TERM
775 if (tapping_key.tap_count == 0) {
776 debug("Tapping: End. Timeout. Not tap(0): ");
777 debug_event(event); debug("\n");
778 process_action(&tapping_key);
779 tapping_key = (keyrecord_t){};
783 if (IS_TAPPING_KEY(event.key) && !event.pressed) {
784 debug("Tapping: End. last timeout tap release(>0).");
785 keyp->tap_count = tapping_key.tap_count;
786 process_action(keyp);
787 tapping_key = (keyrecord_t){};
790 else if (is_tap_key(keyp->event.key) && event.pressed) {
791 if (tapping_key.tap_count > 1) {
792 debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
794 process_action(&(keyrecord_t){
795 .tap_count = tapping_key.tap_count,
796 .event.key = tapping_key.event.key,
797 .event.time = event.time,
798 .event.pressed = false
801 debug("Tapping: Start while last timeout tap(1).\n");
804 waiting_buffer_scan_tap();
809 if (!IS_NOEVENT(keyp->event)) {
810 debug("Tapping: key event while last timeout tap(>0).\n");
812 process_action(keyp);
817 } else if (IS_TAPPING_RELEASED()) {
818 if (WITHIN_TAPPING_TERM(event)) {
819 if (tapping_key.tap_count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) {
821 keyp->tap_count = tapping_key.tap_count + 1;
822 debug("Tapping: Tap press("); debug_dec(keyp->tap_count); debug(")\n");
823 process_action(keyp);
827 } else if (event.pressed && is_tap_key(event.key)) {
828 // Sequential tap can be interfered with other tap key.
829 debug("Tapping: Start with interfering other tap.\n");
831 waiting_buffer_scan_tap();
835 if (!IS_NOEVENT(keyp->event)) debug("Tapping: other key just after tap.\n");
836 process_action(keyp);
840 // timeout. no sequential tap.
841 debug("Tapping: End(Timeout after releasing last tap): ");
842 debug_event(event); debug("\n");
843 tapping_key = (keyrecord_t){};
848 // not tapping satate
850 if (event.pressed && is_tap_key(event.key)) {
851 debug("Tapping: Start(Press tap key).\n");
853 waiting_buffer_scan_tap();
857 process_action(keyp);
863 /* scan buffer for tapping */
864 static void waiting_buffer_scan_tap(void)
866 // tapping already is settled
867 if (tapping_key.tap_count > 0) return;
868 // invalid state: tapping_key released && tap_count == 0
869 if (!tapping_key.event.pressed) return;
871 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
872 if (IS_TAPPING_KEY(waiting_buffer[i].event.key) &&
873 !waiting_buffer[i].event.pressed &&
874 WITHIN_TAPPING_TERM(waiting_buffer[i].event)) {
875 tapping_key.tap_count = 1;
876 waiting_buffer[i].tap_count = 1;
877 process_action(&tapping_key);
879 debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n");
880 debug_waiting_buffer();
889 * Utilities for actions.
891 void register_code(uint8_t code)
896 else if IS_KEY(code) {
897 // TODO: should push command_proc out of this block?
898 if (command_proc(code)) return;
900 if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) {
901 uint8_t tmp_mods = host_get_mods();
902 host_add_mods(oneshot_state.mods);
904 host_send_keyboard_report();
906 host_set_mods(tmp_mods);
907 oneshot_state.ready = false;
910 host_send_keyboard_report();
913 else if IS_MOD(code) {
914 host_add_mods(MOD_BIT(code));
915 host_send_keyboard_report();
919 void unregister_code(uint8_t code)
923 host_send_keyboard_report();
925 else if IS_MOD(code) {
926 host_del_mods(MOD_BIT(code));
927 host_send_keyboard_report();
931 void add_mods(uint8_t mods)
935 host_send_keyboard_report();
939 void del_mods(uint8_t mods)
943 host_send_keyboard_report();
947 void set_mods(uint8_t mods)
950 host_send_keyboard_report();
953 void clear_keyboard(void)
956 clear_keyboard_but_mods();
959 void clear_keyboard_but_mods(void)
962 host_send_keyboard_report();
963 #ifdef MOUSEKEY_ENABLE
967 #ifdef EXTRAKEY_ENABLE
969 host_consumer_send(0);
973 bool sending_anykey(void)
975 return (host_has_anykey() || host_mouse_in_use() ||
976 host_last_sysytem_report() || host_last_consumer_report());
979 void layer_switch(uint8_t new_layer)
981 if (current_layer != new_layer) {
982 debug("Layer Switch: "); debug_hex(current_layer);
983 debug(" -> "); debug_hex(new_layer); debug("\n");
985 current_layer = new_layer;
986 clear_keyboard_but_mods(); // To avoid stuck keys
987 // NOTE: update mods with full scan of matrix? if modifier changes between layers
991 bool is_tap_key(key_t key)
993 action_t action = get_action(key);
995 switch (action.kind.id) {
1001 switch (action.layer.code) {
1002 case LAYER_MOMENTARY:
1003 case LAYER_ON_PRESS:
1004 case LAYER_ON_RELEASE:
1006 case LAYER_SET_DEFAULT_ON_PRESS:
1007 case LAYER_SET_DEFAULT_ON_RELEASE:
1008 case LAYER_SET_DEFAULT_ON_BOTH:
1010 case LAYER_TAP_TOGGLE:
1011 default: /* tap key */
1016 if (action.func.opt & FUNC_TAP) { return true; }
1026 static void debug_event(keyevent_t event)
1028 debug_hex16((event.key.row<<8) | event.key.col);
1029 if (event.pressed) debug("d("); else debug("u(");
1030 debug_dec(event.time); debug(")");
1032 static void debug_record(keyrecord_t record)
1034 debug_event(record.event); debug(":"); debug_dec(record.tap_count);
1036 static void debug_action(action_t action)
1038 switch (action.kind.id) {
1039 case ACT_LMODS: debug("ACT_LMODS"); break;
1040 case ACT_RMODS: debug("ACT_RMODS"); break;
1041 case ACT_LMODS_TAP: debug("ACT_LMODS_TAP"); break;
1042 case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break;
1043 case ACT_USAGE: debug("ACT_USAGE"); break;
1044 case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break;
1045 case ACT_LAYER: debug("ACT_LAYER"); break;
1046 case ACT_LAYER_BIT: debug("ACT_LAYER_BIT"); break;
1047 case ACT_LAYER_STACK: debug("ACT_LAYER_STACK"); break;
1048 case ACT_MACRO: debug("ACT_MACRO"); break;
1049 case ACT_COMMAND: debug("ACT_COMMAND"); break;
1050 case ACT_FUNCTION: debug("ACT_FUNCTION"); break;
1051 default: debug("UNKNOWN"); break;
1054 debug_hex4(action.kind.param>>8);
1056 debug_hex8(action.kind.param & 0xff);
1059 static void debug_tapping_key(void)
1061 debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n");
1063 static void debug_waiting_buffer(void)
1066 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
1067 debug("["); debug_dec(i); debug("]="); debug_record(waiting_buffer[i]); debug(" ");