summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_unicode.c
diff options
context:
space:
mode:
authorGergely Nagy <algernon@madhouse-project.org>2016-08-15 10:02:05 +0200
committerGergely Nagy <algernon@madhouse-project.org>2016-08-15 10:08:53 +0200
commit43d08629cf275d0b32281ffe8785258fff226b49 (patch)
tree35d116efeb3557d7b7e59276d7d53c450ebe9de9 /quantum/process_keycode/process_unicode.c
parenta312cbf712764277e0dbbbb99410c2f6fc6c7484 (diff)
downloadqmk_firmware-43d08629cf275d0b32281ffe8785258fff226b49.tar.gz
qmk_firmware-43d08629cf275d0b32281ffe8785258fff226b49.tar.xz
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/process_unicode.c')
-rw-r--r--quantum/process_keycode/process_unicode.c37
1 files changed, 28 insertions, 9 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) {
}
}
-void register_hex32(uint32_t hex) {
- for(int i = 7; i >= 0; i--) {
- uint8_t digit = ((hex >> (i*8)) & 0xF);
- register_code(hex_to_keycode(digit));
- unregister_code(hex_to_keycode(digit));
- }
-}
-
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
if (keycode > QK_UNICODE && record->event.pressed) {
uint16_t unicode = keycode & 0x7FFF;
@@ -120,6 +112,33 @@ void qk_ucis_symbol_fallback (void) {
}
}
+void register_ucis(const char *hex) {
+ for(int i = 0; hex[i]; i++) {
+ uint8_t kc = 0;
+ char c = hex[i];
+
+ switch (c) {
+ case '0':
+ kc = KC_0;
+ break;
+ case '1' ... '9':
+ kc = c - '1' + KC_1;
+ break;
+ case 'a' ... 'f':
+ kc = c - 'a' + KC_A;
+ break;
+ case 'A' ... 'F':
+ kc = c - 'A' + KC_A;
+ break;
+ }
+
+ if (kc) {
+ register_code (kc);
+ unregister_code (kc);
+ }
+ }
+}
+
bool process_ucis (uint16_t keycode, keyrecord_t *record) {
uint8_t i;
@@ -164,7 +183,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
for (i = 0; ucis_symbol_table[i].symbol; i++) {
if (is_uni_seq (ucis_symbol_table[i].symbol)) {
symbol_found = true;
- register_hex32(ucis_symbol_table[i].code);
+ register_ucis(ucis_symbol_table[i].code + 2);
break;
}
}