Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. host_set_driver(0);
  176. print("Locked.\n");
  177. } else {
  178. host_set_driver(host_driver);
  179. print("Unlocked.\n");
  180. }
  181. break;
  182. case KC_H:
  183. case KC_SLASH: /* ? */
  184. command_common_help();
  185. break;
  186. case KC_C:
  187. debug_matrix = false;
  188. debug_keyboard = false;
  189. debug_mouse = false;
  190. debug_enable = false;
  191. command_console_help();
  192. print("\nEnter Console Mode\n");
  193. print("C> ");
  194. command_state = CONSOLE;
  195. break;
  196. case KC_PAUSE:
  197. clear_keyboard();
  198. print("\n\nJump to bootloader... ");
  199. _delay_ms(1000);
  200. bootloader_jump(); // not return
  201. print("not supported.\n");
  202. break;
  203. case KC_D:
  204. if (debug_enable) {
  205. print("\nDEBUG: disabled.\n");
  206. debug_matrix = false;
  207. debug_keyboard = false;
  208. debug_mouse = false;
  209. debug_enable = false;
  210. } else {
  211. print("\nDEBUG: enabled.\n");
  212. debug_enable = true;
  213. }
  214. break;
  215. case KC_X: // debug matrix toggle
  216. debug_matrix = !debug_matrix;
  217. if (debug_matrix) {
  218. print("\nDEBUG: matrix enabled.\n");
  219. debug_enable = true;
  220. } else {
  221. print("\nDEBUG: matrix disabled.\n");
  222. }
  223. break;
  224. case KC_K: // debug keyboard toggle
  225. debug_keyboard = !debug_keyboard;
  226. if (debug_keyboard) {
  227. print("\nDEBUG: keyboard enabled.\n");
  228. debug_enable = true;
  229. } else {
  230. print("\nDEBUG: keyboard disabled.\n");
  231. }
  232. break;
  233. case KC_M: // debug mouse toggle
  234. debug_mouse = !debug_mouse;
  235. if (debug_mouse) {
  236. print("\nDEBUG: mouse enabled.\n");
  237. debug_enable = true;
  238. } else {
  239. print("\nDEBUG: mouse disabled.\n");
  240. }
  241. break;
  242. case KC_V: // print version & information
  243. print("\n\n----- Version -----\n");
  244. print("DESC: " STR(DESCRIPTION) "\n");
  245. print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
  246. "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
  247. "VER: " STR(DEVICE_VER) "\n");
  248. print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n");
  249. /* build options */
  250. print("OPTIONS:"
  251. #ifdef PROTOCOL_PJRC
  252. " PJRC"
  253. #endif
  254. #ifdef PROTOCOL_LUFA
  255. " LUFA"
  256. #endif
  257. #ifdef PROTOCOL_VUSB
  258. " VUSB"
  259. #endif
  260. #ifdef BOOTMAGIC_ENABLE
  261. " BOOTMAGIC"
  262. #endif
  263. #ifdef MOUSEKEY_ENABLE
  264. " MOUSEKEY"
  265. #endif
  266. #ifdef EXTRAKEY_ENABLE
  267. " EXTRAKEY"
  268. #endif
  269. #ifdef CONSOLE_ENABLE
  270. " CONSOLE"
  271. #endif
  272. #ifdef COMMAND_ENABLE
  273. " COMMAND"
  274. #endif
  275. #ifdef NKRO_ENABLE
  276. " NKRO"
  277. #endif
  278. #ifdef USB_6KRO_ENABLE
  279. " 6KRO"
  280. #endif
  281. #ifdef KEYMAP_SECTION_ENABLE
  282. " KEYMAP_SECTION"
  283. #endif
  284. #ifdef KEYMAP_IN_EEPROM_ENABLE
  285. " KEYMAP_IN_EEPROM"
  286. #endif
  287. #ifdef LEDMAP_ENABLE
  288. " LEDMAP"
  289. #endif
  290. #ifdef LEDMAP_IN_EEPROM_ENABLE
  291. " LEDMAP_IN_EEPROM"
  292. #endif
  293. #ifdef BACKLIGHT_ENABLE
  294. " BACKLIGHT"
  295. #endif
  296. #ifdef SOFTPWM_LED_ENABLE
  297. " SOFTPWM_LED"
  298. #endif
  299. #ifdef BREATHING_LED_ENABLE
  300. " BREATHING_LED"
  301. #endif
  302. " " STR(BOOTLOADER_SIZE) "\n");
  303. print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
  304. " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
  305. " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
  306. break;
  307. case KC_T: // print timer
  308. print_val_hex32(timer_count);
  309. break;
  310. case KC_S:
  311. print("\n\n----- Status -----\n");
  312. print_val_hex8(host_keyboard_leds());
  313. print_val_hex8(keyboard_protocol);
  314. print_val_hex8(keyboard_idle);
  315. #ifdef PROTOCOL_PJRC
  316. print_val_hex8(UDCON);
  317. print_val_hex8(UDIEN);
  318. print_val_hex8(UDINT);
  319. print_val_hex8(usb_keyboard_leds);
  320. print_val_hex8(usb_keyboard_idle_count);
  321. #endif
  322. #ifdef PROTOCOL_PJRC
  323. # if USB_COUNT_SOF
  324. print_val_hex8(usbSofCount);
  325. # endif
  326. #endif
  327. break;
  328. #ifdef NKRO_ENABLE
  329. case KC_N:
  330. clear_keyboard(); //Prevents stuck keys.
  331. keyboard_nkro = !keyboard_nkro;
  332. if (keyboard_nkro)
  333. print("NKRO: enabled\n");
  334. else
  335. print("NKRO: disabled\n");
  336. break;
  337. #endif
  338. #ifdef EXTRAKEY_ENABLE
  339. case KC_PSCREEN:
  340. // TODO: Power key should take this feature? otherwise any key during suspend.
  341. #ifdef PROTOCOL_PJRC
  342. if (suspend && remote_wakeup) {
  343. usb_remote_wakeup();
  344. } else {
  345. host_system_send(SYSTEM_POWER_DOWN);
  346. host_system_send(0);
  347. _delay_ms(500);
  348. }
  349. #else
  350. host_system_send(SYSTEM_POWER_DOWN);
  351. _delay_ms(100);
  352. host_system_send(0);
  353. _delay_ms(500);
  354. #endif
  355. break;
  356. #endif
  357. case KC_ESC:
  358. case KC_GRV:
  359. case KC_0:
  360. switch_default_layer(0);
  361. break;
  362. case KC_1 ... KC_9:
  363. switch_default_layer((code - KC_1) + 1);
  364. break;
  365. case KC_F1 ... KC_F12:
  366. switch_default_layer((code - KC_F1) + 1);
  367. break;
  368. default:
  369. print("?");
  370. return false;
  371. }
  372. return true;
  373. }
  374. /***********************************************************
  375. * Command console
  376. ***********************************************************/
  377. static void command_console_help(void)
  378. {
  379. print("\n\n----- Console Help -----\n");
  380. print("ESC/q: quit\n");
  381. #ifdef MOUSEKEY_ENABLE
  382. print("m: mousekey\n");
  383. #endif
  384. }
  385. static bool command_console(uint8_t code)
  386. {
  387. switch (code) {
  388. case KC_H:
  389. case KC_SLASH: /* ? */
  390. command_console_help();
  391. break;
  392. case KC_Q:
  393. case KC_ESC:
  394. print("\nQuit Console Mode\n");
  395. command_state = ONESHOT;
  396. return false;
  397. #ifdef MOUSEKEY_ENABLE
  398. case KC_M:
  399. mousekey_console_help();
  400. print("\nEnter Mousekey Console\n");
  401. print("M0>");
  402. command_state = MOUSEKEY;
  403. return true;
  404. #endif
  405. default:
  406. print("?");
  407. return false;
  408. }
  409. print("C> ");
  410. return true;
  411. }
  412. #ifdef MOUSEKEY_ENABLE
  413. /***********************************************************
  414. * Mousekey console
  415. ***********************************************************/
  416. static uint8_t mousekey_param = 0;
  417. static void mousekey_param_print(void)
  418. {
  419. print("\n\n----- Mousekey Parameters -----\n");
  420. print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n");
  421. print("2: mk_interval(ms): "); pdec(mk_interval); print("\n");
  422. print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n");
  423. print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n");
  424. print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
  425. print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
  426. }
  427. #define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
  428. static void mousekey_param_inc(uint8_t param, uint8_t inc)
  429. {
  430. switch (param) {
  431. case 1:
  432. if (mk_delay + inc < UINT8_MAX)
  433. mk_delay += inc;
  434. else
  435. mk_delay = UINT8_MAX;
  436. PRINT_SET_VAL(mk_delay);
  437. break;
  438. case 2:
  439. if (mk_interval + inc < UINT8_MAX)
  440. mk_interval += inc;
  441. else
  442. mk_interval = UINT8_MAX;
  443. PRINT_SET_VAL(mk_interval);
  444. break;
  445. case 3:
  446. if (mk_max_speed + inc < UINT8_MAX)
  447. mk_max_speed += inc;
  448. else
  449. mk_max_speed = UINT8_MAX;
  450. PRINT_SET_VAL(mk_max_speed);
  451. break;
  452. case 4:
  453. if (mk_time_to_max + inc < UINT8_MAX)
  454. mk_time_to_max += inc;
  455. else
  456. mk_time_to_max = UINT8_MAX;
  457. PRINT_SET_VAL(mk_time_to_max);
  458. break;
  459. case 5:
  460. if (mk_wheel_max_speed + inc < UINT8_MAX)
  461. mk_wheel_max_speed += inc;
  462. else
  463. mk_wheel_max_speed = UINT8_MAX;
  464. PRINT_SET_VAL(mk_wheel_max_speed);
  465. break;
  466. case 6:
  467. if (mk_wheel_time_to_max + inc < UINT8_MAX)
  468. mk_wheel_time_to_max += inc;
  469. else
  470. mk_wheel_time_to_max = UINT8_MAX;
  471. PRINT_SET_VAL(mk_wheel_time_to_max);
  472. break;
  473. }
  474. }
  475. static void mousekey_param_dec(uint8_t param, uint8_t dec)
  476. {
  477. switch (param) {
  478. case 1:
  479. if (mk_delay > dec)
  480. mk_delay -= dec;
  481. else
  482. mk_delay = 0;
  483. PRINT_SET_VAL(mk_delay);
  484. break;
  485. case 2:
  486. if (mk_interval > dec)
  487. mk_interval -= dec;
  488. else
  489. mk_interval = 0;
  490. PRINT_SET_VAL(mk_interval);
  491. break;
  492. case 3:
  493. if (mk_max_speed > dec)
  494. mk_max_speed -= dec;
  495. else
  496. mk_max_speed = 0;
  497. PRINT_SET_VAL(mk_max_speed);
  498. break;
  499. case 4:
  500. if (mk_time_to_max > dec)
  501. mk_time_to_max -= dec;
  502. else
  503. mk_time_to_max = 0;
  504. PRINT_SET_VAL(mk_time_to_max);
  505. break;
  506. case 5:
  507. if (mk_wheel_max_speed > dec)
  508. mk_wheel_max_speed -= dec;
  509. else
  510. mk_wheel_max_speed = 0;
  511. PRINT_SET_VAL(mk_wheel_max_speed);
  512. break;
  513. case 6:
  514. if (mk_wheel_time_to_max > dec)
  515. mk_wheel_time_to_max -= dec;
  516. else
  517. mk_wheel_time_to_max = 0;
  518. PRINT_SET_VAL(mk_wheel_time_to_max);
  519. break;
  520. }
  521. }
  522. static void mousekey_console_help(void)
  523. {
  524. print("\n\n----- Mousekey Parameters Help -----\n");
  525. print("ESC/q: quit\n");
  526. print("1: select mk_delay(*10ms)\n");
  527. print("2: select mk_interval(ms)\n");
  528. print("3: select mk_max_speed\n");
  529. print("4: select mk_time_to_max\n");
  530. print("5: select mk_wheel_max_speed\n");
  531. print("6: select mk_wheel_time_to_max\n");
  532. print("p: print prameters\n");
  533. print("d: set default values\n");
  534. print("up: increase prameters(+1)\n");
  535. print("down: decrease prameters(-1)\n");
  536. print("pgup: increase prameters(+10)\n");
  537. print("pgdown: decrease prameters(-10)\n");
  538. print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
  539. print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
  540. print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");
  541. print("See http://en.wikipedia.org/wiki/Mouse_keys\n");
  542. }
  543. static bool mousekey_console(uint8_t code)
  544. {
  545. switch (code) {
  546. case KC_H:
  547. case KC_SLASH: /* ? */
  548. mousekey_console_help();
  549. break;
  550. case KC_Q:
  551. case KC_ESC:
  552. mousekey_param = 0;
  553. print("\nQuit Mousekey Console\n");
  554. print("C> ");
  555. command_state = CONSOLE;
  556. return false;
  557. case KC_P:
  558. mousekey_param_print();
  559. break;
  560. case KC_1:
  561. case KC_2:
  562. case KC_3:
  563. case KC_4:
  564. case KC_5:
  565. case KC_6:
  566. case KC_7:
  567. case KC_8:
  568. case KC_9:
  569. case KC_0:
  570. mousekey_param = numkey2num(code);
  571. print("selected parameter: "); pdec(mousekey_param); print("\n");
  572. break;
  573. case KC_UP:
  574. mousekey_param_inc(mousekey_param, 1);
  575. break;
  576. case KC_DOWN:
  577. mousekey_param_dec(mousekey_param, 1);
  578. break;
  579. case KC_PGUP:
  580. mousekey_param_inc(mousekey_param, 10);
  581. break;
  582. case KC_PGDN:
  583. mousekey_param_dec(mousekey_param, 10);
  584. break;
  585. case KC_D:
  586. mk_delay = MOUSEKEY_DELAY/10;
  587. mk_interval = MOUSEKEY_INTERVAL;
  588. mk_max_speed = MOUSEKEY_MAX_SPEED;
  589. mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
  590. mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
  591. mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
  592. print("set default values.\n");
  593. break;
  594. default:
  595. print("?");
  596. return false;
  597. }
  598. print("M"); pdec(mousekey_param); print("> ");
  599. return true;
  600. }
  601. #endif
  602. /***********************************************************
  603. * Utilities
  604. ***********************************************************/
  605. static uint8_t numkey2num(uint8_t code)
  606. {
  607. switch (code) {
  608. case KC_1: return 1;
  609. case KC_2: return 2;
  610. case KC_3: return 3;
  611. case KC_4: return 4;
  612. case KC_5: return 5;
  613. case KC_6: return 6;
  614. case KC_7: return 7;
  615. case KC_8: return 8;
  616. case KC_9: return 9;
  617. case KC_0: return 0;
  618. }
  619. return 0;
  620. }
  621. static void switch_default_layer(uint8_t layer)
  622. {
  623. print("switch_default_layer: "); print_dec(biton32(default_layer_state));
  624. print(" to "); print_dec(layer); print("\n");
  625. default_layer_set(1UL<<layer);
  626. clear_keyboard();
  627. }