diff options
author | Jason Laqua <jlaqua118@gmail.com> | 2020-06-18 02:07:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 08:07:34 +0100 |
commit | f7eb030e917a8fa360ad7cc7bb26d804cf4c5f6c (patch) | |
tree | 8415ddb70ed9fa1cfea2651a6ef950483648d851 /quantum/process_keycode/process_unicodemap.c | |
parent | aae1814319c4992471d074ed18b8b7b4842b0a66 (diff) | |
download | qmk_firmware-f7eb030e917a8fa360ad7cc7bb26d804cf4c5f6c.tar.gz qmk_firmware-f7eb030e917a8fa360ad7cc7bb26d804cf4c5f6c.zip |
Standardize how unicode is processed (fixes #8768) (#8770)
Co-authored-by: Konstantin Đorđević <vomindoraan@gmail.com>
Diffstat (limited to 'quantum/process_keycode/process_unicodemap.c')
-rw-r--r-- | quantum/process_keycode/process_unicodemap.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 2f402a2fd..789a90445 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c | |||
@@ -36,25 +36,8 @@ __attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) { | |||
36 | 36 | ||
37 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record) { | 37 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record) { |
38 | if (keycode >= QK_UNICODEMAP && keycode <= QK_UNICODEMAP_PAIR_MAX && record->event.pressed) { | 38 | if (keycode >= QK_UNICODEMAP && keycode <= QK_UNICODEMAP_PAIR_MAX && record->event.pressed) { |
39 | unicode_input_start(); | 39 | uint32_t code_point = pgm_read_dword(unicode_map + unicodemap_index(keycode)); |
40 | 40 | register_unicode(code_point); | |
41 | uint32_t code = pgm_read_dword(unicode_map + unicodemap_index(keycode)); | ||
42 | uint8_t input_mode = get_unicode_input_mode(); | ||
43 | |||
44 | if (code > 0x10FFFF || (code > 0xFFFF && input_mode == UC_WIN)) { | ||
45 | // Character is out of range supported by the platform | ||
46 | unicode_input_cancel(); | ||
47 | } else if (code > 0xFFFF && input_mode == UC_MAC) { | ||
48 | // Convert to UTF-16 surrogate pair on Mac | ||
49 | code -= 0x10000; | ||
50 | uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10; | ||
51 | register_hex32(hi + 0xD800); | ||
52 | register_hex32(lo + 0xDC00); | ||
53 | unicode_input_finish(); | ||
54 | } else { | ||
55 | register_hex32(code); | ||
56 | unicode_input_finish(); | ||
57 | } | ||
58 | } | 41 | } |
59 | return true; | 42 | return true; |
60 | } | 43 | } |