aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-10-18 21:35:15 -0700
committerJack Humbert <jack.humb@gmail.com>2018-10-19 00:35:15 -0400
commit7222e3691b18128c4822f6bb5db008010f5e41dd (patch)
tree9be08574cf226f6a4f5d08cfad5d302013b44f9e
parent7e1b57add42dcc3330d9d99e28c9b7f96eb2eee8 (diff)
downloadqmk_firmware-7222e3691b18128c4822f6bb5db008010f5e41dd.tar.gz
qmk_firmware-7222e3691b18128c4822f6bb5db008010f5e41dd.zip
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
-rw-r--r--quantum/process_keycode/process_ucis.c6
-rw-r--r--quantum/process_keycode/process_unicode.c7
-rw-r--r--quantum/process_keycode/process_unicode_common.c17
-rw-r--r--quantum/process_keycode/process_unicode_common.h1
-rw-r--r--quantum/process_keycode/process_unicodemap.c1
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) {
93} 93}
94 94
95bool process_ucis (uint16_t keycode, keyrecord_t *record) { 95bool process_ucis (uint16_t keycode, keyrecord_t *record) {
96 uint8_t i; 96 unicode_input_mode_init();
97 97
98 if (!qk_ucis_state.in_progress) 98 if (!qk_ucis_state.in_progress)
99 return true; 99 return true;
@@ -122,7 +122,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
122 if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) { 122 if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) {
123 bool symbol_found = false; 123 bool symbol_found = false;
124 124
125 for (i = qk_ucis_state.count; i > 0; i--) { 125 for (uint8_t i = qk_ucis_state.count; i > 0; i--) {
126 register_code (KC_BSPC); 126 register_code (KC_BSPC);
127 unregister_code (KC_BSPC); 127 unregister_code (KC_BSPC);
128 wait_ms(UNICODE_TYPE_DELAY); 128 wait_ms(UNICODE_TYPE_DELAY);
@@ -134,7 +134,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
134 } 134 }
135 135
136 unicode_input_start(); 136 unicode_input_start();
137 for (i = 0; ucis_symbol_table[i].symbol; i++) { 137 for (uint8_t i = 0; ucis_symbol_table[i].symbol; i++) {
138 if (is_uni_seq (ucis_symbol_table[i].symbol)) { 138 if (is_uni_seq (ucis_symbol_table[i].symbol)) {
139 symbol_found = true; 139 symbol_found = true;
140 register_ucis(ucis_symbol_table[i].code + 2); 140 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 @@
17#include "action_util.h" 17#include "action_util.h"
18#include "eeprom.h" 18#include "eeprom.h"
19 19
20static uint8_t first_flag = 0;
21
22bool process_unicode(uint16_t keycode, keyrecord_t *record) { 20bool process_unicode(uint16_t keycode, keyrecord_t *record) {
23 if (keycode > QK_UNICODE && record->event.pressed) { 21 if (keycode > QK_UNICODE && record->event.pressed) {
24 if (first_flag == 0) {
25 set_unicode_input_mode(eeprom_read_byte(EECONFIG_UNICODEMODE));
26 first_flag = 1;
27 }
28 uint16_t unicode = keycode & 0x7FFF; 22 uint16_t unicode = keycode & 0x7FFF;
23 unicode_input_mode_init();
29 unicode_input_start(); 24 unicode_input_start();
30 register_hex(unicode); 25 register_hex(unicode);
31 unicode_input_finish(); 26 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 @@
22static uint8_t input_mode; 22static uint8_t input_mode;
23uint8_t mods; 23uint8_t mods;
24 24
25void set_unicode_input_mode(uint8_t os_target) 25void set_unicode_input_mode(uint8_t os_target) {
26{
27 input_mode = os_target; 26 input_mode = os_target;
28 eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); 27 eeprom_update_byte(EECONFIG_UNICODEMODE, os_target);
29} 28}
@@ -32,6 +31,14 @@ uint8_t get_unicode_input_mode(void) {
32 return input_mode; 31 return input_mode;
33} 32}
34 33
34void unicode_input_mode_init(void) {
35 static bool first_flag = false;
36 if (!first_flag) {
37 input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE);
38 first_flag = true;
39 }
40}
41
35__attribute__((weak)) 42__attribute__((weak))
36void unicode_input_start (void) { 43void unicode_input_start (void) {
37 // save current mods 44 // save current mods
@@ -104,8 +111,7 @@ void unicode_input_finish (void) {
104} 111}
105 112
106__attribute__((weak)) 113__attribute__((weak))
107uint16_t hex_to_keycode(uint8_t hex) 114uint16_t hex_to_keycode(uint8_t hex) {
108{
109 if (hex == 0x0) { 115 if (hex == 0x0) {
110 return KC_0; 116 return KC_0;
111 } else if (hex < 0xA) { 117 } else if (hex < 0xA) {
@@ -123,8 +129,7 @@ void register_hex(uint16_t hex) {
123 } 129 }
124} 130}
125 131
126void send_unicode_hex_string(const char *str) 132void send_unicode_hex_string(const char *str) {
127{
128 if (!str) { return; } // Safety net 133 if (!str) { return; } // Safety net
129 134
130 while (*str) { 135 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;
28 28
29void set_unicode_input_mode(uint8_t os_target); 29void set_unicode_input_mode(uint8_t os_target);
30uint8_t get_unicode_input_mode(void); 30uint8_t get_unicode_input_mode(void);
31void unicode_input_mode_init(void);
31void unicode_input_start(void); 32void unicode_input_start(void);
32void unicode_input_finish(void); 33void unicode_input_finish(void);
33void register_hex(uint16_t hex); 34void 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))
45void unicode_map_input_error() {} 45void unicode_map_input_error() {}
46 46
47bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { 47bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
48 unicode_input_mode_init();
48 uint8_t input_mode = get_unicode_input_mode(); 49 uint8_t input_mode = get_unicode_input_mode();
49 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { 50 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
50 const uint32_t* map = unicode_map; 51 const uint32_t* map = unicode_map;