aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_unicode_common.c
diff options
context:
space:
mode:
authorKonstantin Đorđević <vomindoraan@gmail.com>2019-05-03 18:33:00 +0200
committerDrashna Jaelre <drashna@live.com>2019-05-03 09:33:00 -0700
commitbdc8d89e6b8f49528b716d9bd3343a4f9e9327bd (patch)
tree72673090e6ebc1669df953b83213231d7ffb8375 /quantum/process_keycode/process_unicode_common.c
parent41beecfc1847bd0039c508753a212fa18f207e3f (diff)
downloadqmk_firmware-bdc8d89e6b8f49528b716d9bd3343a4f9e9327bd.tar.gz
qmk_firmware-bdc8d89e6b8f49528b716d9bd3343a4f9e9327bd.zip
New keycode macro (XP) for shifted character pairs using UNICODEMAP + bug fixes and improvements (#4803)
* Expose unicode_saved_mods * Add UNICODEMAP shift pair functionality and XS keycode * Add XS to keycode reference documentation * Pick pair index based on both Shift and Caps Lock state * Add XS to Unicode feature docs * Clean up process_unicode* headers * Extract unicode_map index calculation into function * Pick pair index as XOR rather than OR of Shift and Caps states * unicode_input_start() has to be called before the unicode_map index is calculated * Replace unicodemap_input_error() with more generic unicode_input_cancel() * Replace register+tap+unregister with tap_code16(LCTL(LSFT(KC_U))) * UNICODE_OSX_KEY → UNICODE_KEY_OSX, UNICODE_WINC_KEY → UNICODE_KEY_WINC * Make keycode range checks more robust * Fix keycode range checks for different input modes * Add UNICODE_KEY_LNX, update docs * QK_UNICODEMAP_SHIFT → QK_UNICODEMAP_PAIR * XS → XP, update docs * Tweak Unicode docs * Use recently added MOD_MASK_SHIFT and IS_HOST_LED_ON helpers * Update Unicode table in docs/keycodes.md * Update Unicode docs per review comments * Replace references to Mac OS X with macOS in Unicode docs * As of v0.9.0, WinCompose supports all possible code points * Expand descriptions in XP docs * Update keycode table and cycling docs * Further expand cycling docs
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))