+void action_exec(keyevent_t event)
+{
+ if (!IS_NOEVENT(event)) {
+ debug("\n---- action_exec: start -----\n");
+ debug("EVENT: "); debug_event(event); debug("\n");
+ }
+
+ keyrecord_t record = { .event = event };
+
+ // pre-process on tapping
+ if (process_tapping(&record)) {
+ if (!IS_NOEVENT(record.event)) {
+ debug("processed: "); debug_record(record); debug("\n");
+ }
+ } else {
+ // enqueue
+ if (!waiting_buffer_enq(record)) {
+ // clear all in case of overflow.
+ debug("OVERFLOW: CLEAR ALL STATES\n");
+ clear_keyboard();
+ waiting_buffer_clear();
+ tapping_key = (keyrecord_t){};
+ }
+ }
+
+ // process waiting_buffer
+ if (!IS_NOEVENT(event) && waiting_buffer_head != waiting_buffer_tail) {
+ debug("---- action_exec: process waiting_buffer -----\n");
+ }
+
+ for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
+ if (process_tapping(&waiting_buffer[waiting_buffer_tail])) {
+ debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = ");
+ debug_record(waiting_buffer[waiting_buffer_tail]); debug("\n\n");
+ } else {
+ break;
+ }
+ }
+ if (!IS_NOEVENT(event)) {
+ debug("\n");
+ }
+}
+
+static action_t get_action(key_t key)
+{
+ action_t action;
+ action.code = ACTION_NO;
+
+ /* layer_switch */
+ action = layer_switch_get_action(key);
+ if (action.code != ACTION_TRANSPARENT) {
+ return action;
+ }
+
+ /* default layer */
+ //debug("get_aciton: default layer: "); debug_dec(default_layer); debug("\n");
+ action = action_for_key(default_layer, key);
+ return action;
+}
+
+static void process_action(keyrecord_t *record)
+{
+ keyevent_t event = record->event;
+ uint8_t tap_count = record->tap_count;
+
+ if (IS_NOEVENT(event)) { return; }
+
+ action_t action = get_action(event.key);
+ debug("ACTION: "); debug_action(action); debug(" ");
+ layer_switch_debug(); debug("["); debug_dec(default_layer); debug("]\n");
+