aboutsummaryrefslogtreecommitdiff
path: root/keyboards/comet46/lib/keylogger.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/comet46/lib/keylogger.c')
-rw-r--r--keyboards/comet46/lib/keylogger.c288
1 files changed, 288 insertions, 0 deletions
diff --git a/keyboards/comet46/lib/keylogger.c b/keyboards/comet46/lib/keylogger.c
new file mode 100644
index 000000000..a0abdd79a
--- /dev/null
+++ b/keyboards/comet46/lib/keylogger.c
@@ -0,0 +1,288 @@
1#include <stdio.h>
2#include "progmem.h"
3
4#define NUM_USB_HID_KEYCODES 255
5#define LEN_KEYCODE_STR 4
6
7char keylog[22] = {"KC: ID: "};
8
9// Quick and dirty way to display USB HID keycodes used in QMK
10// USB HID keycodes from 0x0000 to 0x00FF are stored in a 4x256+1 length char
11const char code_to_name[] PROGMEM = {
12 "NO " //0x00
13 "TRNS"
14 "? "
15 "? "
16 "A "
17 "B "
18 "C "
19 "D "
20 "E "
21 "F "
22 "G "
23 "H "
24 "I "
25 "J "
26 "K "
27 "L "
28 "M " //0x10
29 "N "
30 "O "
31 "P "
32 "Q "
33 "R "
34 "S "
35 "T "
36 "U "
37 "V "
38 "W "
39 "X "
40 "Y "
41 "Z "
42 "1 "
43 "2 "
44 "3 " //0x20
45 "4 "
46 "5 "
47 "6 "
48 "7 "
49 "8 "
50 "9 "
51 "0 "
52 "ENT "
53 "ESC "
54 "BSPC"
55 "TAB "
56 "SPC "
57 "MINS"
58 "EQL "
59 "LBRC"
60 "RBRC" //0x30
61 "BSLS"
62 "NUHS"
63 "SCLN"
64 "QUOT"
65 "GRV "
66 "COMM"
67 "DOT "
68 "SLSH"
69 "CAPS"
70 "F1 "
71 "F2 "
72 "F3 "
73 "F4 "
74 "F5 "
75 "F6 "
76 "F7 " //0x40
77 "F8 "
78 "F9 "
79 "F10 "
80 "F11 "
81 "F12 "
82 "PSCR"
83 "SLCK"
84 "PAUS"
85 "INS "
86 "HOME"
87 "PGUP"
88 "DEL "
89 "END "
90 "PGDN"
91 "RGHT"
92 "LEFT" //0x50
93 "DOWN"
94 "UP "
95 "NLCK"
96 "PSLS"
97 "PAST"
98 "PMNS"
99 "PPLS"
100 "PENT"
101 "P1 "
102 "P2 "
103 "P3 "
104 "P4 "
105 "P5 "
106 "P6 "
107 "P7 "
108 "P8 " //0x60
109 "P9 "
110 "P0 "
111 "PDOT"
112 "NUBS"
113 "APP "
114 "POW "
115 "PEQL"
116 "F13 "
117 "F14 "
118 "F15 "
119 "F16 "
120 "F17 "
121 "F18 "
122 "F19 "
123 "F20 "
124 "F21 " //0x70
125 "F22 "
126 "F23 "
127 "F24 "
128 "EXEC"
129 "HELP"
130 "MENU"
131 "SLCT"
132 "STOP"
133 "AGIN"
134 "UNDO"
135 "CUT "
136 "COPY"
137 "PSTE"
138 "FIND"
139 "_MUT"
140 "_VUP" //0x80
141 "_VDN"
142 "LCAP"
143 "LNUM"
144 "LSCR"
145 "PCMM"
146 "PEQA"
147 "INT1"
148 "INT2"
149 "INT3"
150 "INT4"
151 "INT5"
152 "INT6"
153 "INT7"
154 "INT8"
155 "INT9"
156 "LAN1" //0x90
157 "LAN2"
158 "LAN3"
159 "LAN4"
160 "LAN5"
161 "LAN6"
162 "LAN7"
163 "LAN8"
164 "LAN9"
165 "ERAS"
166 "SYSR"
167 "CNCL"
168 "CLR "
169 "PRIR"
170 "RTRN"
171 "SEP "
172 "OUT " //0xA0
173 "OPER"
174 "CLRA"
175 "CSEL"
176 "ESEL"
177 "PWR " //0xA5
178 "SLEP"
179 "WAKE"
180 "MUTE"
181 "VOLU"
182 "VOLD"
183 "MNXT"
184 "MPRV"
185 "MSTP"
186 "MPLY"
187 "MSEL"
188 "EJCT" //0xB0
189 "MAIL"
190 "CALC"
191 "MYCM"
192 "WSCH"
193 "WHOM"
194 "WBAK"
195 "WFWD"
196 "WSTP"
197 "WREF"
198 "WFAV"
199 "MFFD"
200 "MRWD"
201 "BRIU"
202 "BRID"
203 "? "
204 "FN0 " //0xC0
205 "FN1 "
206 "FN2 "
207 "FN3 "
208 "FN4 "
209 "FN5 "
210 "FN6 "
211 "FN7 "
212 "FN8 "
213 "FN9 "
214 "FN10"
215 "FN11"
216 "FN12"
217 "FN13"
218 "FN14"
219 "FN15"
220 "FN16" //0xD0
221 "FN17"
222 "FN18"
223 "FN19"
224 "FN20"
225 "FN21"
226 "FN22"
227 "FN23"
228 "FN24"
229 "FN25"
230 "FN26"
231 "FN27"
232 "FN28"
233 "FN29"
234 "FN30"
235 "FN31"
236 "LCTL" //0xE0
237 "LSFT"
238 "LALT"
239 "LGUI"
240 "RCTL"
241 "RSFT"
242 "RALT"
243 "RGUI"
244 "? "
245 "? "
246 "? "
247 "? "
248 "? "
249 "? "
250 "? "
251 "? "
252 "MS_U" //0xF0
253 "MS_D"
254 "MS_L"
255 "MS_R"
256 "BTN1"
257 "BTN2"
258 "BTN3"
259 "BTN4"
260 "BTN5"
261 "WH_U"
262 "WH_D"
263 "WH_L"
264 "WH_R"
265 "ACL0"
266 "ACL1"
267 "ACL2"
268};
269
270void set_keylog(uint16_t keycode)
271{
272 char name[LEN_KEYCODE_STR+1] = "? ";
273
274 if (keycode <= NUM_USB_HID_KEYCODES) {
275 for (uint8_t k = 0; k < LEN_KEYCODE_STR; k++) {
276 name[k] = pgm_read_byte_near(code_to_name + keycode * LEN_KEYCODE_STR + k);
277 }
278 } else if (keycode > NUM_USB_HID_KEYCODES) {
279 snprintf(name, sizeof(name), "QMK ");
280 }
281
282 // update keylog
283 snprintf(keylog, sizeof(keylog), "KC: %s ID: %d", name, keycode);
284}
285
286const char *read_keylog(void) {
287 return keylog;
288}