quantum.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /* Copyright 2016-2017 Jack Humbert
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "quantum.h"
  17. #include "process_quantum.h"
  18. #ifdef SLEEP_LED_ENABLE
  19. # include "sleep_led.h"
  20. #endif
  21. #ifdef BACKLIGHT_ENABLE
  22. # include "process_backlight.h"
  23. #endif
  24. #ifdef CONNECTION_ENABLE
  25. # include "process_connection.h"
  26. #endif
  27. #ifdef GRAVE_ESC_ENABLE
  28. # include "process_grave_esc.h"
  29. #endif
  30. #ifdef HAPTIC_ENABLE
  31. # include "process_haptic.h"
  32. #endif
  33. #ifdef JOYSTICK_ENABLE
  34. # include "process_joystick.h"
  35. #endif
  36. #ifdef LEADER_ENABLE
  37. # include "process_leader.h"
  38. #endif
  39. #ifdef LED_MATRIX_ENABLE
  40. # include "process_led_matrix.h"
  41. #endif
  42. #ifdef MAGIC_ENABLE
  43. # include "process_magic.h"
  44. #endif
  45. #ifdef MIDI_ENABLE
  46. # include "process_midi.h"
  47. #endif
  48. #if !defined(NO_ACTION_LAYER)
  49. # include "process_default_layer.h"
  50. #endif
  51. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  52. # include "process_programmable_button.h"
  53. #endif
  54. #if defined(RGB_MATRIX_ENABLE)
  55. # include "process_rgb_matrix.h"
  56. #endif
  57. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  58. # include "process_underglow.h"
  59. #endif
  60. #ifdef SECURE_ENABLE
  61. # include "process_secure.h"
  62. #endif
  63. #ifdef TRI_LAYER_ENABLE
  64. # include "process_tri_layer.h"
  65. #endif
  66. #ifdef UNICODE_COMMON_ENABLE
  67. # include "process_unicode_common.h"
  68. #endif
  69. #ifdef LAYER_LOCK_ENABLE
  70. # include "process_layer_lock.h"
  71. #endif
  72. #ifndef NO_ACTION_ONESHOT
  73. # include "process_oneshot.h"
  74. #endif
  75. #ifdef AUDIO_ENABLE
  76. # ifdef DEFAULT_LAYER_SONGS
  77. float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
  78. # endif
  79. #endif
  80. uint8_t extract_mod_bits(uint16_t code) {
  81. switch (code) {
  82. case QK_MODS ... QK_MODS_MAX:
  83. break;
  84. default:
  85. return 0;
  86. }
  87. uint8_t mods_to_send = 0;
  88. if (code & QK_RMODS_MIN) { // Right mod flag is set
  89. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL);
  90. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT);
  91. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT);
  92. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RIGHT_GUI);
  93. } else {
  94. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LEFT_CTRL);
  95. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LEFT_SHIFT);
  96. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LEFT_ALT);
  97. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LEFT_GUI);
  98. }
  99. return mods_to_send;
  100. }
  101. void do_code16(uint16_t code, void (*f)(uint8_t)) {
  102. f(extract_mod_bits(code));
  103. }
  104. __attribute__((weak)) void register_code16(uint16_t code) {
  105. if (IS_MODIFIER_KEYCODE(code) || code == KC_NO) {
  106. do_code16(code, register_mods);
  107. } else {
  108. do_code16(code, register_weak_mods);
  109. }
  110. register_code(code);
  111. }
  112. __attribute__((weak)) void unregister_code16(uint16_t code) {
  113. unregister_code(code);
  114. if (IS_MODIFIER_KEYCODE(code) || code == KC_NO) {
  115. do_code16(code, unregister_mods);
  116. } else {
  117. do_code16(code, unregister_weak_mods);
  118. }
  119. }
  120. /** \brief Tap a keycode with a delay.
  121. *
  122. * \param code The modded keycode to tap.
  123. * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
  124. */
  125. __attribute__((weak)) void tap_code16_delay(uint16_t code, uint16_t delay) {
  126. register_code16(code);
  127. wait_ms(delay);
  128. unregister_code16(code);
  129. }
  130. /** \brief Tap a keycode with the default delay.
  131. *
  132. * \param code The modded keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
  133. */
  134. __attribute__((weak)) void tap_code16(uint16_t code) {
  135. tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
  136. }
  137. __attribute__((weak)) bool pre_process_record_modules(uint16_t keycode, keyrecord_t *record) {
  138. return true;
  139. }
  140. __attribute__((weak)) bool pre_process_record_kb(uint16_t keycode, keyrecord_t *record) {
  141. return pre_process_record_user(keycode, record);
  142. }
  143. __attribute__((weak)) bool pre_process_record_user(uint16_t keycode, keyrecord_t *record) {
  144. return true;
  145. }
  146. __attribute__((weak)) bool process_record_modules(uint16_t keycode, keyrecord_t *record) {
  147. return true;
  148. }
  149. __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  150. return process_record_user(keycode, record);
  151. }
  152. __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  153. return true;
  154. }
  155. __attribute__((weak)) void post_process_record_modules(uint16_t keycode, keyrecord_t *record) {}
  156. __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) {
  157. post_process_record_user(keycode, record);
  158. }
  159. __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
  160. __attribute__((weak)) bool shutdown_modules(bool jump_to_bootloader) {
  161. return true;
  162. }
  163. __attribute__((weak)) void suspend_power_down_modules(void) {}
  164. __attribute__((weak)) void suspend_wakeup_init_modules(void) {}
  165. void shutdown_quantum(bool jump_to_bootloader) {
  166. clear_keyboard();
  167. #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
  168. process_midi_all_notes_off();
  169. #endif
  170. #ifdef AUDIO_ENABLE
  171. # ifndef NO_MUSIC_MODE
  172. music_all_notes_off();
  173. # endif
  174. audio_shutdown();
  175. #endif
  176. shutdown_modules(jump_to_bootloader);
  177. shutdown_kb(jump_to_bootloader);
  178. #if SHUTDOWN_DELAY > 0
  179. wait_ms(SHUTDOWN_DELAY);
  180. #endif
  181. #ifdef HAPTIC_ENABLE
  182. haptic_shutdown();
  183. #endif
  184. }
  185. void reset_keyboard(void) {
  186. shutdown_quantum(true);
  187. bootloader_jump();
  188. }
  189. void soft_reset_keyboard(void) {
  190. shutdown_quantum(false);
  191. mcu_reset();
  192. }
  193. /* Convert record into usable keycode via the contained event. */
  194. uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
  195. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  196. if (record->keycode) {
  197. return record->keycode;
  198. }
  199. #endif
  200. return get_event_keycode(record->event, update_layer_cache);
  201. }
  202. /* Convert event into usable keycode. Checks the layer cache to ensure that it
  203. * retains the correct keycode after a layer change, if the key is still pressed.
  204. * "update_layer_cache" is to ensure that it only updates the layer cache when
  205. * appropriate, otherwise, it will update it and cause layer tap (and other keys)
  206. * from triggering properly.
  207. */
  208. uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
  209. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  210. /* TODO: Use store_or_get_action() or a similar function. */
  211. if (!disable_action_cache) {
  212. uint8_t layer;
  213. if (event.pressed && update_layer_cache) {
  214. layer = layer_switch_get_layer(event.key);
  215. update_source_layers_cache(event.key, layer);
  216. } else {
  217. layer = read_source_layers_cache(event.key);
  218. }
  219. return keymap_key_to_keycode(layer, event.key);
  220. } else
  221. #endif
  222. return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
  223. }
  224. /* Get keycode, and then process pre tapping functionality */
  225. bool pre_process_record_quantum(keyrecord_t *record) {
  226. return pre_process_record_modules(get_record_keycode(record, true), record) && pre_process_record_kb(get_record_keycode(record, true), record) &&
  227. #ifdef COMBO_ENABLE
  228. process_combo(get_record_keycode(record, true), record) &&
  229. #endif
  230. true;
  231. }
  232. /* Get keycode, and then call keyboard function */
  233. void post_process_record_quantum(keyrecord_t *record) {
  234. uint16_t keycode = get_record_keycode(record, false);
  235. post_process_record_modules(keycode, record);
  236. post_process_record_kb(keycode, record);
  237. }
  238. /** \brief Core keycode function
  239. *
  240. * Hands off handling to other quantum/process_keycode/ functions
  241. */
  242. bool process_record_quantum(keyrecord_t *record) {
  243. uint16_t keycode = get_record_keycode(record, true);
  244. // This is how you use actions here
  245. // if (keycode == QK_LEADER) {
  246. // action_t action;
  247. // action.code = ACTION_DEFAULT_LAYER_SET(0);
  248. // process_action(record, action);
  249. // return false;
  250. // }
  251. #if defined(SECURE_ENABLE)
  252. if (!preprocess_secure(keycode, record)) {
  253. return false;
  254. }
  255. #endif
  256. #ifdef TAP_DANCE_ENABLE
  257. if (preprocess_tap_dance(keycode, record)) {
  258. // The tap dance might have updated the layer state, therefore the
  259. // result of the keycode lookup might change.
  260. keycode = get_record_keycode(record, true);
  261. }
  262. #endif
  263. #ifdef RGBLIGHT_ENABLE
  264. if (record->event.pressed) {
  265. preprocess_rgblight();
  266. }
  267. #endif
  268. #ifdef WPM_ENABLE
  269. if (record->event.pressed) {
  270. update_wpm(keycode);
  271. }
  272. #endif
  273. if (!(
  274. #if defined(KEY_LOCK_ENABLE)
  275. // Must run first to be able to mask key_up events.
  276. process_key_lock(&keycode, record) &&
  277. #endif
  278. #if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
  279. // Must run asap to ensure all keypresses are recorded.
  280. process_dynamic_macro(keycode, record) &&
  281. #endif
  282. #ifdef REPEAT_KEY_ENABLE
  283. process_last_key(keycode, record) && process_repeat_key(keycode, record) &&
  284. #endif
  285. #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
  286. process_clicky(keycode, record) &&
  287. #endif
  288. #ifdef HAPTIC_ENABLE
  289. process_haptic(keycode, record) &&
  290. #endif
  291. #if defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
  292. process_auto_mouse(keycode, record) &&
  293. #endif
  294. process_record_modules(keycode, record) && // modules must run before kb
  295. process_record_kb(keycode, record) &&
  296. #if defined(VIA_ENABLE)
  297. process_record_via(keycode, record) &&
  298. #endif
  299. #if defined(SECURE_ENABLE)
  300. process_secure(keycode, record) &&
  301. #endif
  302. #if defined(SEQUENCER_ENABLE)
  303. process_sequencer(keycode, record) &&
  304. #endif
  305. #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
  306. process_midi(keycode, record) &&
  307. #endif
  308. #ifdef AUDIO_ENABLE
  309. process_audio(keycode, record) &&
  310. #endif
  311. #if defined(BACKLIGHT_ENABLE)
  312. process_backlight(keycode, record) &&
  313. #endif
  314. #if defined(LED_MATRIX_ENABLE)
  315. process_led_matrix(keycode, record) &&
  316. #endif
  317. #ifdef PLOVER_HID_ENABLE
  318. process_plover_hid(keycode, record) &&
  319. #endif
  320. #ifdef STENO_ENABLE
  321. process_steno(keycode, record) &&
  322. #endif
  323. #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
  324. process_music(keycode, record) &&
  325. #endif
  326. #ifdef CAPS_WORD_ENABLE
  327. process_caps_word(keycode, record) &&
  328. #endif
  329. #ifdef KEY_OVERRIDE_ENABLE
  330. process_key_override(keycode, record) &&
  331. #endif
  332. #ifdef TAP_DANCE_ENABLE
  333. process_tap_dance(keycode, record) &&
  334. #endif
  335. #ifdef LEADER_ENABLE
  336. process_leader(keycode, record) &&
  337. #endif
  338. #if defined(UNICODE_COMMON_ENABLE)
  339. process_unicode_common(keycode, record) &&
  340. #endif
  341. #ifdef AUTO_SHIFT_ENABLE
  342. process_auto_shift(keycode, record) &&
  343. #endif
  344. #ifdef DYNAMIC_TAPPING_TERM_ENABLE
  345. process_dynamic_tapping_term(keycode, record) &&
  346. #endif
  347. #ifdef SPACE_CADET_ENABLE
  348. process_space_cadet(keycode, record) &&
  349. #endif
  350. #ifdef MAGIC_ENABLE
  351. process_magic(keycode, record) &&
  352. #endif
  353. #ifdef GRAVE_ESC_ENABLE
  354. process_grave_esc(keycode, record) &&
  355. #endif
  356. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  357. process_underglow(keycode, record) &&
  358. #endif
  359. #if defined(RGB_MATRIX_ENABLE)
  360. process_rgb_matrix(keycode, record) &&
  361. #endif
  362. #ifdef JOYSTICK_ENABLE
  363. process_joystick(keycode, record) &&
  364. #endif
  365. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  366. process_programmable_button(keycode, record) &&
  367. #endif
  368. #ifdef AUTOCORRECT_ENABLE
  369. process_autocorrect(keycode, record) &&
  370. #endif
  371. #ifdef TRI_LAYER_ENABLE
  372. process_tri_layer(keycode, record) &&
  373. #endif
  374. #if !defined(NO_ACTION_LAYER)
  375. process_default_layer(keycode, record) &&
  376. #endif
  377. #ifdef LAYER_LOCK_ENABLE
  378. process_layer_lock(keycode, record) &&
  379. #endif
  380. #ifdef CONNECTION_ENABLE
  381. process_connection(keycode, record) &&
  382. #endif
  383. #ifndef NO_ACTION_ONESHOT
  384. process_oneshot(keycode, record) &&
  385. #endif
  386. process_quantum(keycode, record))) {
  387. return false;
  388. }
  389. return true;
  390. }
  391. void set_single_default_layer(uint8_t default_layer) {
  392. #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
  393. PLAY_SONG(default_layer_songs[default_layer]);
  394. #endif
  395. default_layer_set((layer_state_t)1 << default_layer);
  396. }
  397. void set_single_persistent_default_layer(uint8_t default_layer) {
  398. eeconfig_update_default_layer((layer_state_t)1 << default_layer);
  399. set_single_default_layer(default_layer);
  400. }
  401. //------------------------------------------------------------------------------
  402. // Override these functions in your keymap file to play different tunes on
  403. // different events such as startup and bootloader jump
  404. __attribute__((weak)) bool shutdown_user(bool jump_to_bootloader) {
  405. return true;
  406. }
  407. __attribute__((weak)) bool shutdown_kb(bool jump_to_bootloader) {
  408. if (!shutdown_user(jump_to_bootloader)) {
  409. return false;
  410. }
  411. return true;
  412. }
  413. void suspend_power_down_quantum(void) {
  414. suspend_power_down_modules();
  415. suspend_power_down_kb();
  416. #ifndef NO_SUSPEND_POWER_DOWN
  417. // Turn off backlight
  418. # ifdef BACKLIGHT_ENABLE
  419. backlight_level_noeeprom(0);
  420. # endif
  421. # ifdef SLEEP_LED_ENABLE
  422. sleep_led_enable();
  423. # endif
  424. # ifdef LED_MATRIX_ENABLE
  425. led_matrix_task();
  426. # endif
  427. # ifdef RGB_MATRIX_ENABLE
  428. rgb_matrix_task();
  429. # endif
  430. // Turn off LED indicators
  431. led_suspend();
  432. // Turn off audio
  433. # ifdef AUDIO_ENABLE
  434. stop_all_notes();
  435. # endif
  436. // Turn off underglow
  437. # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  438. rgblight_suspend();
  439. # endif
  440. # if defined(LED_MATRIX_ENABLE)
  441. led_matrix_set_suspend_state(true);
  442. # endif
  443. # if defined(RGB_MATRIX_ENABLE)
  444. rgb_matrix_set_suspend_state(true);
  445. # endif
  446. # ifdef OLED_ENABLE
  447. oled_off();
  448. # endif
  449. # ifdef ST7565_ENABLE
  450. st7565_off();
  451. # endif
  452. # if defined(POINTING_DEVICE_ENABLE)
  453. // run to ensure scanning occurs while suspended
  454. pointing_device_task();
  455. # endif
  456. #endif
  457. }
  458. __attribute__((weak)) void suspend_wakeup_init_quantum(void) {
  459. // Turn on backlight
  460. #ifdef BACKLIGHT_ENABLE
  461. backlight_init();
  462. #endif
  463. #ifdef SLEEP_LED_ENABLE
  464. sleep_led_disable();
  465. #endif
  466. // Restore LED indicators
  467. led_wakeup();
  468. // Wake up underglow
  469. #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  470. rgblight_wakeup();
  471. #endif
  472. #if defined(LED_MATRIX_ENABLE)
  473. led_matrix_set_suspend_state(false);
  474. #endif
  475. #if defined(RGB_MATRIX_ENABLE)
  476. rgb_matrix_set_suspend_state(false);
  477. #endif
  478. suspend_wakeup_init_modules();
  479. suspend_wakeup_init_kb();
  480. }
  481. /** \brief converts unsigned integers into char arrays
  482. *
  483. * Takes an unsigned integer and converts that value into an equivalent char array
  484. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  485. */
  486. const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad) {
  487. buf[buf_len - 1] = '\0';
  488. for (size_t i = 0; i < buf_len - 1; ++i) {
  489. char c = '0' + curr_num % 10;
  490. buf[buf_len - 2 - i] = (c == '0' && i == 0) ? '0' : (curr_num > 0 ? c : curr_pad);
  491. curr_num /= 10;
  492. }
  493. return buf;
  494. }
  495. /** \brief converts uint8_t into char array
  496. *
  497. * Takes an uint8_t, and uses an internal static buffer to render that value into a char array
  498. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  499. *
  500. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  501. * contents. Use the result immediately, instead of caching it.
  502. */
  503. const char *get_u8_str(uint8_t curr_num, char curr_pad) {
  504. static char buf[4] = {0};
  505. static uint8_t last_num = 0xFF;
  506. static char last_pad = '\0';
  507. if (last_num == curr_num && last_pad == curr_pad) {
  508. return buf;
  509. }
  510. last_num = curr_num;
  511. last_pad = curr_pad;
  512. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  513. }
  514. /** \brief converts uint16_t into char array
  515. *
  516. * Takes an uint16_t, and uses an internal static buffer to render that value into a char array
  517. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  518. *
  519. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  520. * contents. Use the result immediately, instead of caching it.
  521. */
  522. const char *get_u16_str(uint16_t curr_num, char curr_pad) {
  523. static char buf[6] = {0};
  524. static uint16_t last_num = 0xFF;
  525. static char last_pad = '\0';
  526. if (last_num == curr_num && last_pad == curr_pad) {
  527. return buf;
  528. }
  529. last_num = curr_num;
  530. last_pad = curr_pad;
  531. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  532. }
  533. #if defined(SECURE_ENABLE)
  534. void secure_hook_quantum(secure_status_t secure_status) {
  535. // If keys are being held when this is triggered, they may not be released properly
  536. // this can result in stuck keys, mods and layers. To prevent that, manually
  537. // clear these, when it is triggered.
  538. if (secure_status == SECURE_PENDING) {
  539. clear_keyboard();
  540. layer_clear();
  541. }
  542. }
  543. #endif