diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 24 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 1 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicodemap.c | 20 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicodemap.h | 1 |
4 files changed, 21 insertions, 25 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4ac305e66..fc392813a 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
@@ -150,6 +150,24 @@ void register_hex(uint16_t hex) { | |||
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | void register_hex32(uint32_t hex) { | ||
154 | bool onzerostart = true; | ||
155 | for (int i = 7; i >= 0; i--) { | ||
156 | if (i <= 3) { | ||
157 | onzerostart = false; | ||
158 | } | ||
159 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | ||
160 | if (digit == 0) { | ||
161 | if (!onzerostart) { | ||
162 | tap_code(hex_to_keycode(digit)); | ||
163 | } | ||
164 | } else { | ||
165 | tap_code(hex_to_keycode(digit)); | ||
166 | onzerostart = false; | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
153 | void send_unicode_hex_string(const char *str) { | 171 | void send_unicode_hex_string(const char *str) { |
154 | if (!str) { | 172 | if (!str) { |
155 | return; | 173 | return; |
@@ -192,9 +210,7 @@ const char *decode_utf8(const char *str, int32_t *code_point) { | |||
192 | *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); | 210 | *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); |
193 | next = str + 3; | 211 | next = str + 3; |
194 | } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF | 212 | } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF |
195 | // Skip for now - register_hex() only takes a uint16 | 213 | *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); |
196 | //*code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0); | ||
197 | *code_point = -1; | ||
198 | next = str + 4; | 214 | next = str + 4; |
199 | } else { | 215 | } else { |
200 | *code_point = -1; | 216 | *code_point = -1; |
@@ -221,7 +237,7 @@ void send_unicode_string(const char *str) { | |||
221 | 237 | ||
222 | if (code_point >= 0) { | 238 | if (code_point >= 0) { |
223 | unicode_input_start(); | 239 | unicode_input_start(); |
224 | register_hex(code_point); | 240 | register_hex32(code_point); |
225 | unicode_input_finish(); | 241 | unicode_input_finish(); |
226 | } | 242 | } |
227 | } | 243 | } |
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 393db2d99..13b6431bf 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h | |||
@@ -79,6 +79,7 @@ void unicode_input_finish(void); | |||
79 | void unicode_input_cancel(void); | 79 | void unicode_input_cancel(void); |
80 | 80 | ||
81 | void register_hex(uint16_t hex); | 81 | void register_hex(uint16_t hex); |
82 | void register_hex32(uint32_t hex); | ||
82 | void send_unicode_hex_string(const char *str); | 83 | void send_unicode_hex_string(const char *str); |
83 | void send_unicode_string(const char *str); | 84 | void send_unicode_string(const char *str); |
84 | 85 | ||
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 4364f156c..1be51a995 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c | |||
@@ -16,26 +16,6 @@ | |||
16 | 16 | ||
17 | #include "process_unicodemap.h" | 17 | #include "process_unicodemap.h" |
18 | 18 | ||
19 | void register_hex32(uint32_t hex) { | ||
20 | bool onzerostart = true; | ||
21 | for (int i = 7; i >= 0; i--) { | ||
22 | if (i <= 3) { | ||
23 | onzerostart = false; | ||
24 | } | ||
25 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | ||
26 | if (digit == 0) { | ||
27 | if (!onzerostart) { | ||
28 | register_code(hex_to_keycode(digit)); | ||
29 | unregister_code(hex_to_keycode(digit)); | ||
30 | } | ||
31 | } else { | ||
32 | register_code(hex_to_keycode(digit)); | ||
33 | unregister_code(hex_to_keycode(digit)); | ||
34 | onzerostart = false; | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | |||
39 | __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { | 19 | __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { |
40 | if (keycode >= QK_UNICODEMAP_PAIR) { | 20 | if (keycode >= QK_UNICODEMAP_PAIR) { |
41 | // Keycode is a pair: extract index based on Shift / Caps Lock state | 21 | // Keycode is a pair: extract index based on Shift / Caps Lock state |
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index a4b6d77f3..c429859bb 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h | |||
@@ -20,6 +20,5 @@ | |||
20 | 20 | ||
21 | extern const uint32_t PROGMEM unicode_map[]; | 21 | extern const uint32_t PROGMEM unicode_map[]; |
22 | 22 | ||
23 | void register_hex32(uint32_t hex); | ||
24 | uint16_t unicodemap_index(uint16_t keycode); | 23 | uint16_t unicodemap_index(uint16_t keycode); |
25 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record); | 24 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record); |