1 #include "process_unicodemap.h"
2 #include "process_unicode_common.h"
5 const uint32_t PROGMEM unicode_map[] = {
8 void register_hex32(uint32_t hex) {
9 bool onzerostart = true;
10 for(int i = 7; i >= 0; i--) {
14 uint8_t digit = ((hex >> (i*4)) & 0xF);
17 register_code(hex_to_keycode(digit));
18 unregister_code(hex_to_keycode(digit));
21 register_code(hex_to_keycode(digit));
22 unregister_code(hex_to_keycode(digit));
29 void unicode_map_input_error() {}
31 bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
32 uint8_t input_mode = get_unicode_input_mode();
33 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
34 const uint32_t* map = unicode_map;
35 uint16_t index = keycode - QK_UNICODE_MAP;
36 uint32_t code = pgm_read_dword_far(&map[index]);
37 if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) {
38 // Convert to UTF-16 surrogate pair
40 uint32_t lo = code & 0x3ff;
41 uint32_t hi = (code & 0xffc00) >> 10;
42 unicode_input_start();
43 register_hex32(hi + 0xd800);
44 register_hex32(lo + 0xdc00);
45 unicode_input_finish();
46 } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
47 // when character is out of range supported by the OS
48 unicode_map_input_error();
50 unicode_input_start();
52 unicode_input_finish();