diff options
Diffstat (limited to 'quantum/process_keycode/process_unicode.c')
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 6a30afe29..cd3a610b4 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
@@ -42,6 +42,11 @@ void unicode_input_start (void) { | |||
42 | register_code(KC_PPLS); | 42 | register_code(KC_PPLS); |
43 | unregister_code(KC_PPLS); | 43 | unregister_code(KC_PPLS); |
44 | break; | 44 | break; |
45 | case UC_WINC: | ||
46 | register_code(KC_RALT); | ||
47 | unregister_code(KC_RALT); | ||
48 | register_code(KC_U); | ||
49 | unregister_code(KC_U); | ||
45 | } | 50 | } |
46 | wait_ms(UNICODE_TYPE_DELAY); | 51 | wait_ms(UNICODE_TYPE_DELAY); |
47 | } | 52 | } |
@@ -78,6 +83,52 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { | |||
78 | return true; | 83 | return true; |
79 | } | 84 | } |
80 | 85 | ||
86 | #ifdef UNICODEMAP_ENABLE | ||
87 | __attribute__((weak)) | ||
88 | const uint32_t PROGMEM unicode_map[] = { | ||
89 | }; | ||
90 | |||
91 | void register_hex32(uint32_t hex) { | ||
92 | uint8_t onzerostart = 1; | ||
93 | for(int i = 7; i >= 0; i--) { | ||
94 | if (i <= 3) { | ||
95 | onzerostart = 0; | ||
96 | } | ||
97 | uint8_t digit = ((hex >> (i*4)) & 0xF); | ||
98 | if (digit == 0) { | ||
99 | if (onzerostart == 0) { | ||
100 | register_code(hex_to_keycode(digit)); | ||
101 | unregister_code(hex_to_keycode(digit)); | ||
102 | } | ||
103 | } else { | ||
104 | register_code(hex_to_keycode(digit)); | ||
105 | unregister_code(hex_to_keycode(digit)); | ||
106 | onzerostart = 0; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | __attribute__((weak)) | ||
112 | void unicode_map_input_error() {} | ||
113 | |||
114 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | ||
115 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | ||
116 | const uint32_t* map = unicode_map; | ||
117 | uint16_t index = keycode & 0x7FF; | ||
118 | uint32_t code = pgm_read_dword_far(&map[index]); | ||
119 | if ((code > 0xFFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { | ||
120 | // when character is out of range supported by the OS | ||
121 | unicode_map_input_error(); | ||
122 | } else { | ||
123 | unicode_input_start(); | ||
124 | register_hex32(code); | ||
125 | unicode_input_finish(); | ||
126 | } | ||
127 | } | ||
128 | return true; | ||
129 | } | ||
130 | #endif | ||
131 | |||
81 | #ifdef UCIS_ENABLE | 132 | #ifdef UCIS_ENABLE |
82 | qk_ucis_state_t qk_ucis_state; | 133 | qk_ucis_state_t qk_ucis_state; |
83 | 134 | ||