diff options
author | Drashna Jaelre <drashna@live.com> | 2018-10-18 21:35:15 -0700 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2018-10-19 00:35:15 -0400 |
commit | 7222e3691b18128c4822f6bb5db008010f5e41dd (patch) | |
tree | 9be08574cf226f6a4f5d08cfad5d302013b44f9e /quantum/process_keycode | |
parent | 7e1b57add42dcc3330d9d99e28c9b7f96eb2eee8 (diff) | |
download | qmk_firmware-7222e3691b18128c4822f6bb5db008010f5e41dd.tar.gz |
Fix Unicode EEPROM handling so it is consistent. (#4066)
* Fix Unicode EEPROM handling so it's consistant
* Remove changes to my userspace
* Optimize variables used
* fix functions
* additional cleanup
* Add False Flag
* rename function
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_ucis.c | 6 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode.c | 7 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 17 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 1 | ||||
-rw-r--r-- | quantum/process_keycode/process_unicodemap.c | 1 |
5 files changed, 17 insertions, 15 deletions
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 5de2e41fc..380199771 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -93,7 +93,7 @@ void register_ucis(const char *hex) { } bool process_ucis (uint16_t keycode, keyrecord_t *record) { - uint8_t i; + unicode_input_mode_init(); if (!qk_ucis_state.in_progress) return true; @@ -122,7 +122,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) { if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) { bool symbol_found = false; - for (i = qk_ucis_state.count; i > 0; i--) { + for (uint8_t i = qk_ucis_state.count; i > 0; i--) { register_code (KC_BSPC); unregister_code (KC_BSPC); wait_ms(UNICODE_TYPE_DELAY); @@ -134,7 +134,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) { } unicode_input_start(); - for (i = 0; ucis_symbol_table[i].symbol; i++) { + for (uint8_t i = 0; ucis_symbol_table[i].symbol; i++) { if (is_uni_seq (ucis_symbol_table[i].symbol)) { symbol_found = true; register_ucis(ucis_symbol_table[i].code + 2); diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index fd008eca1..f39c4a36e 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -17,15 +17,10 @@ #include "action_util.h" #include "eeprom.h" -static uint8_t first_flag = 0; - bool process_unicode(uint16_t keycode, keyrecord_t *record) { if (keycode > QK_UNICODE && record->event.pressed) { - if (first_flag == 0) { - set_unicode_input_mode(eeprom_read_byte(EECONFIG_UNICODEMODE)); - first_flag = 1; - } uint16_t unicode = keycode & 0x7FFF; + unicode_input_mode_init(); unicode_input_start(); register_hex(unicode); unicode_input_finish(); diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index e6620b7ea..4285d20a1 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -22,8 +22,7 @@ static uint8_t input_mode; uint8_t mods; -void set_unicode_input_mode(uint8_t os_target) -{ +void set_unicode_input_mode(uint8_t os_target) { input_mode = os_target; eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); } @@ -32,6 +31,14 @@ uint8_t get_unicode_input_mode(void) { return input_mode; } +void unicode_input_mode_init(void) { + static bool first_flag = false; + if (!first_flag) { + input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE); + first_flag = true; + } +} + __attribute__((weak)) void unicode_input_start (void) { // save current mods @@ -104,8 +111,7 @@ void unicode_input_finish (void) { } __attribute__((weak)) -uint16_t hex_to_keycode(uint8_t hex) -{ +uint16_t hex_to_keycode(uint8_t hex) { if (hex == 0x0) { return KC_0; } else if (hex < 0xA) { @@ -123,8 +129,7 @@ void register_hex(uint16_t hex) { } } -void send_unicode_hex_string(const char *str) -{ +void send_unicode_hex_string(const char *str) { if (!str) { return; } // Safety net while (*str) { diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 814b60c57..e78e1cec6 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -28,6 +28,7 @@ static uint8_t input_mode; void set_unicode_input_mode(uint8_t os_target); uint8_t get_unicode_input_mode(void); +void unicode_input_mode_init(void); void unicode_input_start(void); void unicode_input_finish(void); void register_hex(uint16_t hex); diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 47c27b911..ab5717ba3 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -45,6 +45,7 @@ __attribute__((weak)) void unicode_map_input_error() {} bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { + unicode_input_mode_init(); uint8_t input_mode = get_unicode_input_mode(); if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { const uint32_t* map = unicode_map; |