logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

command.c (19647B)


  1. /*
  2. Copyright 2011 Jun Wako <wakojun@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include "wait.h"
  17. #include "keycode.h"
  18. #include "host.h"
  19. #include "print.h"
  20. #include "debug.h"
  21. #include "util.h"
  22. #include "timer.h"
  23. #include "keyboard.h"
  24. #include "bootloader.h"
  25. #include "action_layer.h"
  26. #include "action_util.h"
  27. #include "eeconfig.h"
  28. #include "sleep_led.h"
  29. #include "led.h"
  30. #include "command.h"
  31. #include "quantum.h"
  32. #include "usb_device_state.h"
  33. #include "version.h"
  34. #ifdef BACKLIGHT_ENABLE
  35. # include "backlight.h"
  36. #endif
  37. #if defined(MOUSEKEY_ENABLE)
  38. # include "mousekey.h"
  39. #endif
  40. #ifdef AUDIO_ENABLE
  41. # include "audio.h"
  42. #endif /* AUDIO_ENABLE */
  43. static bool command_common(uint8_t code);
  44. static void command_common_help(void);
  45. static void print_version(void);
  46. static void print_status(void);
  47. static bool command_console(uint8_t code);
  48. static void command_console_help(void);
  49. #if defined(MOUSEKEY_ENABLE)
  50. static bool mousekey_console(uint8_t code);
  51. #endif
  52. static void switch_default_layer(uint8_t layer);
  53. command_state_t command_state = ONESHOT;
  54. bool command_proc(uint8_t code) {
  55. switch (command_state) {
  56. case ONESHOT:
  57. if (!IS_COMMAND()) return false;
  58. return (command_extra(code) || command_common(code));
  59. break;
  60. case CONSOLE:
  61. if (IS_COMMAND())
  62. return (command_extra(code) || command_common(code));
  63. else
  64. return (command_console_extra(code) || command_console(code));
  65. break;
  66. #if defined(MOUSEKEY_ENABLE)
  67. case MOUSEKEY:
  68. mousekey_console(code);
  69. break;
  70. #endif
  71. default:
  72. command_state = ONESHOT;
  73. return false;
  74. }
  75. return true;
  76. }
  77. /* TODO: Refactoring is needed. */
  78. /* This allows to define extra commands. return false when not processed. */
  79. bool command_extra(uint8_t code) __attribute__((weak));
  80. bool command_extra(uint8_t code) {
  81. (void)code;
  82. return false;
  83. }
  84. bool command_console_extra(uint8_t code) __attribute__((weak));
  85. bool command_console_extra(uint8_t code) {
  86. (void)code;
  87. return false;
  88. }
  89. /***********************************************************
  90. * Command common
  91. ***********************************************************/
  92. static void command_common_help(void) {
  93. print(/* clang-format off */
  94. "\n\t- Magic -\n"
  95. STR(MAGIC_KEY_DEBUG) ": Debug Message Toggle\n"
  96. STR(MAGIC_KEY_DEBUG_MATRIX) ": Matrix Debug Mode Toggle"
  97. " - Show keypresses in matrix grid\n"
  98. STR(MAGIC_KEY_DEBUG_KBD) ": Keyboard Debug Toggle"
  99. " - Show keypress report\n"
  100. STR(MAGIC_KEY_DEBUG_MOUSE) ": Debug Mouse Toggle\n"
  101. STR(MAGIC_KEY_VERSION) ": Version\n"
  102. STR(MAGIC_KEY_STATUS) ": Status\n"
  103. STR(MAGIC_KEY_CONSOLE) ": Activate Console Mode\n"
  104. #if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
  105. STR(MAGIC_KEY_LAYER0) ": Switch to Layer 0\n"
  106. STR(MAGIC_KEY_LAYER1) ": Switch to Layer 1\n"
  107. STR(MAGIC_KEY_LAYER2) ": Switch to Layer 2\n"
  108. STR(MAGIC_KEY_LAYER3) ": Switch to Layer 3\n"
  109. STR(MAGIC_KEY_LAYER4) ": Switch to Layer 4\n"
  110. STR(MAGIC_KEY_LAYER5) ": Switch to Layer 5\n"
  111. STR(MAGIC_KEY_LAYER6) ": Switch to Layer 6\n"
  112. STR(MAGIC_KEY_LAYER7) ": Switch to Layer 7\n"
  113. STR(MAGIC_KEY_LAYER8) ": Switch to Layer 8\n"
  114. STR(MAGIC_KEY_LAYER9) ": Switch to Layer 9\n"
  115. #endif
  116. #if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
  117. "F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
  118. #endif
  119. #if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
  120. "0-9: Switch to Layer 0-9\n"
  121. #endif
  122. STR(MAGIC_KEY_LAYER0_ALT) ": Switch to Layer 0 (alternate)\n"
  123. STR(MAGIC_KEY_BOOTLOADER) ": Jump to Bootloader\n"
  124. STR(MAGIC_KEY_BOOTLOADER_ALT) ": Jump to Bootloader (alternate)\n"
  125. #ifdef KEYBOARD_LOCK_ENABLE
  126. STR(MAGIC_KEY_LOCK) ": Lock Keyboard\n"
  127. #endif
  128. STR(MAGIC_KEY_EEPROM) ": Print EEPROM Settings\n"
  129. STR(MAGIC_KEY_EEPROM_CLEAR) ": Clear EEPROM\n"
  130. #ifdef NKRO_ENABLE
  131. STR(MAGIC_KEY_NKRO) ": NKRO Toggle\n"
  132. #endif
  133. #ifdef SLEEP_LED_ENABLE
  134. STR(MAGIC_KEY_SLEEP_LED) ": Sleep LED Test\n"
  135. #endif
  136. ); /* clang-format on */
  137. }
  138. static void print_version(void) {
  139. xprintf("%s", /* clang-format off */
  140. "\n\t- Version -\n"
  141. "VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
  142. "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
  143. "VER: " STR(DEVICE_VER) "\n"
  144. "BUILD: (" __DATE__ ")\n"
  145. #ifndef SKIP_VERSION
  146. # ifdef PROTOCOL_CHIBIOS
  147. "CHIBIOS: " STR(CHIBIOS_VERSION)
  148. ", CONTRIB: " STR(CHIBIOS_CONTRIB_VERSION) "\n"
  149. # endif
  150. #endif
  151. /* build options */
  152. "OPTIONS:"
  153. #ifdef PROTOCOL_LUFA
  154. " LUFA"
  155. #endif
  156. #ifdef PROTOCOL_VUSB
  157. " VUSB"
  158. #endif
  159. #ifdef BOOTMAGIC_ENABLE
  160. " BOOTMAGIC"
  161. #endif
  162. #ifdef MOUSEKEY_ENABLE
  163. " MOUSEKEY"
  164. #endif
  165. #ifdef EXTRAKEY_ENABLE
  166. " EXTRAKEY"
  167. #endif
  168. #ifdef CONSOLE_ENABLE
  169. " CONSOLE"
  170. #endif
  171. #ifdef COMMAND_ENABLE
  172. " COMMAND"
  173. #endif
  174. #ifdef NKRO_ENABLE
  175. " NKRO"
  176. #endif
  177. #ifdef LTO_ENABLE
  178. " LTO"
  179. #endif
  180. " " STR(BOOTLOADER_SIZE) "\n"
  181. "GCC: " STR(__GNUC__)
  182. "." STR(__GNUC_MINOR__)
  183. "." STR(__GNUC_PATCHLEVEL__)
  184. #if defined(__AVR__)
  185. " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
  186. " AVR_ARCH: avr" STR(__AVR_ARCH__)
  187. #endif
  188. "\n"
  189. ); /* clang-format on */
  190. }
  191. static void print_status(void) {
  192. xprintf(/* clang-format off */
  193. "\n\t- Status -\n"
  194. "host_keyboard_leds(): %02X\n"
  195. "keyboard_protocol: %02X\n"
  196. "keyboard_idle: %02X\n"
  197. #ifdef NKRO_ENABLE
  198. "keymap_config.nkro: %02X\n"
  199. #endif
  200. "timer_read32(): %08lX\n"
  201. , host_keyboard_leds()
  202. , usb_device_state_get_protocol()
  203. , usb_device_state_get_idle_rate()
  204. #ifdef NKRO_ENABLE
  205. , keymap_config.nkro
  206. #endif
  207. , timer_read32()
  208. ); /* clang-format on */
  209. }
  210. #if !defined(NO_PRINT) && !defined(USER_PRINT)
  211. static void print_eeconfig(void) {
  212. xprintf("eeconfig:\ndefault_layer: %" PRIu32 "\n", (uint32_t)eeconfig_read_default_layer());
  213. debug_config_t dc;
  214. eeconfig_read_debug(&dc);
  215. xprintf(/* clang-format off */
  216. "debug_config.raw: %02X\n"
  217. ".enable: %u\n"
  218. ".matrix: %u\n"
  219. ".keyboard: %u\n"
  220. ".mouse: %u\n"
  221. , dc.raw
  222. , dc.enable
  223. , dc.matrix
  224. , dc.keyboard
  225. , dc.mouse
  226. ); /* clang-format on */
  227. keymap_config_t kc;
  228. eeconfig_read_keymap(&kc);
  229. xprintf(/* clang-format off */
  230. "keymap_config.raw: %02X\n"
  231. ".swap_control_capslock: %u\n"
  232. ".capslock_to_control: %u\n"
  233. ".swap_lctl_lgui: %u\n"
  234. ".swap_rctl_rgui: %u\n"
  235. ".swap_lalt_lgui: %u\n"
  236. ".swap_ralt_rgui: %u\n"
  237. ".no_gui: %u\n"
  238. ".swap_grave_esc: %u\n"
  239. ".swap_backslash_backspace: %u\n"
  240. ".nkro: %u\n"
  241. ".swap_escape_capslock: %u\n"
  242. , kc.raw
  243. , kc.swap_control_capslock
  244. , kc.capslock_to_control
  245. , kc.swap_lctl_lgui
  246. , kc.swap_rctl_rgui
  247. , kc.swap_lalt_lgui
  248. , kc.swap_ralt_rgui
  249. , kc.no_gui
  250. , kc.swap_grave_esc
  251. , kc.swap_backslash_backspace
  252. , kc.nkro
  253. , kc.swap_escape_capslock
  254. ); /* clang-format on */
  255. # ifdef BACKLIGHT_ENABLE
  256. backlight_config_t bc;
  257. eeconfig_read_backlight(&bc);
  258. xprintf(/* clang-format off */
  259. "backlight_config"
  260. ".raw: %02X\n"
  261. ".enable: %u\n"
  262. ".level: %u\n"
  263. , bc.raw
  264. , bc.enable
  265. , bc.level
  266. ); /* clang-format on */
  267. # endif /* BACKLIGHT_ENABLE */
  268. }
  269. #endif /* !NO_PRINT && !USER_PRINT */
  270. static bool command_common(uint8_t code) {
  271. #ifdef KEYBOARD_LOCK_ENABLE
  272. static host_driver_t *host_driver = 0;
  273. #endif
  274. switch (code) {
  275. #ifdef SLEEP_LED_ENABLE
  276. // test breathing sleep LED
  277. case MAGIC_KC(MAGIC_KEY_SLEEP_LED):
  278. print("Sleep LED Test\n");
  279. sleep_led_toggle();
  280. led_set(host_keyboard_leds());
  281. break;
  282. #endif
  283. // print stored eeprom config
  284. case MAGIC_KC(MAGIC_KEY_EEPROM):
  285. #if !defined(NO_PRINT) && !defined(USER_PRINT)
  286. print_eeconfig();
  287. #endif /* !NO_PRINT && !USER_PRINT */
  288. break;
  289. // clear eeprom
  290. case MAGIC_KC(MAGIC_KEY_EEPROM_CLEAR):
  291. print("Clearing EEPROM\n");
  292. eeconfig_init();
  293. break;
  294. #ifdef KEYBOARD_LOCK_ENABLE
  295. // lock/unlock keyboard
  296. case MAGIC_KC(MAGIC_KEY_LOCK):
  297. if (host_get_driver()) {
  298. host_driver = host_get_driver();
  299. clear_keyboard();
  300. host_set_driver(0);
  301. print("Locked.\n");
  302. } else {
  303. host_set_driver(host_driver);
  304. print("Unlocked.\n");
  305. }
  306. break;
  307. #endif
  308. // print help
  309. case MAGIC_KC(MAGIC_KEY_HELP):
  310. case MAGIC_KC(MAGIC_KEY_HELP_ALT):
  311. command_common_help();
  312. break;
  313. // activate console
  314. case MAGIC_KC(MAGIC_KEY_CONSOLE):
  315. debug_matrix = false;
  316. debug_keyboard = false;
  317. debug_mouse = false;
  318. debug_enable = false;
  319. command_console_help();
  320. print("C> ");
  321. command_state = CONSOLE;
  322. break;
  323. // jump to bootloader
  324. case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
  325. case MAGIC_KC(MAGIC_KEY_BOOTLOADER_ALT):
  326. print("\n\nJumping to bootloader... ");
  327. reset_keyboard();
  328. break;
  329. // debug toggle
  330. case MAGIC_KC(MAGIC_KEY_DEBUG):
  331. debug_enable = !debug_enable;
  332. if (debug_enable) {
  333. print("\ndebug: on\n");
  334. } else {
  335. print("\ndebug: off\n");
  336. debug_matrix = false;
  337. debug_keyboard = false;
  338. debug_mouse = false;
  339. }
  340. break;
  341. // debug matrix toggle
  342. case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
  343. debug_matrix = !debug_matrix;
  344. if (debug_matrix) {
  345. print("\nmatrix: on\n");
  346. debug_enable = true;
  347. } else {
  348. print("\nmatrix: off\n");
  349. }
  350. break;
  351. // debug keyboard toggle
  352. case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
  353. debug_keyboard = !debug_keyboard;
  354. if (debug_keyboard) {
  355. print("\nkeyboard: on\n");
  356. debug_enable = true;
  357. } else {
  358. print("\nkeyboard: off\n");
  359. }
  360. break;
  361. // debug mouse toggle
  362. case MAGIC_KC(MAGIC_KEY_DEBUG_MOUSE):
  363. debug_mouse = !debug_mouse;
  364. if (debug_mouse) {
  365. print("\nmouse: on\n");
  366. debug_enable = true;
  367. } else {
  368. print("\nmouse: off\n");
  369. }
  370. break;
  371. // print version
  372. case MAGIC_KC(MAGIC_KEY_VERSION):
  373. print_version();
  374. break;
  375. // print status
  376. case MAGIC_KC(MAGIC_KEY_STATUS):
  377. print_status();
  378. break;
  379. #ifdef NKRO_ENABLE
  380. // NKRO toggle
  381. case MAGIC_KC(MAGIC_KEY_NKRO):
  382. clear_keyboard(); // clear to prevent stuck keys
  383. keymap_config.nkro = !keymap_config.nkro;
  384. if (keymap_config.nkro) {
  385. print("NKRO: on\n");
  386. } else {
  387. print("NKRO: off\n");
  388. }
  389. break;
  390. #endif
  391. // switch layers
  392. case MAGIC_KC(MAGIC_KEY_LAYER0_ALT):
  393. switch_default_layer(0);
  394. break;
  395. #if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
  396. case MAGIC_KC(MAGIC_KEY_LAYER0):
  397. switch_default_layer(0);
  398. break;
  399. case MAGIC_KC(MAGIC_KEY_LAYER1):
  400. switch_default_layer(1);
  401. break;
  402. case MAGIC_KC(MAGIC_KEY_LAYER2):
  403. switch_default_layer(2);
  404. break;
  405. case MAGIC_KC(MAGIC_KEY_LAYER3):
  406. switch_default_layer(3);
  407. break;
  408. case MAGIC_KC(MAGIC_KEY_LAYER4):
  409. switch_default_layer(4);
  410. break;
  411. case MAGIC_KC(MAGIC_KEY_LAYER5):
  412. switch_default_layer(5);
  413. break;
  414. case MAGIC_KC(MAGIC_KEY_LAYER6):
  415. switch_default_layer(6);
  416. break;
  417. case MAGIC_KC(MAGIC_KEY_LAYER7):
  418. switch_default_layer(7);
  419. break;
  420. case MAGIC_KC(MAGIC_KEY_LAYER8):
  421. switch_default_layer(8);
  422. break;
  423. case MAGIC_KC(MAGIC_KEY_LAYER9):
  424. switch_default_layer(9);
  425. break;
  426. #endif
  427. #if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
  428. case KC_F1 ... KC_F9:
  429. switch_default_layer((code - KC_F1) + 1);
  430. break;
  431. case KC_F10:
  432. switch_default_layer(0);
  433. break;
  434. #endif
  435. #if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
  436. case KC_1 ... KC_9:
  437. switch_default_layer((code - KC_1) + 1);
  438. break;
  439. case KC_0:
  440. switch_default_layer(0);
  441. break;
  442. #endif
  443. default:
  444. print("?");
  445. return false;
  446. }
  447. return true;
  448. }
  449. /***********************************************************
  450. * Command console
  451. ***********************************************************/
  452. static void command_console_help(void) {
  453. print("\n\t- Console -\n"
  454. "ESC/q: quit\n"
  455. #ifdef MOUSEKEY_ENABLE
  456. "m: mousekey\n"
  457. #endif
  458. );
  459. }
  460. static bool command_console(uint8_t code) {
  461. switch (code) {
  462. case KC_H:
  463. case KC_SLASH: /* ? */
  464. command_console_help();
  465. print("C> ");
  466. return true;
  467. case KC_Q:
  468. case KC_ESC:
  469. command_state = ONESHOT;
  470. return false;
  471. #if defined(MOUSEKEY_ENABLE)
  472. case KC_M:
  473. command_state = MOUSEKEY;
  474. mousekey_console(KC_SLASH /* ? */);
  475. return true;
  476. #endif
  477. default:
  478. print("?");
  479. return false;
  480. }
  481. }
  482. /***********************************************************
  483. * Mousekey console
  484. ***********************************************************/
  485. #if defined(MOUSEKEY_ENABLE)
  486. # if !defined(NO_PRINT) && !defined(USER_PRINT)
  487. static void mousekey_param_print(void) {
  488. xprintf(/* clang-format off */
  489. #ifndef MK_3_SPEED
  490. "1: delay(*10ms): %u\n"
  491. "2: interval(ms): %u\n"
  492. "3: max_speed: %u\n"
  493. "4: time_to_max: %u\n"
  494. "5: wheel_max_speed: %u\n"
  495. "6: wheel_time_to_max: %u\n"
  496. , mk_delay
  497. , mk_interval
  498. , mk_max_speed
  499. , mk_time_to_max
  500. , mk_wheel_max_speed
  501. , mk_wheel_time_to_max
  502. #else
  503. "no knobs sorry\n"
  504. #endif
  505. ); /* clang-format on */
  506. }
  507. # endif /* !NO_PRINT && !USER_PRINT */
  508. # if !defined(NO_PRINT) && !defined(USER_PRINT)
  509. static void mousekey_console_help(void) {
  510. mousekey_param_print();
  511. xprintf(/* clang-format off */
  512. "p: print values\n"
  513. "d: set defaults\n"
  514. "up: +1\n"
  515. "dn: -1\n"
  516. "lt: +10\n"
  517. "rt: -10\n"
  518. "ESC/q: quit\n"
  519. #ifndef MK_3_SPEED
  520. "\n"
  521. "speed = delta * max_speed * (repeat / time_to_max)\n"
  522. "where delta: cursor=%d, wheel=%d\n"
  523. "See http://en.wikipedia.org/wiki/Mouse_keys\n"
  524. , MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA
  525. #endif
  526. ); /* clang-format on */
  527. }
  528. # endif /* !NO_PRINT && !USER_PRINT */
  529. /* Only used by `quantum/command.c` / `command_proc()`. To avoid
  530. * any doubt: we return `false` to return to the main console,
  531. * which differs from the `bool` that `command_proc()` returns. */
  532. bool mousekey_console(uint8_t code) {
  533. static uint8_t param = 0;
  534. static uint8_t *pp = NULL;
  535. static char * desc = NULL;
  536. # if defined(NO_PRINT) || defined(USER_PRINT) /* -Wunused-parameter */
  537. (void)desc;
  538. # endif
  539. int8_t change = 0;
  540. switch (code) {
  541. case KC_H:
  542. case KC_SLASH: /* ? */
  543. # if !defined(NO_PRINT) && !defined(USER_PRINT)
  544. print("\n\t- Mousekey -\n");
  545. mousekey_console_help();
  546. # endif
  547. break;
  548. case KC_Q:
  549. case KC_ESC:
  550. print("q\n");
  551. if (!param) return false;
  552. param = 0;
  553. pp = NULL;
  554. desc = NULL;
  555. break;
  556. case KC_P:
  557. # if !defined(NO_PRINT) && !defined(USER_PRINT)
  558. print("\n\t- Values -\n");
  559. mousekey_param_print();
  560. # endif
  561. break;
  562. case KC_1 ... KC_0: /* KC_0 gives param = 10 */
  563. param = 1 + code - KC_1;
  564. switch (param) { /* clang-format off */
  565. # define PARAM(n, v) case n: pp = &(v); desc = #v; break
  566. #ifndef MK_3_SPEED
  567. PARAM(1, mk_delay);
  568. PARAM(2, mk_interval);
  569. PARAM(3, mk_max_speed);
  570. PARAM(4, mk_time_to_max);
  571. PARAM(5, mk_wheel_max_speed);
  572. PARAM(6, mk_wheel_time_to_max);
  573. #endif /* MK_3_SPEED */
  574. # undef PARAM
  575. default:
  576. param = 0;
  577. print("?\n");
  578. break;
  579. } /* clang-format on */
  580. if (param) xprintf("%u\n", param);
  581. break;
  582. /* clang-format off */
  583. case KC_UP: change = +1; break;
  584. case KC_DOWN: change = -1; break;
  585. case KC_LEFT: change = -10; break;
  586. case KC_RIGHT: change = +10; break;
  587. /* clang-format on */
  588. case KC_D:
  589. # ifndef MK_3_SPEED
  590. mk_delay = MOUSEKEY_DELAY / 10;
  591. mk_interval = MOUSEKEY_INTERVAL;
  592. mk_max_speed = MOUSEKEY_MAX_SPEED;
  593. mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
  594. mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
  595. mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
  596. # endif /* MK_3_SPEED */
  597. print("defaults\n");
  598. break;
  599. default:
  600. print("?\n");
  601. break;
  602. }
  603. if (change) {
  604. if (pp) {
  605. int16_t val = *pp + change;
  606. if (val > (int16_t)UINT8_MAX)
  607. *pp = UINT8_MAX;
  608. else if (val < 0)
  609. *pp = 0;
  610. else
  611. *pp = (uint8_t)val;
  612. xprintf("= %u\n", *pp);
  613. } else {
  614. print("?\n");
  615. }
  616. }
  617. if (param) {
  618. xprintf("M%u:%s> ", param, desc ? desc : "???");
  619. } else {
  620. print("M> ");
  621. }
  622. return true;
  623. }
  624. #endif /* MOUSEKEY_ENABLE */
  625. /***********************************************************
  626. * Utilities
  627. ***********************************************************/
  628. static void switch_default_layer(uint8_t layer) {
  629. xprintf("L%d\n", layer);
  630. default_layer_set((layer_state_t)1 << layer);
  631. clear_keyboard();
  632. }