diff options
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.h')
-rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 66 |
1 files changed, 50 insertions, 16 deletions
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 | ||