diff options
author | Gergely Nagy <algernon@madhouse-project.org> | 2016-08-15 10:02:05 +0200 |
---|---|---|
committer | Gergely Nagy <algernon@madhouse-project.org> | 2016-08-15 10:08:53 +0200 |
commit | 43d08629cf275d0b32281ffe8785258fff226b49 (patch) | |
tree | 35d116efeb3557d7b7e59276d7d53c450ebe9de9 /quantum/process_keycode | |
parent | a312cbf712764277e0dbbbb99410c2f6fc6c7484 (diff) | |
download | qmk_firmware-43d08629cf275d0b32281ffe8785258fff226b49.tar.gz qmk_firmware-43d08629cf275d0b32281ffe8785258fff226b49.zip |
process_unicode: Replace register_hex32
It turns out that register_hex32 did not work reliably, and some systems
only allow 7 chars after the unicode magic sequence, while others allow
8. To remedy the situation, store the codes as strings, and type those
in instead of doing bit shifting magic.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 37 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.h | 8 |
2 files changed, 32 insertions, 13 deletions
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 698cc3c02..d8a0f667c 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
@@ -60,14 +60,6 @@ void register_hex(uint16_t hex) { | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void register_hex32(uint32_t hex) { | ||
64 | for(int i = 7; i >= 0; i--) { | ||
65 | uint8_t digit = ((hex >> (i*8)) & 0xF); | ||
66 | register_code(hex_to_keycode(digit)); | ||
67 | unregister_code(hex_to_keycode(digit)); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | 63 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { |
72 | if (keycode > QK_UNICODE && record->event.pressed) { | 64 | if (keycode > QK_UNICODE && record->event.pressed) { |
73 | uint16_t unicode = keycode & 0x7FFF; | 65 | uint16_t unicode = keycode & 0x7FFF; |
@@ -120,6 +112,33 @@ void qk_ucis_symbol_fallback (void) { | |||
120 | } | 112 | } |
121 | } | 113 | } |
122 | 114 | ||
115 | void register_ucis(const char *hex) { | ||
116 | for(int i = 0; hex[i]; i++) { | ||
117 | uint8_t kc = 0; | ||
118 | char c = hex[i]; | ||
119 | |||
120 | switch (c) { | ||
121 | case '0': | ||
122 | kc = KC_0; | ||
123 | break; | ||
124 | case '1' ... '9': | ||
125 | kc = c - '1' + KC_1; | ||
126 | break; | ||
127 | case 'a' ... 'f': | ||
128 | kc = c - 'a' + KC_A; | ||
129 | break; | ||
130 | case 'A' ... 'F': | ||
131 | kc = c - 'A' + KC_A; | ||
132 | break; | ||
133 | } | ||
134 | |||
135 | if (kc) { | ||
136 | register_code (kc); | ||
137 | unregister_code (kc); | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | |||
123 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { | 142 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { |
124 | uint8_t i; | 143 | uint8_t i; |
125 | 144 | ||
@@ -164,7 +183,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) { | |||
164 | for (i = 0; ucis_symbol_table[i].symbol; i++) { | 183 | for (i = 0; ucis_symbol_table[i].symbol; i++) { |
165 | if (is_uni_seq (ucis_symbol_table[i].symbol)) { | 184 | if (is_uni_seq (ucis_symbol_table[i].symbol)) { |
166 | symbol_found = true; | 185 | symbol_found = true; |
167 | register_hex32(ucis_symbol_table[i].code); | 186 | register_ucis(ucis_symbol_table[i].code + 2); |
168 | break; | 187 | break; |
169 | } | 188 | } |
170 | } | 189 | } |
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index dd6dd7138..be24ddc2b 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
@@ -12,7 +12,6 @@ void set_unicode_input_mode(uint8_t os_target); | |||
12 | void unicode_input_start(void); | 12 | void unicode_input_start(void); |
13 | void unicode_input_finish(void); | 13 | void unicode_input_finish(void); |
14 | void register_hex(uint16_t hex); | 14 | void register_hex(uint16_t hex); |
15 | void register_hex32(uint32_t hex); | ||
16 | 15 | ||
17 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 16 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
18 | 17 | ||
@@ -23,7 +22,7 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record); | |||
23 | 22 | ||
24 | typedef struct { | 23 | typedef struct { |
25 | char *symbol; | 24 | char *symbol; |
26 | uint32_t code; | 25 | char *code; |
27 | } qk_ucis_symbol_t; | 26 | } qk_ucis_symbol_t; |
28 | 27 | ||
29 | struct { | 28 | struct { |
@@ -32,14 +31,15 @@ struct { | |||
32 | bool in_progress:1; | 31 | bool in_progress:1; |
33 | } qk_ucis_state; | 32 | } qk_ucis_state; |
34 | 33 | ||
35 | #define UCIS_TABLE(...) {__VA_ARGS__, {NULL, 0}} | 34 | #define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}} |
36 | #define UCIS_SYM(name, code) {name, code} | 35 | #define UCIS_SYM(name, code) {name, #code} |
37 | 36 | ||
38 | extern const qk_ucis_symbol_t ucis_symbol_table[]; | 37 | extern const qk_ucis_symbol_t ucis_symbol_table[]; |
39 | 38 | ||
40 | void qk_ucis_start(void); | 39 | void qk_ucis_start(void); |
41 | void qk_ucis_start_user(void); | 40 | void qk_ucis_start_user(void); |
42 | void qk_ucis_symbol_fallback (void); | 41 | void qk_ucis_symbol_fallback (void); |
42 | void register_ucis(const char *hex); | ||
43 | bool process_ucis (uint16_t keycode, keyrecord_t *record); | 43 | bool process_ucis (uint16_t keycode, keyrecord_t *record); |
44 | 44 | ||
45 | #endif | 45 | #endif |