]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/process_keycode/process_unicode_common.h
Usbasploader bootloader option addition (#6304)
[qmk_firmware.git] / quantum / process_keycode / process_unicode_common.h
1 /* Copyright 2017 Jack Humbert
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
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/>.
15  */
16
17 #pragma once
18
19 #include "quantum.h"
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_KEY_OSX
27   #define UNICODE_KEY_OSX  KC_LALT
28 #endif
29 #ifndef UNICODE_KEY_LNX
30   #define UNICODE_KEY_LNX  LCTL(LSFT(KC_U))
31 #endif
32 #ifndef UNICODE_KEY_WINC
33   #define UNICODE_KEY_WINC KC_RALT
34 #endif
35
36 // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle)
37 // Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX
38 #ifndef UNICODE_SELECTED_MODES
39   #define UNICODE_SELECTED_MODES -1
40 #endif
41
42 // Whether input mode changes in cycle should be written to EEPROM
43 #ifndef UNICODE_CYCLE_PERSIST
44   #define UNICODE_CYCLE_PERSIST true
45 #endif
46
47 // Delay between starting Unicode input and sending a sequence, in ms
48 #ifndef UNICODE_TYPE_DELAY
49   #define UNICODE_TYPE_DELAY 10
50 #endif
51
52 enum unicode_input_modes {
53   UC_OSX,   // Mac OS X using Unicode Hex Input
54   UC_LNX,   // Linux using IBus
55   UC_WIN,   // Windows using EnableHexNumpad
56   UC_BSD,   // BSD (not implemented)
57   UC_WINC,  // Windows using WinCompose (https://github.com/samhocevar/wincompose)
58   UC__COUNT // Number of available input modes (always leave at the end)
59 };
60
61 typedef union {
62   uint32_t raw;
63   struct {
64     uint8_t input_mode : 8;
65   };
66 } unicode_config_t;
67
68 extern unicode_config_t unicode_config;
69 extern uint8_t          unicode_saved_mods;
70
71 void unicode_input_mode_init(void);
72 uint8_t get_unicode_input_mode(void);
73 void set_unicode_input_mode(uint8_t mode);
74 void cycle_unicode_input_mode(uint8_t offset);
75 void persist_unicode_input_mode(void);
76
77 void unicode_input_start(void);
78 void unicode_input_finish(void);
79 void unicode_input_cancel(void);
80
81 void register_hex(uint16_t hex);
82 void send_unicode_hex_string(const char *str);
83
84 bool process_unicode_common(uint16_t keycode, keyrecord_t *record);
85
86 #define UC_BSPC UC(0x0008)
87 #define UC_SPC  UC(0x0020)
88
89 #define UC_EXLM UC(0x0021)
90 #define UC_DQUT UC(0x0022)
91 #define UC_HASH UC(0x0023)
92 #define UC_DLR  UC(0x0024)
93 #define UC_PERC UC(0x0025)
94 #define UC_AMPR UC(0x0026)
95 #define UC_QUOT UC(0x0027)
96 #define UC_LPRN UC(0x0028)
97 #define UC_RPRN UC(0x0029)
98 #define UC_ASTR UC(0x002A)
99 #define UC_PLUS UC(0x002B)
100 #define UC_COMM UC(0x002C)
101 #define UC_DASH UC(0x002D)
102 #define UC_DOT  UC(0x002E)
103 #define UC_SLSH UC(0x002F)
104
105 #define UC_0    UC(0x0030)
106 #define UC_1    UC(0x0031)
107 #define UC_2    UC(0x0032)
108 #define UC_3    UC(0x0033)
109 #define UC_4    UC(0x0034)
110 #define UC_5    UC(0x0035)
111 #define UC_6    UC(0x0036)
112 #define UC_7    UC(0x0037)
113 #define UC_8    UC(0x0038)
114 #define UC_9    UC(0x0039)
115
116 #define UC_COLN UC(0x003A)
117 #define UC_SCLN UC(0x003B)
118 #define UC_LT   UC(0x003C)
119 #define UC_EQL  UC(0x003D)
120 #define UC_GT   UC(0x003E)
121 #define UC_QUES UC(0x003F)
122 #define UC_AT   UC(0x0040)
123
124 #define UC_A    UC(0x0041)
125 #define UC_B    UC(0x0042)
126 #define UC_C    UC(0x0043)
127 #define UC_D    UC(0x0044)
128 #define UC_E    UC(0x0045)
129 #define UC_F    UC(0x0046)
130 #define UC_G    UC(0x0047)
131 #define UC_H    UC(0x0048)
132 #define UC_I    UC(0x0049)
133 #define UC_J    UC(0x004A)
134 #define UC_K    UC(0x004B)
135 #define UC_L    UC(0x004C)
136 #define UC_M    UC(0x004D)
137 #define UC_N    UC(0x004E)
138 #define UC_O    UC(0x004F)
139 #define UC_P    UC(0x0050)
140 #define UC_Q    UC(0x0051)
141 #define UC_R    UC(0x0052)
142 #define UC_S    UC(0x0053)
143 #define UC_T    UC(0x0054)
144 #define UC_U    UC(0x0055)
145 #define UC_V    UC(0x0056)
146 #define UC_W    UC(0x0057)
147 #define UC_X    UC(0x0058)
148 #define UC_Y    UC(0x0059)
149 #define UC_Z    UC(0x005A)
150
151 #define UC_LBRC UC(0x005B)
152 #define UC_BSLS UC(0x005C)
153 #define UC_RBRC UC(0x005D)
154 #define UC_CIRM UC(0x005E)
155 #define UC_UNDR UC(0x005F)
156
157 #define UC_GRV  UC(0x0060)
158
159 #define UC_a    UC(0x0061)
160 #define UC_b    UC(0x0062)
161 #define UC_c    UC(0x0063)
162 #define UC_d    UC(0x0064)
163 #define UC_e    UC(0x0065)
164 #define UC_f    UC(0x0066)
165 #define UC_g    UC(0x0067)
166 #define UC_h    UC(0x0068)
167 #define UC_i    UC(0x0069)
168 #define UC_j    UC(0x006A)
169 #define UC_k    UC(0x006B)
170 #define UC_l    UC(0x006C)
171 #define UC_m    UC(0x006D)
172 #define UC_n    UC(0x006E)
173 #define UC_o    UC(0x006F)
174 #define UC_p    UC(0x0070)
175 #define UC_q    UC(0x0071)
176 #define UC_r    UC(0x0072)
177 #define UC_s    UC(0x0073)
178 #define UC_t    UC(0x0074)
179 #define UC_u    UC(0x0075)
180 #define UC_v    UC(0x0076)
181 #define UC_w    UC(0x0077)
182 #define UC_x    UC(0x0078)
183 #define UC_y    UC(0x0079)
184 #define UC_z    UC(0x007A)
185
186 #define UC_LCBR UC(0x007B)
187 #define UC_PIPE UC(0x007C)
188 #define UC_RCBR UC(0x007D)
189 #define UC_TILD UC(0x007E)
190 #define UC_DEL  UC(0x007F)