diff options
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 51 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.h | 13 |
2 files changed, 60 insertions, 4 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 | ||
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index 27f8072ee..065eeb5f6 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
@@ -3,10 +3,11 @@ | |||
3 | 3 | ||
4 | #include "quantum.h" | 4 | #include "quantum.h" |
5 | 5 | ||
6 | #define UC_OSX 0 | 6 | #define UC_OSX 0 // Mac OS X |
7 | #define UC_LNX 1 | 7 | #define UC_LNX 1 // Linux |
8 | #define UC_WIN 2 | 8 | #define UC_WIN 2 // Windows 'HexNumpad' |
9 | #define UC_BSD 3 | 9 | #define UC_BSD 3 // BSD (not implemented) |
10 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
10 | 11 | ||
11 | #ifndef UNICODE_TYPE_DELAY | 12 | #ifndef UNICODE_TYPE_DELAY |
12 | #define UNICODE_TYPE_DELAY 10 | 13 | #define UNICODE_TYPE_DELAY 10 |
@@ -20,6 +21,10 @@ void register_hex(uint16_t hex); | |||
20 | 21 | ||
21 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 22 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
22 | 23 | ||
24 | #ifdef UNICODEMAP_ENABLE | ||
25 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | ||
26 | #endif | ||
27 | |||
23 | #ifdef UCIS_ENABLE | 28 | #ifdef UCIS_ENABLE |
24 | #ifndef UCIS_MAX_SYMBOL_LENGTH | 29 | #ifndef UCIS_MAX_SYMBOL_LENGTH |
25 | #define UCIS_MAX_SYMBOL_LENGTH 32 | 30 | #define UCIS_MAX_SYMBOL_LENGTH 32 |