+ if (timer_elapsed(last_timer) > LAYER_ENTER_DELAY) {
+ uint8_t _layer_to_switch = new_layer(BIT_SUBT(fn_bits, sent_fn));
+ if (current_layer != _layer_to_switch) { // not switch layer yet
+ debug("Fn case: 1,2,3(LAYER_ENTER_DELAY passed)\n");
+ debug("Switch Layer: "); debug_hex(current_layer);
+ current_layer = _layer_to_switch;
+ layer_used = false;
+ debug(" -> "); debug_hex(current_layer); debug("\n");
+ }
+ } else {
+ if (host_has_anykey()) { // other keys is pressed
+ uint8_t _fn_to_send = BIT_SUBT(fn_bits, sent_fn);
+ if (_fn_to_send) {
+ debug("Fn case: 4(send Fn before other key pressed)\n");
+ // send only Fn key first
+ host_swap_keyboard_report();
+ host_clear_keyboard_report();
+ host_set_mods(last_mods);
+ host_add_code(keymap_fn_keycode(_fn_to_send)); // TODO: do all Fn keys
+ host_send_keyboard_report();
+ host_swap_keyboard_report();
+ sent_fn |= _fn_to_send;
+ }
+ }