diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/process_keycode/process_ucis.c | 2 | ||||
| -rw-r--r-- | quantum/process_keycode/process_ucis.h | 5 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode.c | 2 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode.h | 5 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 200 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 66 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicodemap.c | 5 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicodemap.h | 4 | ||||
| -rw-r--r-- | quantum/quantum.c | 19 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 21 |
10 files changed, 216 insertions, 113 deletions
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 8deb24a86..5de2e41fc 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c | |||
| @@ -95,8 +95,6 @@ void register_ucis(const char *hex) { | |||
| 95 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { | 95 | bool process_ucis (uint16_t keycode, keyrecord_t *record) { |
| 96 | uint8_t i; | 96 | uint8_t i; |
| 97 | 97 | ||
| 98 | unicode_input_mode_init(); | ||
| 99 | |||
| 100 | if (!qk_ucis_state.in_progress) | 98 | if (!qk_ucis_state.in_progress) |
| 101 | return true; | 99 | return true; |
| 102 | 100 | ||
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h index d4aa34cde..b114d839a 100644 --- a/quantum/process_keycode/process_ucis.h +++ b/quantum/process_keycode/process_ucis.h | |||
| @@ -14,8 +14,7 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #ifndef PROCESS_UCIS_H | 17 | #pragma once |
| 18 | #define PROCESS_UCIS_H | ||
| 19 | 18 | ||
| 20 | #include "quantum.h" | 19 | #include "quantum.h" |
| 21 | #include "process_unicode_common.h" | 20 | #include "process_unicode_common.h" |
| @@ -48,5 +47,3 @@ void qk_ucis_symbol_fallback (void); | |||
| 48 | void qk_ucis_success(uint8_t symbol_index); | 47 | void qk_ucis_success(uint8_t symbol_index); |
| 49 | void register_ucis(const char *hex); | 48 | void register_ucis(const char *hex); |
| 50 | bool process_ucis (uint16_t keycode, keyrecord_t *record); | 49 | bool process_ucis (uint16_t keycode, keyrecord_t *record); |
| 51 | |||
| 52 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index f39c4a36e..19beb8452 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c | |||
| @@ -20,11 +20,9 @@ | |||
| 20 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { | 20 | bool process_unicode(uint16_t keycode, keyrecord_t *record) { |
| 21 | if (keycode > QK_UNICODE && record->event.pressed) { | 21 | if (keycode > QK_UNICODE && record->event.pressed) { |
| 22 | uint16_t unicode = keycode & 0x7FFF; | 22 | uint16_t unicode = keycode & 0x7FFF; |
| 23 | unicode_input_mode_init(); | ||
| 24 | unicode_input_start(); | 23 | unicode_input_start(); |
| 25 | register_hex(unicode); | 24 | register_hex(unicode); |
| 26 | unicode_input_finish(); | 25 | unicode_input_finish(); |
| 27 | } | 26 | } |
| 28 | return true; | 27 | return true; |
| 29 | } | 28 | } |
| 30 | |||
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index c525b74f0..0913e9910 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h | |||
| @@ -13,12 +13,9 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef PROCESS_UNICODE_H | 16 | #pragma once |
| 17 | #define PROCESS_UNICODE_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | #include "process_unicode_common.h" | 19 | #include "process_unicode_common.h" |
| 21 | 20 | ||
| 22 | bool process_unicode(uint16_t keycode, keyrecord_t *record); | 21 | bool process_unicode(uint16_t keycode, keyrecord_t *record); |
| 23 | |||
| 24 | #endif | ||
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4285d20a1..3286f45b5 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -16,98 +16,111 @@ | |||
| 16 | 16 | ||
| 17 | #include "process_unicode_common.h" | 17 | #include "process_unicode_common.h" |
| 18 | #include "eeprom.h" | 18 | #include "eeprom.h" |
| 19 | #include <string.h> | ||
| 20 | #include <ctype.h> | 19 | #include <ctype.h> |
| 20 | #include <string.h> | ||
| 21 | 21 | ||
| 22 | static uint8_t input_mode; | 22 | unicode_config_t unicode_config; |
| 23 | uint8_t mods; | 23 | #if UNICODE_SELECTED_MODES != -1 |
| 24 | static uint8_t selected[] = { UNICODE_SELECTED_MODES }; | ||
| 25 | static uint8_t selected_count = sizeof selected / sizeof *selected; | ||
| 26 | static uint8_t selected_index; | ||
| 27 | #endif | ||
| 24 | 28 | ||
| 25 | void set_unicode_input_mode(uint8_t os_target) { | 29 | void unicode_input_mode_init(void) { |
| 26 | input_mode = os_target; | 30 | unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); |
| 27 | eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); | 31 | #if UNICODE_SELECTED_MODES != -1 |
| 32 | #if UNICODE_CYCLE_PERSIST | ||
| 33 | // Find input_mode in selected modes | ||
| 34 | uint8_t i; | ||
| 35 | for (i = 0; i < selected_count; i++) { | ||
| 36 | if (selected[i] == unicode_config.input_mode) { | ||
| 37 | selected_index = i; | ||
| 38 | break; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | if (i == selected_count) { | ||
| 42 | // Not found: input_mode isn't selected, change to one that is | ||
| 43 | unicode_config.input_mode = selected[selected_index = 0]; | ||
| 44 | } | ||
| 45 | #else | ||
| 46 | // Always change to the first selected input mode | ||
| 47 | unicode_config.input_mode = selected[selected_index = 0]; | ||
| 48 | #endif | ||
| 49 | #endif | ||
| 50 | dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode); | ||
| 28 | } | 51 | } |
| 29 | 52 | ||
| 30 | uint8_t get_unicode_input_mode(void) { | 53 | uint8_t get_unicode_input_mode(void) { |
| 31 | return input_mode; | 54 | return unicode_config.input_mode; |
| 32 | } | 55 | } |
| 33 | 56 | ||
| 34 | void unicode_input_mode_init(void) { | 57 | void set_unicode_input_mode(uint8_t mode) { |
| 35 | static bool first_flag = false; | 58 | unicode_config.input_mode = mode; |
| 36 | if (!first_flag) { | 59 | persist_unicode_input_mode(); |
| 37 | input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE); | 60 | dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode); |
| 38 | first_flag = true; | 61 | } |
| 39 | } | 62 | |
| 63 | void cycle_unicode_input_mode(uint8_t offset) { | ||
| 64 | #if UNICODE_SELECTED_MODES != -1 | ||
| 65 | selected_index = (selected_index + offset) % selected_count; | ||
| 66 | unicode_config.input_mode = selected[selected_index]; | ||
| 67 | #if UNICODE_CYCLE_PERSIST | ||
| 68 | persist_unicode_input_mode(); | ||
| 69 | #endif | ||
| 70 | dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode); | ||
| 71 | #endif | ||
| 72 | } | ||
| 73 | |||
| 74 | void persist_unicode_input_mode(void) { | ||
| 75 | eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); | ||
| 40 | } | 76 | } |
| 41 | 77 | ||
| 78 | static uint8_t saved_mods; | ||
| 79 | |||
| 42 | __attribute__((weak)) | 80 | __attribute__((weak)) |
| 43 | void unicode_input_start (void) { | 81 | void unicode_input_start(void) { |
| 44 | // save current mods | 82 | saved_mods = get_mods(); // Save current mods |
| 45 | mods = keyboard_report->mods; | 83 | clear_mods(); // Unregister mods to start from a clean state |
| 46 | 84 | ||
| 47 | // unregister all mods to start from clean state | 85 | switch (unicode_config.input_mode) { |
| 48 | if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT); | ||
| 49 | if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT); | ||
| 50 | if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL); | ||
| 51 | if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL); | ||
| 52 | if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT); | ||
| 53 | if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT); | ||
| 54 | if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI); | ||
| 55 | if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI); | ||
| 56 | |||
| 57 | switch(input_mode) { | ||
| 58 | case UC_OSX: | 86 | case UC_OSX: |
| 59 | register_code(KC_LALT); | 87 | register_code(UNICODE_OSX_KEY); |
| 60 | break; | ||
| 61 | case UC_OSX_RALT: | ||
| 62 | register_code(KC_RALT); | ||
| 63 | break; | 88 | break; |
| 64 | case UC_LNX: | 89 | case UC_LNX: |
| 65 | register_code(KC_LCTL); | 90 | register_code(KC_LCTL); |
| 66 | register_code(KC_LSFT); | 91 | register_code(KC_LSFT); |
| 67 | register_code(KC_U); | 92 | tap_code(KC_U); // TODO: Replace with tap_code16(LCTL(LSFT(KC_U))); and test |
| 68 | unregister_code(KC_U); | ||
| 69 | unregister_code(KC_LSFT); | 93 | unregister_code(KC_LSFT); |
| 70 | unregister_code(KC_LCTL); | 94 | unregister_code(KC_LCTL); |
| 71 | break; | 95 | break; |
| 72 | case UC_WIN: | 96 | case UC_WIN: |
| 73 | register_code(KC_LALT); | 97 | register_code(KC_LALT); |
| 74 | register_code(KC_PPLS); | 98 | tap_code(KC_PPLS); |
| 75 | unregister_code(KC_PPLS); | ||
| 76 | break; | 99 | break; |
| 77 | case UC_WINC: | 100 | case UC_WINC: |
| 78 | register_code(KC_RALT); | 101 | tap_code(UNICODE_WINC_KEY); |
| 79 | unregister_code(KC_RALT); | 102 | tap_code(KC_U); |
| 80 | register_code(KC_U); | 103 | break; |
| 81 | unregister_code(KC_U); | ||
| 82 | } | 104 | } |
| 105 | |||
| 83 | wait_ms(UNICODE_TYPE_DELAY); | 106 | wait_ms(UNICODE_TYPE_DELAY); |
| 84 | } | 107 | } |
| 85 | 108 | ||
| 86 | __attribute__((weak)) | 109 | __attribute__((weak)) |
| 87 | void unicode_input_finish (void) { | 110 | void unicode_input_finish(void) { |
| 88 | switch(input_mode) { | 111 | switch (unicode_config.input_mode) { |
| 89 | case UC_OSX: | 112 | case UC_OSX: |
| 90 | case UC_WIN: | 113 | unregister_code(UNICODE_OSX_KEY); |
| 91 | unregister_code(KC_LALT); | 114 | break; |
| 92 | break; | 115 | case UC_LNX: |
| 93 | case UC_OSX_RALT: | 116 | tap_code(KC_SPC); |
| 94 | unregister_code(KC_RALT); | 117 | break; |
| 95 | break; | 118 | case UC_WIN: |
| 96 | case UC_LNX: | 119 | unregister_code(KC_LALT); |
| 97 | register_code(KC_SPC); | 120 | break; |
| 98 | unregister_code(KC_SPC); | ||
| 99 | break; | ||
| 100 | } | 121 | } |
| 101 | 122 | ||
| 102 | // reregister previously set mods | 123 | set_mods(saved_mods); // Reregister previously set mods |
| 103 | if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); | ||
| 104 | if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT); | ||
| 105 | if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL); | ||
| 106 | if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL); | ||
| 107 | if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT); | ||
| 108 | if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT); | ||
| 109 | if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI); | ||
| 110 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); | ||
| 111 | } | 124 | } |
| 112 | 125 | ||
| 113 | __attribute__((weak)) | 126 | __attribute__((weak)) |
| @@ -124,13 +137,12 @@ uint16_t hex_to_keycode(uint8_t hex) { | |||
| 124 | void register_hex(uint16_t hex) { | 137 | void register_hex(uint16_t hex) { |
| 125 | for(int i = 3; i >= 0; i--) { | 138 | for(int i = 3; i >= 0; i--) { |
| 126 | uint8_t digit = ((hex >> (i*4)) & 0xF); | 139 | uint8_t digit = ((hex >> (i*4)) & 0xF); |
| 127 | register_code(hex_to_keycode(digit)); | 140 | tap_code(hex_to_keycode(digit)); |
| 128 | unregister_code(hex_to_keycode(digit)); | ||
| 129 | } | 141 | } |
| 130 | } | 142 | } |
| 131 | 143 | ||
| 132 | void send_unicode_hex_string(const char *str) { | 144 | void send_unicode_hex_string(const char *str) { |
| 133 | if (!str) { return; } // Safety net | 145 | if (!str) { return; } |
| 134 | 146 | ||
| 135 | while (*str) { | 147 | while (*str) { |
| 136 | // Find the next code point (token) in the string | 148 | // Find the next code point (token) in the string |
| @@ -153,3 +165,61 @@ void send_unicode_hex_string(const char *str) { | |||
| 153 | str += n; // Move to the first ' ' (or '\0') after the current token | 165 | str += n; // Move to the first ' ' (or '\0') after the current token |
| 154 | } | 166 | } |
| 155 | } | 167 | } |
| 168 | |||
| 169 | bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { | ||
| 170 | if (record->event.pressed) { | ||
| 171 | switch (keycode) { | ||
| 172 | case UNICODE_MODE_FORWARD: | ||
| 173 | cycle_unicode_input_mode(+1); | ||
| 174 | break; | ||
| 175 | case UNICODE_MODE_REVERSE: | ||
| 176 | cycle_unicode_input_mode(-1); | ||
| 177 | break; | ||
| 178 | |||
| 179 | case UNICODE_MODE_OSX: | ||
| 180 | set_unicode_input_mode(UC_OSX); | ||
| 181 | #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) | ||
| 182 | static float song_osx[][2] = UNICODE_SONG_OSX; | ||
| 183 | PLAY_SONG(song_osx); | ||
| 184 | #endif | ||
| 185 | break; | ||
| 186 | case UNICODE_MODE_LNX: | ||
| 187 | set_unicode_input_mode(UC_LNX); | ||
| 188 | #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) | ||
| 189 | static float song_lnx[][2] = UNICODE_SONG_LNX; | ||
| 190 | PLAY_SONG(song_lnx); | ||
| 191 | #endif | ||
| 192 | break; | ||
| 193 | case UNICODE_MODE_WIN: | ||
| 194 | set_unicode_input_mode(UC_WIN); | ||
| 195 | #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) | ||
| 196 | static float song_win[][2] = UNICODE_SONG_WIN; | ||
| 197 | PLAY_SONG(song_win); | ||
| 198 | #endif | ||
| 199 | break; | ||
| 200 | case UNICODE_MODE_BSD: | ||
| 201 | set_unicode_input_mode(UC_BSD); | ||
| 202 | #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) | ||
| 203 | static float song_bsd[][2] = UNICODE_SONG_BSD; | ||
| 204 | PLAY_SONG(song_bsd); | ||
| 205 | #endif | ||
| 206 | break; | ||
| 207 | case UNICODE_MODE_WINC: | ||
| 208 | set_unicode_input_mode(UC_WINC); | ||
| 209 | #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) | ||
| 210 | static float song_winc[][2] = UNICODE_SONG_WINC; | ||
| 211 | PLAY_SONG(song_winc); | ||
| 212 | #endif | ||
| 213 | break; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | #if defined(UNICODE_ENABLE) | ||
| 217 | return process_unicode(keycode, record); | ||
| 218 | #elif defined(UNICODEMAP_ENABLE) | ||
| 219 | return process_unicode_map(keycode, record); | ||
| 220 | #elif defined(UCIS_ENABLE) | ||
| 221 | return process_ucis(keycode, record); | ||
| 222 | #else | ||
| 223 | return true; | ||
| 224 | #endif | ||
| 225 | } | ||
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e78e1cec6..e608ab76b 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h | |||
| @@ -14,35 +14,71 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #ifndef PROCESS_UNICODE_COMMON_H | 17 | #pragma once |
| 18 | #define PROCESS_UNICODE_COMMON_H | ||
| 19 | 18 | ||
| 20 | #include "quantum.h" | 19 | #include "quantum.h" |
| 21 | 20 | ||
| 21 | #if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 | ||
| 22 | #error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" | ||
| 23 | #endif | ||
| 24 | |||
| 25 | // Keycodes used for starting Unicode input on different platforms | ||
| 26 | #ifndef UNICODE_OSX_KEY | ||
| 27 | #define UNICODE_OSX_KEY KC_LALT | ||
| 28 | #endif | ||
| 29 | #ifndef UNICODE_WINC_KEY | ||
| 30 | #define UNICODE_WINC_KEY KC_RALT | ||
| 31 | #endif | ||
| 32 | |||
| 33 | // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) | ||
| 34 | // Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX | ||
| 35 | #ifndef UNICODE_SELECTED_MODES | ||
| 36 | #define UNICODE_SELECTED_MODES -1 | ||
| 37 | #endif | ||
| 38 | |||
| 39 | // Whether input mode changes in cycle should be written to EEPROM | ||
| 40 | #ifndef UNICODE_CYCLE_PERSIST | ||
| 41 | #define UNICODE_CYCLE_PERSIST true | ||
| 42 | #endif | ||
| 43 | |||
| 44 | // Delay between starting Unicode input and sending a sequence, in ms | ||
| 22 | #ifndef UNICODE_TYPE_DELAY | 45 | #ifndef UNICODE_TYPE_DELAY |
| 23 | #define UNICODE_TYPE_DELAY 10 | 46 | #define UNICODE_TYPE_DELAY 10 |
| 24 | #endif | 47 | #endif |
| 25 | 48 | ||
| 26 | __attribute__ ((unused)) | 49 | enum unicode_input_modes { |
| 27 | static uint8_t input_mode; | 50 | UC_OSX, // Mac OS X using Unicode Hex Input |
| 51 | UC_LNX, // Linux using IBus | ||
| 52 | UC_WIN, // Windows using EnableHexNumpad | ||
| 53 | UC_BSD, // BSD (not implemented) | ||
| 54 | UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) | ||
| 55 | UC__COUNT // Number of available input modes (always leave at the end) | ||
| 56 | }; | ||
| 57 | |||
| 58 | typedef union { | ||
| 59 | uint32_t raw; | ||
| 60 | struct { | ||
| 61 | uint8_t input_mode : 8; | ||
| 62 | }; | ||
| 63 | } unicode_config_t; | ||
| 64 | |||
| 65 | extern unicode_config_t unicode_config; | ||
| 28 | 66 | ||
| 29 | void set_unicode_input_mode(uint8_t os_target); | ||
| 30 | uint8_t get_unicode_input_mode(void); | ||
| 31 | void unicode_input_mode_init(void); | 67 | void unicode_input_mode_init(void); |
| 68 | uint8_t get_unicode_input_mode(void); | ||
| 69 | void set_unicode_input_mode(uint8_t mode); | ||
| 70 | void cycle_unicode_input_mode(uint8_t offset); | ||
| 71 | void persist_unicode_input_mode(void); | ||
| 72 | |||
| 32 | void unicode_input_start(void); | 73 | void unicode_input_start(void); |
| 33 | void unicode_input_finish(void); | 74 | void unicode_input_finish(void); |
| 75 | |||
| 34 | void register_hex(uint16_t hex); | 76 | void register_hex(uint16_t hex); |
| 35 | void send_unicode_hex_string(const char *str); | 77 | void send_unicode_hex_string(const char *str); |
| 36 | 78 | ||
| 37 | #define UC_OSX 0 // Mac OS X | 79 | bool process_unicode_common(uint16_t keycode, keyrecord_t *record); |
| 38 | #define UC_LNX 1 // Linux | ||
| 39 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
| 40 | #define UC_BSD 3 // BSD (not implemented) | ||
| 41 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
| 42 | #define UC_OSX_RALT 5 // Mac OS X using Right Alt key for Unicode Compose | ||
| 43 | 80 | ||
| 44 | #define UC_BSPC UC(0x0008) | 81 | #define UC_BSPC UC(0x0008) |
| 45 | |||
| 46 | #define UC_SPC UC(0x0020) | 82 | #define UC_SPC UC(0x0020) |
| 47 | 83 | ||
| 48 | #define UC_EXLM UC(0x0021) | 84 | #define UC_EXLM UC(0x0021) |
| @@ -147,5 +183,3 @@ void send_unicode_hex_string(const char *str); | |||
| 147 | #define UC_RCBR UC(0x007D) | 183 | #define UC_RCBR UC(0x007D) |
| 148 | #define UC_TILD UC(0x007E) | 184 | #define UC_TILD UC(0x007E) |
| 149 | #define UC_DEL UC(0x007F) | 185 | #define UC_DEL UC(0x007F) |
| 150 | |||
| 151 | #endif | ||
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index ab5717ba3..75f35112b 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c | |||
| @@ -45,13 +45,12 @@ __attribute__((weak)) | |||
| 45 | void unicode_map_input_error() {} | 45 | void unicode_map_input_error() {} |
| 46 | 46 | ||
| 47 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | 47 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { |
| 48 | unicode_input_mode_init(); | ||
| 49 | uint8_t input_mode = get_unicode_input_mode(); | 48 | uint8_t input_mode = get_unicode_input_mode(); |
| 50 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | 49 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { |
| 51 | const uint32_t* map = unicode_map; | 50 | const uint32_t* map = unicode_map; |
| 52 | uint16_t index = keycode - QK_UNICODE_MAP; | 51 | uint16_t index = keycode - QK_UNICODE_MAP; |
| 53 | uint32_t code = pgm_read_dword(&map[index]); | 52 | uint32_t code = pgm_read_dword(&map[index]); |
| 54 | if (code > 0xFFFF && code <= 0x10ffff && (input_mode == UC_OSX || input_mode == UC_OSX_RALT)) { | 53 | if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { |
| 55 | // Convert to UTF-16 surrogate pair | 54 | // Convert to UTF-16 surrogate pair |
| 56 | code -= 0x10000; | 55 | code -= 0x10000; |
| 57 | uint32_t lo = code & 0x3ff; | 56 | uint32_t lo = code & 0x3ff; |
| @@ -60,7 +59,7 @@ bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | |||
| 60 | register_hex32(hi + 0xd800); | 59 | register_hex32(hi + 0xd800); |
| 61 | register_hex32(lo + 0xdc00); | 60 | register_hex32(lo + 0xdc00); |
| 62 | unicode_input_finish(); | 61 | unicode_input_finish(); |
| 63 | } else if ((code > 0x10ffff && (input_mode == UC_OSX || input_mode == UC_OSX_RALT)) || (code > 0xFFFFF && input_mode == UC_LNX)) { | 62 | } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { |
| 64 | // when character is out of range supported by the OS | 63 | // when character is out of range supported by the OS |
| 65 | unicode_map_input_error(); | 64 | unicode_map_input_error(); |
| 66 | } else { | 65 | } else { |
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index 929c88c0b..f6d64bb86 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h | |||
| @@ -14,12 +14,10 @@ | |||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #ifndef PROCESS_UNICODEMAP_H | 17 | #pragma once |
| 18 | #define PROCESS_UNICODEMAP_H | ||
| 19 | 18 | ||
| 20 | #include "quantum.h" | 19 | #include "quantum.h" |
| 21 | #include "process_unicode_common.h" | 20 | #include "process_unicode_common.h" |
| 22 | 21 | ||
| 23 | void unicode_map_input_error(void); | 22 | void unicode_map_input_error(void); |
| 24 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | 23 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); |
| 25 | #endif | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index a57d4f89f..85db100ab 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -243,7 +243,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 243 | process_key_lock(&keycode, record) && | 243 | process_key_lock(&keycode, record) && |
| 244 | #endif | 244 | #endif |
| 245 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) | 245 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) |
| 246 | process_clicky(keycode, record) && | 246 | process_clicky(keycode, record) && |
| 247 | #endif //AUDIO_CLICKY | 247 | #endif //AUDIO_CLICKY |
| 248 | process_record_kb(keycode, record) && | 248 | process_record_kb(keycode, record) && |
| 249 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) | 249 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) |
| @@ -258,33 +258,27 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 258 | #ifdef STENO_ENABLE | 258 | #ifdef STENO_ENABLE |
| 259 | process_steno(keycode, record) && | 259 | process_steno(keycode, record) && |
| 260 | #endif | 260 | #endif |
| 261 | #if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) | 261 | #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) |
| 262 | process_music(keycode, record) && | 262 | process_music(keycode, record) && |
| 263 | #endif | 263 | #endif |
| 264 | #ifdef TAP_DANCE_ENABLE | 264 | #ifdef TAP_DANCE_ENABLE |
| 265 | process_tap_dance(keycode, record) && | 265 | process_tap_dance(keycode, record) && |
| 266 | #endif | 266 | #endif |
| 267 | #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) | ||
| 268 | process_unicode_common(keycode, record) && | ||
| 269 | #endif | ||
| 267 | #ifdef LEADER_ENABLE | 270 | #ifdef LEADER_ENABLE |
| 268 | process_leader(keycode, record) && | 271 | process_leader(keycode, record) && |
| 269 | #endif | 272 | #endif |
| 270 | #ifdef COMBO_ENABLE | 273 | #ifdef COMBO_ENABLE |
| 271 | process_combo(keycode, record) && | 274 | process_combo(keycode, record) && |
| 272 | #endif | 275 | #endif |
| 273 | #ifdef UNICODE_ENABLE | ||
| 274 | process_unicode(keycode, record) && | ||
| 275 | #endif | ||
| 276 | #ifdef UCIS_ENABLE | ||
| 277 | process_ucis(keycode, record) && | ||
| 278 | #endif | ||
| 279 | #ifdef PRINTING_ENABLE | 276 | #ifdef PRINTING_ENABLE |
| 280 | process_printer(keycode, record) && | 277 | process_printer(keycode, record) && |
| 281 | #endif | 278 | #endif |
| 282 | #ifdef AUTO_SHIFT_ENABLE | 279 | #ifdef AUTO_SHIFT_ENABLE |
| 283 | process_auto_shift(keycode, record) && | 280 | process_auto_shift(keycode, record) && |
| 284 | #endif | 281 | #endif |
| 285 | #ifdef UNICODEMAP_ENABLE | ||
| 286 | process_unicode_map(keycode, record) && | ||
| 287 | #endif | ||
| 288 | #ifdef TERMINAL_ENABLE | 282 | #ifdef TERMINAL_ENABLE |
| 289 | process_terminal(keycode, record) && | 283 | process_terminal(keycode, record) && |
| 290 | #endif | 284 | #endif |
| @@ -1010,6 +1004,9 @@ void matrix_init_quantum() { | |||
| 1010 | #ifdef ENCODER_ENABLE | 1004 | #ifdef ENCODER_ENABLE |
| 1011 | encoder_init(); | 1005 | encoder_init(); |
| 1012 | #endif | 1006 | #endif |
| 1007 | #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) | ||
| 1008 | unicode_input_mode_init(); | ||
| 1009 | #endif | ||
| 1013 | matrix_init_kb(); | 1010 | matrix_init_kb(); |
| 1014 | } | 1011 | } |
| 1015 | 1012 | ||
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 283b4a65c..2b309f4d5 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -81,9 +81,6 @@ enum quantum_keycodes { | |||
| 81 | #endif | 81 | #endif |
| 82 | QK_MOD_TAP = 0x6000, | 82 | QK_MOD_TAP = 0x6000, |
| 83 | QK_MOD_TAP_MAX = 0x7FFF, | 83 | QK_MOD_TAP_MAX = 0x7FFF, |
| 84 | #if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) | ||
| 85 | #error "Cannot enable both UNICODEMAP && UNICODE" | ||
| 86 | #endif | ||
| 87 | #ifdef UNICODE_ENABLE | 84 | #ifdef UNICODE_ENABLE |
| 88 | QK_UNICODE = 0x8000, | 85 | QK_UNICODE = 0x8000, |
| 89 | QK_UNICODE_MAX = 0xFFFF, | 86 | QK_UNICODE_MAX = 0xFFFF, |
| @@ -456,6 +453,15 @@ enum quantum_keycodes { | |||
| 456 | 453 | ||
| 457 | EEPROM_RESET, | 454 | EEPROM_RESET, |
| 458 | 455 | ||
| 456 | UNICODE_MODE_FORWARD, | ||
| 457 | UNICODE_MODE_REVERSE, | ||
| 458 | |||
| 459 | UNICODE_MODE_OSX, | ||
| 460 | UNICODE_MODE_LNX, | ||
| 461 | UNICODE_MODE_WIN, | ||
| 462 | UNICODE_MODE_BSD, | ||
| 463 | UNICODE_MODE_WINC, | ||
| 464 | |||
| 459 | // always leave at the end | 465 | // always leave at the end |
| 460 | SAFE_RANGE | 466 | SAFE_RANGE |
| 461 | }; | 467 | }; |
| @@ -684,6 +690,15 @@ enum quantum_keycodes { | |||
| 684 | #define X(n) (QK_UNICODE_MAP | (n)) | 690 | #define X(n) (QK_UNICODE_MAP | (n)) |
| 685 | #endif | 691 | #endif |
| 686 | 692 | ||
| 693 | #define UC_MOD UNICODE_MODE_FORWARD | ||
| 694 | #define UC_RMOD UNICODE_MODE_REVERSE | ||
| 695 | |||
| 696 | #define UC_M_OS UNICODE_MODE_OSX | ||
| 697 | #define UC_M_LN UNICODE_MODE_LNX | ||
| 698 | #define UC_M_WI UNICODE_MODE_WIN | ||
| 699 | #define UC_M_BS UNICODE_MODE_BSD | ||
| 700 | #define UC_M_WC UNICODE_MODE_WINC | ||
| 701 | |||
| 687 | #ifdef SWAP_HANDS_ENABLE | 702 | #ifdef SWAP_HANDS_ENABLE |
| 688 | #define SH_T(kc) (QK_SWAP_HANDS | (kc)) | 703 | #define SH_T(kc) (QK_SWAP_HANDS | (kc)) |
| 689 | #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) | 704 | #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) |
