diff options
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 76 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.h | 3 |
2 files changed, 48 insertions, 31 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 3fcac15ce..55e47f179 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
@@ -18,40 +18,54 @@ void set_unicode_input_mode(uint8_t os_target) | |||
18 | input_mode = os_target; | 18 | input_mode = os_target; |
19 | } | 19 | } |
20 | 20 | ||
21 | void unicode_input_start (void) { | ||
22 | switch(input_mode) { | ||
23 | case UC_OSX: | ||
24 | register_code(KC_LALT); | ||
25 | break; | ||
26 | case UC_LNX: | ||
27 | register_code(KC_LCTL); | ||
28 | register_code(KC_LSFT); | ||
29 | register_code(KC_U); | ||
30 | unregister_code(KC_U); | ||
31 | unregister_code(KC_LSFT); | ||
32 | unregister_code(KC_LCTL); | ||
33 | break; | ||
34 | case UC_WIN: | ||
35 | register_code(KC_LALT); | ||
36 | register_code(KC_PPLS); | ||
37 | unregister_code(KC_PPLS); | ||
38 | break; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | void unicode_input_finish (void) { | ||
43 | switch(input_mode) { | ||
44 | case UC_OSX: | ||
45 | case UC_WIN: | ||
46 | unregister_code(KC_LALT); | ||
47 | break; | ||
48 | case UC_LNX: | ||
49 | register_code(KC_SPC); | ||
50 | unregister_code(KC_SPC); | ||
51 | break; | ||
52 | } | ||
53 | } | ||
54 | |||
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)); | ||
60 | } | ||
61 | } | ||
62 | |||
21 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | 63 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { |
22 | if (keycode > QK_UNICODE && record->event.pressed) { | 64 | if (keycode > QK_UNICODE && record->event.pressed) { |
23 | uint16_t unicode = keycode & 0x7FFF; | 65 | uint16_t unicode = keycode & 0x7FFF; |
24 | switch(input_mode) { | 66 | unicode_input_start(); |
25 | case UC_OSX: | 67 | register_hex(unicode); |
26 | register_code(KC_LALT); | 68 | unicode_input_finish(); |
27 | break; | ||
28 | case UC_LNX: | ||
29 | register_code(KC_LCTL); | ||
30 | register_code(KC_LSFT); | ||
31 | register_code(KC_U); | ||
32 | unregister_code(KC_U); | ||
33 | break; | ||
34 | case UC_WIN: | ||
35 | register_code(KC_LALT); | ||
36 | register_code(KC_PPLS); | ||
37 | unregister_code(KC_PPLS); | ||
38 | break; | ||
39 | } | ||
40 | for(int i = 3; i >= 0; i--) { | ||
41 | uint8_t digit = ((unicode >> (i*4)) & 0xF); | ||
42 | register_code(hex_to_keycode(digit)); | ||
43 | unregister_code(hex_to_keycode(digit)); | ||
44 | } | ||
45 | switch(input_mode) { | ||
46 | case UC_OSX: | ||
47 | case UC_WIN: | ||
48 | unregister_code(KC_LALT); | ||
49 | break; | ||
50 | case UC_LNX: | ||
51 | unregister_code(KC_LCTL); | ||
52 | unregister_code(KC_LSFT); | ||
53 | break; | ||
54 | } | ||
55 | } | 69 | } |
56 | return true; | 70 | return true; |
57 | } \ No newline at end of file | 71 | } \ No newline at end of file |
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index ca17f8f66..f719a1226 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
@@ -9,6 +9,9 @@ | |||
9 | #define UC_BSD 3 | 9 | #define UC_BSD 3 |
10 | 10 | ||
11 | void set_unicode_input_mode(uint8_t os_target); | 11 | void set_unicode_input_mode(uint8_t os_target); |
12 | void unicode_input_start(void); | ||
13 | void unicode_input_finish(void); | ||
14 | void register_hex(uint16_t hex); | ||
12 | 15 | ||
13 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 16 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
14 | 17 | ||