2 Copyright 2011 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <util/delay.h>
28 #include "bootloader.h"
32 # include "usb_keyboard.h"
33 # ifdef EXTRAKEY_ENABLE
34 # include "usb_extra.h"
43 static uint8_t command_common(void);
44 static void help(void);
45 static void switch_layer(uint8_t layer);
47 static bool last_print_enable;
49 uint8_t command_proc(void)
51 uint8_t processed = 0;
52 last_print_enable = print_enable;
58 if (command_extra() || command_common()) {
62 print_enable = last_print_enable;
66 /* This allows to define extra commands. return 0 when not processed. */
67 uint8_t command_extra(void) __attribute__ ((weak));
68 uint8_t command_extra(void)
74 static uint8_t command_common(void)
76 switch (host_get_first_key()) {
81 print("jump to bootloader... ");
83 bootloader_jump(); // not return
84 print("not supported.\n");
87 debug_enable = !debug_enable;
89 last_print_enable = true;
90 print("debug enabled.\n");
92 debug_keyboard = true;
95 print("debug disabled.\n");
96 last_print_enable = false;
98 debug_keyboard = false;
102 case KC_X: // debug matrix toggle
103 debug_matrix = !debug_matrix;
105 print("debug matrix enabled.\n");
107 print("debug matrix disabled.\n");
109 case KC_K: // debug keyboard toggle
110 debug_keyboard = !debug_keyboard;
112 print("debug keyboard enabled.\n");
114 print("debug keyboard disabled.\n");
116 case KC_M: // debug mouse toggle
117 debug_mouse = !debug_mouse;
119 print("debug mouse enabled.\n");
121 print("debug mouse disabled.\n");
123 case KC_V: // print version & information
124 print(STR(DESCRIPTION) "\n");
126 case KC_T: // print timer
127 print("timer: "); phex16(timer_count); print("\n");
129 case KC_P: // print toggle
130 if (last_print_enable) {
131 print("print disabled.\n");
132 last_print_enable = false;
134 last_print_enable = true;
135 print("print enabled.\n");
139 print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n");
141 print("UDCON: "); phex(UDCON); print("\n");
142 print("UDIEN: "); phex(UDIEN); print("\n");
143 print("UDINT: "); phex(UDINT); print("\n");
144 print("usb_keyboard_leds:"); phex(usb_keyboard_leds); print("\n");
145 print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol); print("\n");
146 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n");
147 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n");
152 print("usbSofCount: "); phex(usbSofCount); print("\n");
158 keyboard_nkro = !keyboard_nkro;
160 print("NKRO: enabled\n");
162 print("NKRO: disabled\n");
165 #ifdef EXTRAKEY_ENABLE
168 if (suspend && remote_wakeup) {
171 host_system_send(SYSTEM_POWER_DOWN);
176 host_system_send(SYSTEM_POWER_DOWN);
184 print("clear matrix\n");
207 static void help(void)
209 print("b: jump to bootloader\n");
210 print("d: toggle debug enable\n");
211 print("x: toggle matrix debug\n");
212 print("k: toggle keyboard debug\n");
213 print("m: toggle mouse debug\n");
214 print("p: toggle print enable\n");
215 print("v: print version\n");
216 print("t: print timer count\n");
217 print("s: print status\n");
219 print("n: toggle NKRO\n");
221 print("Backspace: clear matrix\n");
222 print("ESC: power down/wake up\n");
223 print("0: switch to Layer0 \n");
224 print("1: switch to Layer1 \n");
225 print("2: switch to Layer2 \n");
226 print("3: switch to Layer3 \n");
227 print("4: switch to Layer4 \n");
230 static void switch_layer(uint8_t layer)
232 print("current_layer: "); phex(current_layer); print("\n");
233 print("default_layer: "); phex(default_layer); print("\n");
234 current_layer = layer;
235 default_layer = layer;
236 print("switch to Layer: "); phex(layer); print("\n");