aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_unicodemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode/process_unicodemap.c')
-rw-r--r--quantum/process_keycode/process_unicodemap.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index 75f35112b..cee9acb5f 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -18,8 +18,7 @@
18#include "process_unicode_common.h" 18#include "process_unicode_common.h"
19 19
20__attribute__((weak)) 20__attribute__((weak))
21const uint32_t PROGMEM unicode_map[] = { 21const uint32_t PROGMEM unicode_map[] = {};
22};
23 22
24void register_hex32(uint32_t hex) { 23void register_hex32(uint32_t hex) {
25 bool onzerostart = true; 24 bool onzerostart = true;
@@ -42,26 +41,26 @@ void register_hex32(uint32_t hex) {
42} 41}
43 42
44__attribute__((weak)) 43__attribute__((weak))
45void unicode_map_input_error() {} 44void unicodemap_input_error() {}
46 45
47bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { 46bool process_unicodemap(uint16_t keycode, keyrecord_t *record) {
48 uint8_t input_mode = get_unicode_input_mode(); 47 if ((keycode & QK_UNICODEMAP) == QK_UNICODEMAP && record->event.pressed) {
49 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { 48 uint16_t index = keycode - QK_UNICODEMAP;
50 const uint32_t* map = unicode_map; 49 uint32_t code = pgm_read_dword(unicode_map + index);
51 uint16_t index = keycode - QK_UNICODE_MAP; 50 uint8_t input_mode = get_unicode_input_mode();
52 uint32_t code = pgm_read_dword(&map[index]); 51
53 if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { 52 if (code > 0xFFFF && code <= 0x10FFFF && input_mode == UC_OSX) {
54 // Convert to UTF-16 surrogate pair 53 // Convert to UTF-16 surrogate pair
55 code -= 0x10000; 54 code -= 0x10000;
56 uint32_t lo = code & 0x3ff; 55 uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10;
57 uint32_t hi = (code & 0xffc00) >> 10; 56
58 unicode_input_start(); 57 unicode_input_start();
59 register_hex32(hi + 0xd800); 58 register_hex32(hi + 0xD800);
60 register_hex32(lo + 0xdc00); 59 register_hex32(lo + 0xDC00);
61 unicode_input_finish(); 60 unicode_input_finish();
62 } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { 61 } else if ((code > 0x10FFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
63 // when character is out of range supported by the OS 62 // Character is out of range supported by the OS
64 unicode_map_input_error(); 63 unicodemap_input_error();
65 } else { 64 } else {
66 unicode_input_start(); 65 unicode_input_start();
67 register_hex32(code); 66 register_hex32(code);