]>
git.gir.st - tmk_keyboard.git/blob - 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"
31 # include "jump_bootloader.h"
32 # include "usb_keyboard.h"
33 # ifdef USB_EXTRA_ENABLE
34 # include "usb_extra.h"
39 static void help(void);
40 static void switch_layer(uint8_t layer
);
43 uint8_t command_proc(void)
48 uint8_t processed
= 1;
49 bool last_print_enable
= print_enable
;
51 switch (host_get_first_key()) {
57 host_clear_keyboard_report();
58 host_send_keyboard_report();
59 print("jump to bootloader...\n");
61 jump_bootloader(); // not return
65 debug_enable
= !debug_enable
;
67 last_print_enable
= true;
68 print("debug enabled.\n");
70 debug_keyboard
= true;
73 print("debug disabled.\n");
74 last_print_enable
= false;
76 debug_keyboard
= false;
80 case KB_X
: // debug matrix toggle
81 debug_matrix
= !debug_matrix
;
83 print("debug matrix enabled.\n");
85 print("debug matrix disabled.\n");
87 case KB_K
: // debug keyboard toggle
88 debug_keyboard
= !debug_keyboard
;
90 print("debug keyboard enabled.\n");
92 print("debug keyboard disabled.\n");
94 case KB_M
: // debug mouse toggle
95 debug_mouse
= !debug_mouse
;
97 print("debug mouse enabled.\n");
99 print("debug mouse disabled.\n");
101 case KB_V
: // print version & information
102 print(STR(DESCRIPTION
) "\n");
104 case KB_T
: // print timer
105 print("timer: "); phex16(timer_count
); print("\n");
107 case KB_P
: // print toggle
108 if (last_print_enable
) {
109 print("print disabled.\n");
110 last_print_enable
= false;
112 last_print_enable
= true;
113 print("print enabled.\n");
118 print("UDCON: "); phex(UDCON
); print("\n");
119 print("UDIEN: "); phex(UDIEN
); print("\n");
120 print("UDINT: "); phex(UDINT
); print("\n");
121 print("usb_keyboard_leds:"); phex(usb_keyboard_leds
); print("\n");
122 print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol
); print("\n");
123 print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config
); print("\n");
124 print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count
); print("\n");
127 #ifdef USB_NKRO_ENABLE
129 // send empty report before change
130 host_clear_keyboard_report();
131 host_send_keyboard_report();
132 keyboard_nkro
= !keyboard_nkro
;
134 print("USB_NKRO: enabled\n");
136 print("USB_NKRO: disabled\n");
139 #ifdef USB_EXTRA_ENABLE
141 host_clear_keyboard_report();
142 host_send_keyboard_report();
144 if (suspend
&& remote_wakeup
) {
147 host_system_send(SYSTEM_POWER_DOWN
);
152 host_system_send(SYSTEM_POWER_DOWN
);
160 print("clear matrix\n");
182 print_enable
= last_print_enable
;
186 static void help(void)
188 print("b: jump to bootloader\n");
189 print("d: toggle debug enable\n");
190 print("x: toggle matrix debug\n");
191 print("k: toggle keyboard debug\n");
192 print("m: toggle mouse debug\n");
193 print("p: toggle print enable\n");
194 print("v: print version\n");
195 print("t: print timer count\n");
196 print("s: print status\n");
197 #ifdef USB_NKRO_ENABLE
198 print("n: toggle USB_NKRO\n");
200 print("Backspace: clear matrix\n");
201 print("ESC: power down/wake up\n");
202 print("0: switch to Layer0 \n");
203 print("1: switch to Layer1 \n");
204 print("2: switch to Layer2 \n");
205 print("3: switch to Layer3 \n");
206 print("4: switch to Layer4 \n");
209 static void switch_layer(uint8_t layer
)
211 print("current_layer: "); phex(current_layer
); print("\n");
212 print("default_layer: "); phex(default_layer
); print("\n");
213 current_layer
= layer
;
214 default_layer
= layer
;
215 print("switch to Layer: "); phex(layer
); print("\n");