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