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 a6fe61079d..638442676a 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) { unregister_code(KC_LSFT); unregister_code(KC_LCTL); }; - -// Override method to use NEO_A instead of KC_A -uint16_t hex_to_keycode(uint8_t hex) -{ - if(hex == 0x0) { - return KC_0; - } - else if(hex >= 0xA) { - switch(hex) { - case 0xA: - return NEO_A; - case 0xB: - return NEO_B; - case 0xC: - return NEO_C; - case 0xD: - return NEO_D; - case 0xE: - return NEO_E; - case 0xF: - return NEO_F; - default: - return KC_NO; - } - } - - return KC_1 + (hex - 0x1); -} diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index bac9fbcc0f..46fcaaa86b 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) { void register_hex(uint16_t hex) { for (int i = 3; i >= 0; i--) { uint8_t digit = ((hex >> (i * 4)) & 0xF); - tap_code16(hex_to_keycode(digit)); + send_nibble(digit); } } @@ -171,10 +171,10 @@ void register_hex32(uint32_t hex) { uint8_t digit = ((hex >> (i * 4)) & 0xF); if (digit == 0) { if (!onzerostart) { - tap_code16(hex_to_keycode(digit)); + send_nibble(digit); } } else { - tap_code16(hex_to_keycode(digit)); + send_nibble(digit); onzerostart = false; } } diff --git a/quantum/quantum.c b/quantum/quantum.c index 80c4e8f00c..b40b40544a 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_ 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)); } -void tap_random_base64(void) { -#if defined(__AVR_ATmega32U4__) - uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64; -#else - uint8_t key = rand() % 64; -#endif - switch (key) { - case 0 ... 25: - send_char(key + 'A'); - break; - case 26 ... 51: - send_char(key - 26 + 'a'); - break; - case 52: - send_char('0'); - break; - case 53 ... 61: - send_char(key - 53 + '1'); - break; - case 62: - send_char('+'); - break; - case 63: - send_char('/'); - break; - } -} - void matrix_init_quantum() { #ifdef BOOTMAGIC_LITE bootmagic_lite(); @@ -469,40 +441,6 @@ void matrix_scan_quantum() { # include "hd44780.h" #endif -// Functions for spitting out values -// - -void send_dword(uint32_t number) { - uint16_t word = (number >> 16); - send_word(word); - send_word(number & 0xFFFFUL); -} - -void send_word(uint16_t number) { - uint8_t byte = number >> 8; - send_byte(byte); - send_byte(number & 0xFF); -} - -void send_byte(uint8_t number) { - uint8_t nibble = number >> 4; - send_nibble(nibble); - send_nibble(number & 0xF); -} - -void send_nibble(uint8_t number) { tap_code16(hex_to_keycode(number)); } - -__attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) { - hex = hex & 0xF; - if (hex == 0x0) { - return KC_0; - } else if (hex < 0xA) { - return KC_1 + (hex - 0x1); - } else { - return KC_A + (hex - 0xA); - } -} - void api_send_unicode(uint32_t unicode) { #ifdef API_ENABLE uint8_t chunk[4]; diff --git a/quantum/quantum.h b/quantum/quantum.h index b1600dd724..e24a4c43a3 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_ void set_single_persistent_default_layer(uint8_t default_layer); -void tap_random_base64(void); - #define IS_LAYER_ON(layer) layer_state_is(layer) #define IS_LAYER_OFF(layer) !layer_state_is(layer) @@ -276,12 +274,6 @@ void register_code16(uint16_t code); void unregister_code16(uint16_t code); void tap_code16(uint16_t code); -void send_dword(uint32_t number); -void send_word(uint16_t number); -void send_byte(uint8_t number); -void send_nibble(uint8_t number); -uint16_t hex_to_keycode(uint8_t hex); - void led_set_user(uint8_t usb_led); void led_set_kb(uint8_t usb_led); bool led_update_user(led_t led_state); diff --git a/quantum/send_string.c b/quantum/send_string.c index 0e8902ca3f..7d096b4273 100644 --- a/quantum/send_string.c +++ b/quantum/send_string.c @@ -249,4 +249,58 @@ void send_char(char ascii_code) { if (is_dead) { tap_code(KC_SPACE); } -}
\ No newline at end of file +} + +void send_dword(uint32_t number) { + send_word(number >> 16); + send_word(number & 0xFFFFUL); +} + +void send_word(uint16_t number) { + send_byte(number >> 8); + send_byte(number & 0xFF); +} + +void send_byte(uint8_t number) { + send_nibble(number >> 4); + send_nibble(number & 0xF); +} + +void send_nibble(uint8_t number) { + switch (number & 0xF) { + case 0 ... 9: + send_char(number + '0'); + break; + case 10 ... 15: + send_char(number - 10 + 'a'); + break; + } +} + +void tap_random_base64(void) { +#if defined(__AVR_ATmega32U4__) + uint8_t key = (TCNT0 + TCNT1 + TCNT3 + TCNT4) % 64; +#else + uint8_t key = rand() % 64; +#endif + switch (key) { + case 0 ... 25: + send_char(key + 'A'); + break; + case 26 ... 51: + send_char(key - 26 + 'a'); + break; + case 52: + send_char('0'); + break; + case 53 ... 61: + send_char(key - 53 + '1'); + break; + case 62: + send_char('+'); + break; + case 63: + send_char('/'); + break; + } +} diff --git a/quantum/send_string.h b/quantum/send_string.h index 570522eb0e..b90e6f6890 100644 --- a/quantum/send_string.h +++ b/quantum/send_string.h @@ -23,10 +23,10 @@ #define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval) // Look-Up Tables (LUTs) to convert ASCII character to keycode sequence. -extern const uint8_t ascii_to_keycode_lut[128]; extern const uint8_t ascii_to_shift_lut[16]; extern const uint8_t ascii_to_altgr_lut[16]; extern const uint8_t ascii_to_dead_lut[16]; +extern const uint8_t ascii_to_keycode_lut[128]; // clang-format off #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); void send_string_P(const char *str); void send_string_with_delay_P(const char *str, uint8_t interval); void send_char(char ascii_code); + +void send_dword(uint32_t number); +void send_word(uint16_t number); +void send_byte(uint8_t number); +void send_nibble(uint8_t number); + +void tap_random_base64(void); |