diff options
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.c')
-rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 24 |
1 files changed, 20 insertions, 4 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 | } |