aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_unicode_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.c')
-rw-r--r--quantum/process_keycode/process_unicode_common.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index d0a9cf232..21ac2291d 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -20,6 +20,8 @@
20#include <string.h> 20#include <string.h>
21 21
22unicode_config_t unicode_config; 22unicode_config_t unicode_config;
23uint8_t unicode_saved_mods;
24
23#if UNICODE_SELECTED_MODES != -1 25#if UNICODE_SELECTED_MODES != -1
24static uint8_t selected[] = { UNICODE_SELECTED_MODES }; 26static uint8_t selected[] = { UNICODE_SELECTED_MODES };
25static uint8_t selected_count = sizeof selected / sizeof *selected; 27static uint8_t selected_count = sizeof selected / sizeof *selected;
@@ -75,30 +77,24 @@ void persist_unicode_input_mode(void) {
75 eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); 77 eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode);
76} 78}
77 79
78static uint8_t saved_mods;
79
80__attribute__((weak)) 80__attribute__((weak))
81void unicode_input_start(void) { 81void unicode_input_start(void) {
82 saved_mods = get_mods(); // Save current mods 82 unicode_saved_mods = get_mods(); // Save current mods
83 clear_mods(); // Unregister mods to start from a clean state 83 clear_mods(); // Unregister mods to start from a clean state
84 84
85 switch (unicode_config.input_mode) { 85 switch (unicode_config.input_mode) {
86 case UC_OSX: 86 case UC_OSX:
87 register_code(UNICODE_OSX_KEY); 87 register_code(UNICODE_KEY_OSX);
88 break; 88 break;
89 case UC_LNX: 89 case UC_LNX:
90 register_code(KC_LCTL); 90 tap_code16(UNICODE_KEY_LNX);
91 register_code(KC_LSFT);
92 tap_code(KC_U); // TODO: Replace with tap_code16(LCTL(LSFT(KC_U))); and test
93 unregister_code(KC_LSFT);
94 unregister_code(KC_LCTL);
95 break; 91 break;
96 case UC_WIN: 92 case UC_WIN:
97 register_code(KC_LALT); 93 register_code(KC_LALT);
98 tap_code(KC_PPLS); 94 tap_code(KC_PPLS);
99 break; 95 break;
100 case UC_WINC: 96 case UC_WINC:
101 tap_code(UNICODE_WINC_KEY); 97 tap_code(UNICODE_KEY_WINC);
102 tap_code(KC_U); 98 tap_code(KC_U);
103 break; 99 break;
104 } 100 }
@@ -110,7 +106,7 @@ __attribute__((weak))
110void unicode_input_finish(void) { 106void unicode_input_finish(void) {
111 switch (unicode_config.input_mode) { 107 switch (unicode_config.input_mode) {
112 case UC_OSX: 108 case UC_OSX:
113 unregister_code(UNICODE_OSX_KEY); 109 unregister_code(UNICODE_KEY_OSX);
114 break; 110 break;
115 case UC_LNX: 111 case UC_LNX:
116 tap_code(KC_SPC); 112 tap_code(KC_SPC);
@@ -123,7 +119,25 @@ void unicode_input_finish(void) {
123 break; 119 break;
124 } 120 }
125 121
126 set_mods(saved_mods); // Reregister previously set mods 122 set_mods(unicode_saved_mods); // Reregister previously set mods
123}
124
125__attribute__((weak))
126void unicode_input_cancel(void) {
127 switch (unicode_config.input_mode) {
128 case UC_OSX:
129 unregister_code(UNICODE_KEY_OSX);
130 break;
131 case UC_LNX:
132 case UC_WINC:
133 tap_code(KC_ESC);
134 break;
135 case UC_WIN:
136 unregister_code(KC_LALT);
137 break;
138 }
139
140 set_mods(unicode_saved_mods); // Reregister previously set mods
127} 141}
128 142
129__attribute__((weak)) 143__attribute__((weak))