diff options
-rw-r--r-- | layouts/community/ergodox/coderkun_neo2/keymap.c | 28 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 6 | ||||
-rw-r--r-- | quantum/quantum.c | 62 | ||||
-rw-r--r-- | quantum/quantum.h | 8 | ||||
-rw-r--r-- | quantum/send_string.c | 56 | ||||
-rw-r--r-- | quantum/send_string.h | 9 |
6 files changed, 66 insertions, 103 deletions
diff --git a/layouts/community/ergodox/coderkun_neo2/keymap.c b/layouts/community/ergodox/coderkun_neo2/keymap.c index a6fe61079..638442676 100644 --- a/layouts/community/ergodox/coderkun_neo2/keymap.c +++ b/layouts/community/ergodox/coderkun_neo2/keymap.c | |||
@@ -269,31 +269,3 @@ void unicode_input_start (void) { | |||
269 | unregister_code(KC_LSFT); | 269 | unregister_code(KC_LSFT); |
270 | unregister_code(KC_LCTL); | 270 | unregister_code(KC_LCTL); |
271 | }; | 271 | }; |
272 | |||
273 | // Override method to use NEO_A instead of KC_A | ||
274 | uint16_t hex_to_keycode(uint8_t hex) | ||
275 | { | ||
276 | if(hex == 0x0) { | ||
277 | return KC_0; | ||
278 | } | ||
279 | else if(hex >= 0xA) { | ||
280 | switch(hex) { | ||
281 | case 0xA: | ||
282 | return NEO_A; | ||
283 | case 0xB: | ||
284 | return NEO_B; | ||
285 | case 0xC: | ||
286 | return NEO_C; | ||
287 | case 0xD: | ||
288 | return NEO_D; | ||
289 | case 0xE: | ||
290 | return NEO_E; | ||
291 | case 0xF: | ||
292 | return NEO_F; | ||
293 | default: | ||
294 | return KC_NO; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | return KC_1 + (hex - 0x1); | ||
299 | } | ||
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index bac9fbcc0..46fcaaa86 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
@@ -158,7 +158,7 @@ __attribute__((weak)) void unicode_input_cancel(void) { | |||
158 | void register_hex(uint16_t hex) { | 158 | void register_hex(uint16_t hex) { |
159 | for (int i = 3; i >= 0; i--) { | 159 | for (int i = 3; i >= 0; i--) { |
160 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | 160 | uint8_t digit = ((hex >> (i * 4)) & 0xF); |
161 | tap_code16(hex_to_keycode(digit)); | 161 | send_nibble(digit); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
@@ -171,10 +171,10 @@ void register_hex32(uint32_t hex) { | |||
171 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | 171 | uint8_t digit = ((hex >> (i * 4)) & 0xF); |
172 | if (digit == 0) { | 172 | if (digit == 0) { |
173 | if (!onzerostart) { | 173 | if (!onzerostart) { |
174 | tap_code16(hex_to_keycode(digit)); | 174 | send_nibble(digit); |
175 | } | 175 | } |
176 | } else { | 176 | } else { |
177 | tap_code16(hex_to_keycode(digit)); | 177 | send_nibble(digit); |
178 | onzerostart = false; | 178 | onzerostart = false; |
179 | } | 179 | } |
180 | } | 180 | } |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 80c4e8f00..b40b40544 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -340,34 +340,6 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ | |||
340 | 340 | ||
341 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } | 341 | void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); } |
342 | 342 | ||
343 | void tap_random_base64(void) { | ||
344 | #if defined(__AVR_ATmega32U4__) | ||
345 | uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64; | ||
346 | #else | ||
347 | uint8_t key = rand() % 64; | ||
348 | #endif | ||
349 | switch (key) { | ||
350 | case 0 ... 25: | ||
351 | send_char(key + 'A'); | ||
352 | break; | ||
353 | case 26 ... 51: | ||
354 | send_char(key - 26 + 'a'); | ||
355 | break; | ||
356 | case 52: | ||
357 | send_char('0'); | ||
358 | break; | ||
359 | case 53 ... 61: | ||
360 | send_char(key - 53 + '1'); | ||
361 | break; | ||
362 | case 62: | ||
363 | send_char('+'); | ||
364 | break; | ||
365 | case 63: | ||
366 | send_char('/'); | ||
367 | break; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | void matrix_init_quantum() { | 343 | void matrix_init_quantum() { |
372 | #ifdef BOOTMAGIC_LITE | 344 | #ifdef BOOTMAGIC_LITE |
373 | bootmagic_lite(); | 345 | bootmagic_lite(); |
@@ -469,40 +441,6 @@ void matrix_scan_quantum() { | |||
469 | # include "hd44780.h" | 441 | # include "hd44780.h" |
470 | #endif | 442 | #endif |
471 | 443 | ||
472 | // Functions for spitting out values | ||
473 | // | ||
474 | |||
475 | void send_dword(uint32_t number) { | ||
476 | uint16_t word = (number >> 16); | ||
477 | send_word(word); | ||
478 | send_word(number & 0xFFFFUL); | ||
479 | } | ||
480 | |||
481 | void send_word(uint16_t number) { | ||
482 | uint8_t byte = number >> 8; | ||
483 | send_byte(byte); | ||
484 | send_byte(number & 0xFF); | ||
485 | } | ||
486 | |||
487 | void send_byte(uint8_t number) { | ||
488 | uint8_t nibble = number >> 4; | ||
489 | send_nibble(nibble); | ||
490 | send_nibble(number & 0xF); | ||
491 | } | ||
492 | |||
493 | void send_nibble(uint8_t number) { tap_code16(hex_to_keycode(number)); } | ||
494 | |||
495 | __attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) { | ||
496 | hex = hex & 0xF; | ||
497 | if (hex == 0x0) { | ||
498 | return KC_0; | ||
499 | } else if (hex < 0xA) { | ||
500 | return KC_1 + (hex - 0x1); | ||
501 | } else { | ||
502 | return KC_A + (hex - 0xA); | ||
503 | } | ||
504 | } | ||
505 | |||
506 | void api_send_unicode(uint32_t unicode) { | 444 | void api_send_unicode(uint32_t unicode) { |
507 | #ifdef API_ENABLE | 445 | #ifdef API_ENABLE |
508 | uint8_t chunk[4]; | 446 | uint8_t chunk[4]; |
diff --git a/quantum/quantum.h b/quantum/quantum.h index b1600dd72..e24a4c43a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -238,8 +238,6 @@ layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_ | |||
238 | 238 | ||
239 | void set_single_persistent_default_layer(uint8_t default_layer); | 239 | void set_single_persistent_default_layer(uint8_t default_layer); |
240 | 240 | ||
241 | void tap_random_base64(void); | ||
242 | |||
243 | #define IS_LAYER_ON(layer) layer_state_is(layer) | 241 | #define IS_LAYER_ON(layer) layer_state_is(layer) |
244 | #define IS_LAYER_OFF(layer) !layer_state_is(layer) | 242 | #define IS_LAYER_OFF(layer) !layer_state_is(layer) |
245 | 243 | ||
@@ -276,12 +274,6 @@ void register_code16(uint16_t code); | |||
276 | void unregister_code16(uint16_t code); | 274 | void unregister_code16(uint16_t code); |
277 | void tap_code16(uint16_t code); | 275 | void tap_code16(uint16_t code); |
278 | 276 | ||
279 | void send_dword(uint32_t number); | ||
280 | void send_word(uint16_t number); | ||
281 | void send_byte(uint8_t number); | ||
282 | void send_nibble(uint8_t number); | ||
283 | uint16_t hex_to_keycode(uint8_t hex); | ||
284 | |||
285 | void led_set_user(uint8_t usb_led); | 277 | void led_set_user(uint8_t usb_led); |
286 | void led_set_kb(uint8_t usb_led); | 278 | void led_set_kb(uint8_t usb_led); |
287 | bool led_update_user(led_t led_state); | 279 | bool led_update_user(led_t led_state); |
diff --git a/quantum/send_string.c b/quantum/send_string.c index 0e8902ca3..7d096b427 100644 --- a/quantum/send_string.c +++ b/quantum/send_string.c | |||
@@ -249,4 +249,58 @@ void send_char(char ascii_code) { | |||
249 | if (is_dead) { | 249 | if (is_dead) { |
250 | tap_code(KC_SPACE); | 250 | tap_code(KC_SPACE); |
251 | } | 251 | } |
252 | } \ No newline at end of file | 252 | } |
253 | |||
254 | void send_dword(uint32_t number) { | ||
255 | send_word(number >> 16); | ||
256 | send_word(number & 0xFFFFUL); | ||
257 | } | ||
258 | |||
259 | void send_word(uint16_t number) { | ||
260 | send_byte(number >> 8); | ||
261 | send_byte(number & 0xFF); | ||
262 | } | ||
263 | |||
264 | void send_byte(uint8_t number) { | ||
265 | send_nibble(number >> 4); | ||
266 | send_nibble(number & 0xF); | ||
267 | } | ||
268 | |||
269 | void send_nibble(uint8_t number) { | ||
270 | switch (number & 0xF) { | ||
271 | case 0 ... 9: | ||
272 | send_char(number + '0'); | ||
273 | break; | ||
274 | case 10 ... 15: | ||
275 | send_char(number - 10 + 'a'); | ||
276 | break; | ||
277 | } | ||
278 | } | ||
279 | |||
280 | void tap_random_base64(void) { | ||
281 | #if defined(__AVR_ATmega32U4__) | ||
282 | uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64; | ||
283 | #else | ||
284 | uint8_t key = rand() % 64; | ||
285 | #endif | ||
286 | switch (key) { | ||
287 | case 0 ... 25: | ||
288 | send_char(key + 'A'); | ||
289 | break; | ||
290 | case 26 ... 51: | ||
291 | send_char(key - 26 + 'a'); | ||
292 | break; | ||
293 | case 52: | ||
294 | send_char('0'); | ||
295 | break; | ||
296 | case 53 ... 61: | ||
297 | send_char(key - 53 + '1'); | ||
298 | break; | ||
299 | case 62: | ||
300 | send_char('+'); | ||
301 | break; | ||
302 | case 63: | ||
303 | send_char('/'); | ||
304 | break; | ||
305 | } | ||
306 | } | ||
diff --git a/quantum/send_string.h b/quantum/send_string.h index 570522eb0..b90e6f689 100644 --- a/quantum/send_string.h +++ b/quantum/send_string.h | |||
@@ -23,10 +23,10 @@ | |||
23 | #define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval) | 23 | #define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval) |
24 | 24 | ||
25 | // Look-Up Tables (LUTs) to convert ASCII character to keycode sequence. | 25 | // Look-Up Tables (LUTs) to convert ASCII character to keycode sequence. |
26 | extern const uint8_t ascii_to_keycode_lut[128]; | ||
27 | extern const uint8_t ascii_to_shift_lut[16]; | 26 | extern const uint8_t ascii_to_shift_lut[16]; |
28 | extern const uint8_t ascii_to_altgr_lut[16]; | 27 | extern const uint8_t ascii_to_altgr_lut[16]; |
29 | extern const uint8_t ascii_to_dead_lut[16]; | 28 | extern const uint8_t ascii_to_dead_lut[16]; |
29 | extern const uint8_t ascii_to_keycode_lut[128]; | ||
30 | 30 | ||
31 | // clang-format off | 31 | // clang-format off |
32 | #define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \ | 32 | #define KCLUT_ENTRY(a, b, c, d, e, f, g, h) \ |
@@ -45,3 +45,10 @@ void send_string_with_delay(const char *str, uint8_t interval); | |||
45 | void send_string_P(const char *str); | 45 | void send_string_P(const char *str); |
46 | void send_string_with_delay_P(const char *str, uint8_t interval); | 46 | void send_string_with_delay_P(const char *str, uint8_t interval); |
47 | void send_char(char ascii_code); | 47 | void send_char(char ascii_code); |
48 | |||
49 | void send_dword(uint32_t number); | ||
50 | void send_word(uint16_t number); | ||
51 | void send_byte(uint8_t number); | ||
52 | void send_nibble(uint8_t number); | ||
53 | |||
54 | void tap_random_base64(void); | ||