You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

command.c 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. Copyright 2011 Jun Wako <[email protected]>
  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 <util/delay.h>
  17. #include "keycode.h"
  18. #include "host.h"
  19. #include "keymap.h"
  20. #include "print.h"
  21. #include "debug.h"
  22. #include "util.h"
  23. #include "timer.h"
  24. #include "keyboard.h"
  25. #include "bootloader.h"
  26. #include "action_layer.h"
  27. #include "action_util.h"
  28. #include "eeconfig.h"
  29. #include "sleep_led.h"
  30. #include "led.h"
  31. #include "command.h"
  32. #include "backlight.h"
  33. #ifdef MOUSEKEY_ENABLE
  34. #include "mousekey.h"
  35. #endif
  36. #ifdef PROTOCOL_PJRC
  37. # include "usb_keyboard.h"
  38. # ifdef EXTRAKEY_ENABLE
  39. # include "usb_extra.h"
  40. # endif
  41. #endif
  42. #ifdef PROTOCOL_VUSB
  43. # include "usbdrv.h"
  44. #endif
  45. static bool command_common(uint8_t code);
  46. static void command_common_help(void);
  47. static bool command_console(uint8_t code);
  48. static void command_console_help(void);
  49. #ifdef MOUSEKEY_ENABLE
  50. static bool mousekey_console(uint8_t code);
  51. static void mousekey_console_help(void);
  52. #endif
  53. static uint8_t numkey2num(uint8_t code);
  54. static void switch_default_layer(uint8_t layer);
  55. command_state_t command_state = ONESHOT;
  56. bool command_proc(uint8_t code)
  57. {
  58. switch (command_state) {
  59. case ONESHOT:
  60. if (!IS_COMMAND())
  61. return false;
  62. return (command_extra(code) || command_common(code));
  63. break;
  64. case CONSOLE:
  65. if (IS_COMMAND())
  66. return (command_extra(code) || command_common(code));
  67. else
  68. return (command_console_extra(code) || command_console(code));
  69. break;
  70. #ifdef MOUSEKEY_ENABLE
  71. case MOUSEKEY:
  72. mousekey_console(code);
  73. break;
  74. #endif
  75. default:
  76. command_state = ONESHOT;
  77. return false;
  78. }
  79. return true;
  80. }
  81. /* TODO: Refactoring is needed. */
  82. /* This allows to define extra commands. return false when not processed. */
  83. bool command_extra(uint8_t code) __attribute__ ((weak));
  84. bool command_extra(uint8_t code)
  85. {
  86. return false;
  87. }
  88. bool command_console_extra(uint8_t code) __attribute__ ((weak));
  89. bool command_console_extra(uint8_t code)
  90. {
  91. return false;
  92. }
  93. /***********************************************************
  94. * Command common
  95. ***********************************************************/
  96. static void command_common_help(void)
  97. {
  98. print("\n\n----- Command Help -----\n");
  99. print("c: enter console mode\n");
  100. print("d: toggle debug enable\n");
  101. print("x: toggle matrix debug\n");
  102. print("k: toggle keyboard debug\n");
  103. print("m: toggle mouse debug\n");
  104. #ifdef SLEEP_LED_ENABLE
  105. print("z: toggle sleep LED test\n");
  106. #endif
  107. print("v: print device version & info\n");
  108. print("t: print timer count\n");
  109. print("s: print status\n");
  110. print("e: print eeprom config\n");
  111. #ifdef NKRO_ENABLE
  112. print("n: toggle NKRO\n");
  113. #endif
  114. print("0/F10: switch to Layer0 \n");
  115. print("1/F1: switch to Layer1 \n");
  116. print("2/F2: switch to Layer2 \n");
  117. print("3/F3: switch to Layer3 \n");
  118. print("4/F4: switch to Layer4 \n");
  119. print("PScr: power down/remote wake-up\n");
  120. print("Caps: Lock Keyboard(Child Proof)\n");
  121. print("Paus: jump to bootloader\n");
  122. }
  123. #ifdef BOOTMAGIC_ENABLE
  124. static void print_eeconfig(void)
  125. {
  126. print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");
  127. debug_config_t dc;
  128. dc.raw = eeconfig_read_debug();
  129. print("debug_config.raw: "); print_hex8(dc.raw); print("\n");
  130. print(".enable: "); print_dec(dc.enable); print("\n");
  131. print(".matrix: "); print_dec(dc.matrix); print("\n");
  132. print(".keyboard: "); print_dec(dc.keyboard); print("\n");
  133. print(".mouse: "); print_dec(dc.mouse); print("\n");
  134. keymap_config_t kc;
  135. kc.raw = eeconfig_read_keymap();
  136. print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
  137. print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
  138. print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
  139. print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
  140. print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
  141. print(".no_gui: "); print_dec(kc.no_gui); print("\n");
  142. print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n");
  143. print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n");
  144. print(".nkro: "); print_dec(kc.nkro); print("\n");
  145. #ifdef BACKLIGHT_ENABLE
  146. backlight_config_t bc;
  147. bc.raw = eeconfig_read_backlight();
  148. print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
  149. print(".enable: "); print_dec(bc.enable); print("\n");
  150. print(".level: "); print_dec(bc.level); print("\n");
  151. #endif
  152. }
  153. #endif
  154. static bool command_common(uint8_t code)
  155. {
  156. static host_driver_t *host_driver = 0;
  157. switch (code) {
  158. #ifdef SLEEP_LED_ENABLE
  159. case KC_Z:
  160. // test breathing sleep LED
  161. print("Sleep LED test\n");
  162. sleep_led_toggle();
  163. led_set(host_keyboard_leds());
  164. break;
  165. #endif
  166. #ifdef BOOTMAGIC_ENABLE
  167. case KC_E:
  168. print("eeconfig:\n");
  169. print_eeconfig();
  170. break;
  171. #endif
  172. case KC_CAPSLOCK:
  173. if (host_get_driver()) {
  174. host_driver = host_get_driver();
  175. clear_keyboard();
  176. host_set_driver(0);
  177. print("Locked.\n");
  178. } else {
  179. host_set_driver(host_driver);
  180. print("Unlocked.\n");
  181. }
  182. break;
  183. case KC_H:
  184. case KC_SLASH: /* ? */
  185. command_common_help();
  186. break;
  187. case KC_C:
  188. debug_matrix = false;
  189. debug_keyboard = false;
  190. debug_mouse = false;
  191. debug_enable = false;
  192. command_console_help();
  193. print("\nEnter Console Mode\n");
  194. print("C> ");
  195. command_state = CONSOLE;
  196. break;
  197. case KC_PAUSE:
  198. clear_keyboard();
  199. print("\n\nJump to bootloader... ");
  200. _delay_ms(1000);
  201. bootloader_jump(); // not return
  202. print("not supported.\n");
  203. break;
  204. case KC_D:
  205. if (debug_enable) {
  206. print("\nDEBUG: disabled.\n");
  207. debug_matrix = false;
  208. debug_keyboard = false;
  209. debug_mouse = false;
  210. debug_enable = false;
  211. } else {
  212. print("\nDEBUG: enabled.\n");
  213. debug_enable = true;
  214. }
  215. break;
  216. case KC_X: // debug matrix toggle
  217. debug_matrix = !debug_matrix;
  218. if (debug_matrix) {
  219. print("\nDEBUG: matrix enabled.\n");
  220. debug_enable = true;
  221. } else {
  222. print("\nDEBUG: matrix disabled.\n");
  223. }
  224. break;
  225. case KC_K: // debug keyboard toggle
  226. debug_keyboard = !debug_keyboard;
  227. if (debug_keyboard) {
  228. print("\nDEBUG: keyboard enabled.\n");
  229. debug_enable = true;
  230. } else {
  231. print("\nDEBUG: keyboard disabled.\n");
  232. }
  233. break;
  234. case KC_M: // debug mouse toggle
  235. debug_mouse = !debug_mouse;
  236. if (debug_mouse) {
  237. print("\nDEBUG: mouse enabled.\n");
  238. debug_enable = true;
  239. } else {
  240. print("\nDEBUG: mouse disabled.\n");
  241. }
  242. break;
  243. case KC_V: // print version & information
  244. print("\n\n----- Version -----\n");
  245. print("DESC: " STR(DESCRIPTION) "\n");
  246. print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
  247. "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
  248. "VER: " STR(DEVICE_VER) "\n");
  249. print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n");
  250. /* build options */
  251. print("OPTIONS:"
  252. #ifdef PROTOCOL_PJRC
  253. " PJRC"
  254. #endif
  255. #ifdef PROTOCOL_LUFA
  256. " LUFA"
  257. #endif
  258. #ifdef PROTOCOL_VUSB
  259. " VUSB"
  260. #endif
  261. #ifdef BOOTMAGIC_ENABLE
  262. " BOOTMAGIC"
  263. #endif
  264. #ifdef MOUSEKEY_ENABLE
  265. " MOUSEKEY"
  266. #endif
  267. #ifdef EXTRAKEY_ENABLE
  268. " EXTRAKEY"
  269. #endif
  270. #ifdef CONSOLE_ENABLE
  271. " CONSOLE"
  272. #endif
  273. #ifdef COMMAND_ENABLE
  274. " COMMAND"
  275. #endif
  276. #ifdef NKRO_ENABLE
  277. " NKRO"
  278. #endif
  279. #ifdef USB_6KRO_ENABLE
  280. " 6KRO"
  281. #endif
  282. #ifdef KEYMAP_SECTION_ENABLE
  283. " KEYMAP_SECTION"
  284. #endif
  285. #ifdef KEYMAP_IN_EEPROM_ENABLE
  286. " KEYMAP_IN_EEPROM"
  287. #endif
  288. #ifdef LEDMAP_ENABLE
  289. " LEDMAP"
  290. #endif
  291. #ifdef LEDMAP_IN_EEPROM_ENABLE
  292. " LEDMAP_IN_EEPROM"
  293. #endif
  294. #ifdef BACKLIGHT_ENABLE
  295. " BACKLIGHT"
  296. #endif
  297. #ifdef SOFTPWM_LED_ENABLE
  298. " SOFTPWM_LED"
  299. #endif
  300. #ifdef BREATHING_LED_ENABLE
  301. " BREATHING_LED"
  302. #endif
  303. " " STR(BOOTLOADER_SIZE) "\n");
  304. print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
  305. " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
  306. " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
  307. break;
  308. case KC_T: // print timer
  309. print_val_hex32(timer_count);
  310. break;
  311. case KC_S:
  312. print("\n\n----- Status -----\n");
  313. print_val_hex8(host_keyboard_leds());
  314. print_val_hex8(keyboard_protocol);
  315. print_val_hex8(keyboard_idle);
  316. #ifdef PROTOCOL_PJRC
  317. print_val_hex8(UDCON);
  318. print_val_hex8(UDIEN);
  319. print_val_hex8(UDINT);
  320. print_val_hex8(usb_keyboard_leds);
  321. print_val_hex8(usb_keyboard_idle_count);
  322. #endif
  323. #ifdef PROTOCOL_PJRC
  324. # if USB_COUNT_SOF
  325. print_val_hex8(usbSofCount);
  326. # endif
  327. #endif
  328. break;
  329. #ifdef NKRO_ENABLE
  330. case KC_N:
  331. clear_keyboard(); //Prevents stuck keys.
  332. keyboard_nkro = !keyboard_nkro;
  333. if (keyboard_nkro)
  334. print("NKRO: enabled\n");
  335. else
  336. print("NKRO: disabled\n");
  337. break;
  338. #endif
  339. #ifdef EXTRAKEY_ENABLE
  340. case KC_PSCREEN:
  341. // TODO: Power key should take this feature? otherwise any key during suspend.
  342. #ifdef PROTOCOL_PJRC
  343. if (suspend && remote_wakeup) {
  344. usb_remote_wakeup();
  345. } else {
  346. host_system_send(SYSTEM_POWER_DOWN);
  347. host_system_send(0);
  348. _delay_ms(500);
  349. }
  350. #else
  351. host_system_send(SYSTEM_POWER_DOWN);
  352. _delay_ms(100);
  353. host_system_send(0);
  354. _delay_ms(500);
  355. #endif
  356. break;
  357. #endif
  358. case KC_ESC:
  359. case KC_GRV:
  360. case KC_0:
  361. switch_default_layer(0);
  362. break;
  363. case KC_1 ... KC_9:
  364. switch_default_layer((code - KC_1) + 1);
  365. break;
  366. case KC_F1 ... KC_F12:
  367. switch_default_layer((code - KC_F1) + 1);
  368. break;
  369. default:
  370. print("?");
  371. return false;
  372. }
  373. return true;
  374. }
  375. /***********************************************************
  376. * Command console
  377. ***********************************************************/
  378. static void command_console_help(void)
  379. {
  380. print("\n\n----- Console Help -----\n");
  381. print("ESC/q: quit\n");
  382. #ifdef MOUSEKEY_ENABLE
  383. print("m: mousekey\n");
  384. #endif
  385. }
  386. static bool command_console(uint8_t code)
  387. {
  388. switch (code) {
  389. case KC_H:
  390. case KC_SLASH: /* ? */
  391. command_console_help();
  392. break;
  393. case KC_Q:
  394. case KC_ESC:
  395. print("\nQuit Console Mode\n");
  396. command_state = ONESHOT;
  397. return false;
  398. #ifdef MOUSEKEY_ENABLE
  399. case KC_M:
  400. mousekey_console_help();
  401. print("\nEnter Mousekey Console\n");
  402. print("M0>");
  403. command_state = MOUSEKEY;
  404. return true;
  405. #endif
  406. default:
  407. print("?");
  408. return false;
  409. }
  410. print("C> ");
  411. return true;
  412. }
  413. #ifdef MOUSEKEY_ENABLE
  414. /***********************************************************
  415. * Mousekey console
  416. ***********************************************************/
  417. static uint8_t mousekey_param = 0;
  418. static void mousekey_param_print(void)
  419. {
  420. print("\n\n----- Mousekey Parameters -----\n");
  421. print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n");
  422. print("2: mk_interval(ms): "); pdec(mk_interval); print("\n");
  423. print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n");
  424. print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n");
  425. print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
  426. print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
  427. }
  428. #define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
  429. static void mousekey_param_inc(uint8_t param, uint8_t inc)
  430. {
  431. switch (param) {
  432. case 1:
  433. if (mk_delay + inc < UINT8_MAX)
  434. mk_delay += inc;
  435. else
  436. mk_delay = UINT8_MAX;
  437. PRINT_SET_VAL(mk_delay);
  438. break;
  439. case 2:
  440. if (mk_interval + inc < UINT8_MAX)
  441. mk_interval += inc;
  442. else
  443. mk_interval = UINT8_MAX;
  444. PRINT_SET_VAL(mk_interval);
  445. break;
  446. case 3:
  447. if (mk_max_speed + inc < UINT8_MAX)
  448. mk_max_speed += inc;
  449. else
  450. mk_max_speed = UINT8_MAX;
  451. PRINT_SET_VAL(mk_max_speed);
  452. break;
  453. case 4:
  454. if (mk_time_to_max + inc < UINT8_MAX)
  455. mk_time_to_max += inc;
  456. else
  457. mk_time_to_max = UINT8_MAX;
  458. PRINT_SET_VAL(mk_time_to_max);
  459. break;
  460. case 5:
  461. if (mk_wheel_max_speed + inc < UINT8_MAX)
  462. mk_wheel_max_speed += inc;
  463. else
  464. mk_wheel_max_speed = UINT8_MAX;
  465. PRINT_SET_VAL(mk_wheel_max_speed);
  466. break;
  467. case 6:
  468. if (mk_wheel_time_to_max + inc < UINT8_MAX)
  469. mk_wheel_time_to_max += inc;
  470. else
  471. mk_wheel_time_to_max = UINT8_MAX;
  472. PRINT_SET_VAL(mk_wheel_time_to_max);
  473. break;
  474. }
  475. }
  476. static void mousekey_param_dec(uint8_t param, uint8_t dec)
  477. {
  478. switch (param) {
  479. case 1:
  480. if (mk_delay > dec)
  481. mk_delay -= dec;
  482. else
  483. mk_delay = 0;
  484. PRINT_SET_VAL(mk_delay);
  485. break;
  486. case 2:
  487. if (mk_interval > dec)
  488. mk_interval -= dec;
  489. else
  490. mk_interval = 0;
  491. PRINT_SET_VAL(mk_interval);
  492. break;
  493. case 3:
  494. if (mk_max_speed > dec)
  495. mk_max_speed -= dec;
  496. else
  497. mk_max_speed = 0;
  498. PRINT_SET_VAL(mk_max_speed);
  499. break;
  500. case 4:
  501. if (mk_time_to_max > dec)
  502. mk_time_to_max -= dec;
  503. else
  504. mk_time_to_max = 0;
  505. PRINT_SET_VAL(mk_time_to_max);
  506. break;
  507. case 5:
  508. if (mk_wheel_max_speed > dec)
  509. mk_wheel_max_speed -= dec;
  510. else
  511. mk_wheel_max_speed = 0;
  512. PRINT_SET_VAL(mk_wheel_max_speed);
  513. break;
  514. case 6:
  515. if (mk_wheel_time_to_max > dec)
  516. mk_wheel_time_to_max -= dec;
  517. else
  518. mk_wheel_time_to_max = 0;
  519. PRINT_SET_VAL(mk_wheel_time_to_max);
  520. break;
  521. }
  522. }
  523. static void mousekey_console_help(void)
  524. {
  525. print("\n\n----- Mousekey Parameters Help -----\n");
  526. print("ESC/q: quit\n");
  527. print("1: select mk_delay(*10ms)\n");
  528. print("2: select mk_interval(ms)\n");
  529. print("3: select mk_max_speed\n");
  530. print("4: select mk_time_to_max\n");
  531. print("5: select mk_wheel_max_speed\n");
  532. print("6: select mk_wheel_time_to_max\n");
  533. print("p: print parameters\n");
  534. print("d: set default values\n");
  535. print("up: increase parameters(+1)\n");
  536. print("down: decrease parameters(-1)\n");
  537. print("pgup: increase parameters(+10)\n");
  538. print("pgdown: decrease parameters(-10)\n");
  539. print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
  540. print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
  541. print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");
  542. print("See http://en.wikipedia.org/wiki/Mouse_keys\n");
  543. }
  544. static bool mousekey_console(uint8_t code)
  545. {
  546. switch (code) {
  547. case KC_H:
  548. case KC_SLASH: /* ? */
  549. mousekey_console_help();
  550. break;
  551. case KC_Q:
  552. case KC_ESC:
  553. mousekey_param = 0;
  554. print("\nQuit Mousekey Console\n");
  555. print("C> ");
  556. command_state = CONSOLE;
  557. return false;
  558. case KC_P:
  559. mousekey_param_print();
  560. break;
  561. case KC_1:
  562. case KC_2:
  563. case KC_3:
  564. case KC_4:
  565. case KC_5:
  566. case KC_6:
  567. case KC_7:
  568. case KC_8:
  569. case KC_9:
  570. case KC_0:
  571. mousekey_param = numkey2num(code);
  572. print("selected parameter: "); pdec(mousekey_param); print("\n");
  573. break;
  574. case KC_UP:
  575. mousekey_param_inc(mousekey_param, 1);
  576. break;
  577. case KC_DOWN:
  578. mousekey_param_dec(mousekey_param, 1);
  579. break;
  580. case KC_PGUP:
  581. mousekey_param_inc(mousekey_param, 10);
  582. break;
  583. case KC_PGDN:
  584. mousekey_param_dec(mousekey_param, 10);
  585. break;
  586. case KC_D:
  587. mk_delay = MOUSEKEY_DELAY/10;
  588. mk_interval = MOUSEKEY_INTERVAL;
  589. mk_max_speed = MOUSEKEY_MAX_SPEED;
  590. mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
  591. mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
  592. mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
  593. print("set default values.\n");
  594. break;
  595. default:
  596. print("?");
  597. return false;
  598. }
  599. print("M"); pdec(mousekey_param); print("> ");
  600. return true;
  601. }
  602. #endif
  603. /***********************************************************
  604. * Utilities
  605. ***********************************************************/
  606. static uint8_t numkey2num(uint8_t code)
  607. {
  608. switch (code) {
  609. case KC_1: return 1;
  610. case KC_2: return 2;
  611. case KC_3: return 3;
  612. case KC_4: return 4;
  613. case KC_5: return 5;
  614. case KC_6: return 6;
  615. case KC_7: return 7;
  616. case KC_8: return 8;
  617. case KC_9: return 9;
  618. case KC_0: return 0;
  619. }
  620. return 0;
  621. }
  622. static void switch_default_layer(uint8_t layer)
  623. {
  624. print("switch_default_layer: "); print_dec(biton32(default_layer_state));
  625. print(" to "); print_dec(layer); print("\n");
  626. default_layer_set(1UL<<layer);
  627. clear_keyboard();
  628. }