]>
git.gir.st - tmk_keyboard.git/blob - common/command.c
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>
20 #include "usb_keycodes.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 host_clear_keyboard_report();
82 host_send_keyboard_report();
83 print("jump to bootloader... ");
85 bootloader_jump(); // not return
86 print("not supported.\n");
89 debug_enable
= !debug_enable
;
91 last_print_enable
= true;
92 print("debug enabled.\n");
94 debug_keyboard
= true;
97 print("debug disabled.\n");
98 last_print_enable
= false;
100 debug_keyboard
= false;
104 case KB_X
: // debug matrix toggle
105 debug_matrix
= !debug_matrix
;
107 print("debug matrix enabled.\n");
109 print("debug matrix disabled.\n");
111 case KB_K
: // debug keyboard toggle
112 debug_keyboard
= !debug_keyboard
;
114 print("debug keyboard enabled.\n");
116 print("debug keyboard disabled.\n");
118 case KB_M
: // debug mouse toggle
119 debug_mouse
= !debug_mouse
;
121 print("debug mouse enabled.\n");
123 print("debug mouse disabled.\n");
125 case KB_V
: // print version & information
126 print(STR(DESCRIPTION
) "\n");
128 case KB_T
: // print timer
129 print("timer: "); phex16(timer_count
); print("\n");
131 case KB_P
: // print toggle
132 if (last_print_enable
) {
133 print("print disabled.\n");
134 last_print_enable
= false;
136 last_print_enable
= true;
137 print("print enabled.\n");
141 print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n");
143 print("UDCON: "); phex(UDCON
); print("\n");
144 print("UDIEN: "); phex(UDIEN
); print("\n");
145 print("UDINT: "); phex(UDINT
); print("\n");
146 print("usb_keyboard_leds:"); phex(usb_keyboard_leds
); print("\n");
147 print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol
); print("\n");
148 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config
); print("\n");
149 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count
); print("\n");
154 print("usbSofCount: "); phex(usbSofCount
); print("\n");
160 // send empty report before change
161 host_clear_keyboard_report();
162 host_send_keyboard_report();
163 keyboard_nkro
= !keyboard_nkro
;
165 print("NKRO: enabled\n");
167 print("NKRO: disabled\n");
170 #ifdef EXTRAKEY_ENABLE
172 host_clear_keyboard_report();
173 host_send_keyboard_report();
175 if (suspend
&& remote_wakeup
) {
178 host_system_send(SYSTEM_POWER_DOWN
);
183 host_system_send(SYSTEM_POWER_DOWN
);
191 print("clear matrix\n");
214 static void help(void)
216 print("b: jump to bootloader\n");
217 print("d: toggle debug enable\n");
218 print("x: toggle matrix debug\n");
219 print("k: toggle keyboard debug\n");
220 print("m: toggle mouse debug\n");
221 print("p: toggle print enable\n");
222 print("v: print version\n");
223 print("t: print timer count\n");
224 print("s: print status\n");
226 print("n: toggle NKRO\n");
228 print("Backspace: clear matrix\n");
229 print("ESC: power down/wake up\n");
230 print("0: switch to Layer0 \n");
231 print("1: switch to Layer1 \n");
232 print("2: switch to Layer2 \n");
233 print("3: switch to Layer3 \n");
234 print("4: switch to Layer4 \n");
237 static void switch_layer(uint8_t layer
)
239 print("current_layer: "); phex(current_layer
); print("\n");
240 print("default_layer: "); phex(default_layer
); print("\n");
241 current_layer
= layer
;
242 default_layer
= layer
;
243 print("switch to Layer: "); phex(layer
); print("\n");