1 #include "process_unicode.h"
3 static uint8_t input_mode;
5 uint16_t hex_to_keycode(uint8_t hex)
9 } else if (hex < 0xA) {
10 return KC_1 + (hex - 0x1);
12 return KC_A + (hex - 0xA);
16 void set_unicode_input_mode(uint8_t os_target)
18 input_mode = os_target;
21 void unicode_input_start (void) {
24 register_code(KC_LALT);
27 register_code(KC_LCTL);
28 register_code(KC_LSFT);
30 unregister_code(KC_U);
31 unregister_code(KC_LSFT);
32 unregister_code(KC_LCTL);
35 register_code(KC_LALT);
36 register_code(KC_PPLS);
37 unregister_code(KC_PPLS);
42 void unicode_input_finish (void) {
46 unregister_code(KC_LALT);
49 register_code(KC_SPC);
50 unregister_code(KC_SPC);
55 void register_hex(uint16_t hex) {
56 for(int i = 3; i >= 0; i--) {
57 uint8_t digit = ((hex >> (i*4)) & 0xF);
58 register_code(hex_to_keycode(digit));
59 unregister_code(hex_to_keycode(digit));
63 bool process_unicode(uint16_t keycode, keyrecord_t *record) {
64 if (keycode > QK_UNICODE && record->event.pressed) {
65 uint16_t unicode = keycode & 0x7FFF;
66 unicode_input_start();
67 register_hex(unicode);
68 unicode_input_finish();