diff options
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.h')
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 4d2b04fb3..e608ab76b 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h | |||
| @@ -14,33 +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 | ||
| 22 | #ifndef UNICODE_TYPE_DELAY | 21 | #if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 |
| 23 | #define UNICODE_TYPE_DELAY 10 | 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 | ||
| 24 | #endif | 31 | #endif |
| 25 | 32 | ||
| 26 | __attribute__ ((unused)) | 33 | // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) |
| 27 | static uint8_t input_mode; | 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 | ||
| 28 | 43 | ||
| 29 | void set_unicode_input_mode(uint8_t os_target); | 44 | // Delay between starting Unicode input and sending a sequence, in ms |
| 45 | #ifndef UNICODE_TYPE_DELAY | ||
| 46 | #define UNICODE_TYPE_DELAY 10 | ||
| 47 | #endif | ||
| 48 | |||
| 49 | enum unicode_input_modes { | ||
| 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; | ||
| 66 | |||
| 67 | void unicode_input_mode_init(void); | ||
| 30 | uint8_t get_unicode_input_mode(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 | |||
| 31 | void unicode_input_start(void); | 73 | void unicode_input_start(void); |
| 32 | void unicode_input_finish(void); | 74 | void unicode_input_finish(void); |
| 75 | |||
| 33 | void register_hex(uint16_t hex); | 76 | void register_hex(uint16_t hex); |
| 77 | void send_unicode_hex_string(const char *str); | ||
| 34 | 78 | ||
| 35 | #define UC_OSX 0 // Mac OS X | 79 | bool process_unicode_common(uint16_t keycode, keyrecord_t *record); |
| 36 | #define UC_LNX 1 // Linux | ||
| 37 | #define UC_WIN 2 // Windows 'HexNumpad' | ||
| 38 | #define UC_BSD 3 // BSD (not implemented) | ||
| 39 | #define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose | ||
| 40 | #define UC_OSX_RALT 5 // Mac OS X using Right Alt key for Unicode Compose | ||
| 41 | 80 | ||
| 42 | #define UC_BSPC UC(0x0008) | 81 | #define UC_BSPC UC(0x0008) |
| 43 | |||
| 44 | #define UC_SPC UC(0x0020) | 82 | #define UC_SPC UC(0x0020) |
| 45 | 83 | ||
| 46 | #define UC_EXLM UC(0x0021) | 84 | #define UC_EXLM UC(0x0021) |
| @@ -145,5 +183,3 @@ void register_hex(uint16_t hex); | |||
| 145 | #define UC_RCBR UC(0x007D) | 183 | #define UC_RCBR UC(0x007D) |
| 146 | #define UC_TILD UC(0x007E) | 184 | #define UC_TILD UC(0x007E) |
| 147 | #define UC_DEL UC(0x007F) | 185 | #define UC_DEL UC(0x007F) |
| 148 | |||
| 149 | #endif | ||
