Rev 4240 | Rev 4298 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4240 | Rev 4285 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2009 Jiri Svoboda |
2 | * Copyright (c) 2009 Jiri Svoboda |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup kbd |
29 | /** @addtogroup kbd |
30 | * @brief US QWERTY leyout. |
30 | * @brief US QWERTY leyout. |
31 | * @{ |
31 | * @{ |
32 | */ |
32 | */ |
33 | 33 | ||
34 | #include <kbd.h> |
34 | #include <kbd.h> |
35 | #include <kbd/kbd.h> |
35 | #include <kbd/kbd.h> |
36 | #include <kbd/keycode.h> |
36 | #include <kbd/keycode.h> |
- | 37 | #include <bool.h> |
|
37 | #include <layout.h> |
38 | #include <layout.h> |
38 | 39 | ||
- | 40 | static void layout_reset(void); |
|
39 | static wchar_t layout_parse_ev(kbd_event_t *ev); |
41 | static wchar_t layout_parse_ev(kbd_event_t *ev); |
40 | 42 | ||
- | 43 | enum m_state { |
|
- | 44 | ms_start, |
|
- | 45 | ms_hacek, |
|
- | 46 | ms_carka |
|
- | 47 | }; |
|
- | 48 | ||
- | 49 | static enum m_state mstate; |
|
- | 50 | ||
41 | layout_op_t cz_op = { |
51 | layout_op_t cz_op = { |
- | 52 | layout_reset, |
|
42 | layout_parse_ev |
53 | layout_parse_ev |
43 | }; |
54 | }; |
44 | 55 | ||
45 | static wchar_t map_lcase[] = { |
56 | static wchar_t map_lcase[] = { |
46 | [KC_2] = L'ě', |
57 | [KC_2] = L'ě', |
47 | [KC_3] = L'š', |
58 | [KC_3] = L'š', |
48 | [KC_4] = L'č', |
59 | [KC_4] = L'č', |
49 | [KC_5] = L'ř', |
60 | [KC_5] = L'ř', |
50 | [KC_6] = L'ž', |
61 | [KC_6] = L'ž', |
51 | [KC_7] = L'ý', |
62 | [KC_7] = L'ý', |
52 | [KC_8] = L'á', |
63 | [KC_8] = L'á', |
53 | [KC_9] = L'í', |
64 | [KC_9] = L'í', |
54 | [KC_0] = L'é', |
65 | [KC_0] = L'é', |
55 | 66 | ||
56 | [KC_LBRACKET] = L'ú', |
67 | [KC_LBRACKET] = L'ú', |
57 | [KC_SEMICOLON] = L'ů', |
68 | [KC_SEMICOLON] = L'ů', |
58 | 69 | ||
59 | [KC_Q] = 'q', |
70 | [KC_Q] = 'q', |
60 | [KC_W] = 'w', |
71 | [KC_W] = 'w', |
61 | [KC_E] = 'e', |
72 | [KC_E] = 'e', |
62 | [KC_R] = 'r', |
73 | [KC_R] = 'r', |
63 | [KC_T] = 't', |
74 | [KC_T] = 't', |
64 | [KC_Y] = 'z', |
75 | [KC_Y] = 'z', |
65 | [KC_U] = 'u', |
76 | [KC_U] = 'u', |
66 | [KC_I] = 'i', |
77 | [KC_I] = 'i', |
67 | [KC_O] = 'o', |
78 | [KC_O] = 'o', |
68 | [KC_P] = 'p', |
79 | [KC_P] = 'p', |
69 | 80 | ||
70 | [KC_A] = 'a', |
81 | [KC_A] = 'a', |
71 | [KC_S] = 's', |
82 | [KC_S] = 's', |
72 | [KC_D] = 'd', |
83 | [KC_D] = 'd', |
73 | [KC_F] = 'f', |
84 | [KC_F] = 'f', |
74 | [KC_G] = 'g', |
85 | [KC_G] = 'g', |
75 | [KC_H] = 'h', |
86 | [KC_H] = 'h', |
76 | [KC_J] = 'j', |
87 | [KC_J] = 'j', |
77 | [KC_K] = 'k', |
88 | [KC_K] = 'k', |
78 | [KC_L] = 'l', |
89 | [KC_L] = 'l', |
79 | 90 | ||
80 | [KC_Z] = 'y', |
91 | [KC_Z] = 'y', |
81 | [KC_X] = 'x', |
92 | [KC_X] = 'x', |
82 | [KC_C] = 'c', |
93 | [KC_C] = 'c', |
83 | [KC_V] = 'v', |
94 | [KC_V] = 'v', |
84 | [KC_B] = 'b', |
95 | [KC_B] = 'b', |
85 | [KC_N] = 'n', |
96 | [KC_N] = 'n', |
86 | [KC_M] = 'm', |
97 | [KC_M] = 'm', |
87 | }; |
98 | }; |
88 | 99 | ||
89 | static wchar_t map_ucase[] = { |
100 | static wchar_t map_ucase[] = { |
90 | [KC_2] = L'Ě', |
101 | [KC_2] = L'Ě', |
91 | [KC_3] = L'Š', |
102 | [KC_3] = L'Š', |
92 | [KC_4] = L'Č', |
103 | [KC_4] = L'Č', |
93 | [KC_5] = L'Ř', |
104 | [KC_5] = L'Ř', |
94 | [KC_6] = L'Ž', |
105 | [KC_6] = L'Ž', |
95 | [KC_7] = L'Ý', |
106 | [KC_7] = L'Ý', |
96 | [KC_8] = L'Á', |
107 | [KC_8] = L'Á', |
97 | [KC_9] = L'Í', |
108 | [KC_9] = L'Í', |
98 | [KC_0] = L'É', |
109 | [KC_0] = L'É', |
99 | 110 | ||
100 | [KC_LBRACKET] = L'Ú', |
111 | [KC_LBRACKET] = L'Ú', |
101 | [KC_SEMICOLON] = L'Ů', |
112 | [KC_SEMICOLON] = L'Ů', |
102 | 113 | ||
103 | [KC_Q] = 'Q', |
114 | [KC_Q] = 'Q', |
104 | [KC_W] = 'W', |
115 | [KC_W] = 'W', |
105 | [KC_E] = 'E', |
116 | [KC_E] = 'E', |
106 | [KC_R] = 'R', |
117 | [KC_R] = 'R', |
107 | [KC_T] = 'T', |
118 | [KC_T] = 'T', |
108 | [KC_Y] = 'Z', |
119 | [KC_Y] = 'Z', |
109 | [KC_U] = 'U', |
120 | [KC_U] = 'U', |
110 | [KC_I] = 'I', |
121 | [KC_I] = 'I', |
111 | [KC_O] = 'O', |
122 | [KC_O] = 'O', |
112 | [KC_P] = 'P', |
123 | [KC_P] = 'P', |
113 | 124 | ||
114 | [KC_A] = 'A', |
125 | [KC_A] = 'A', |
115 | [KC_S] = 'S', |
126 | [KC_S] = 'S', |
116 | [KC_D] = 'D', |
127 | [KC_D] = 'D', |
117 | [KC_F] = 'F', |
128 | [KC_F] = 'F', |
118 | [KC_G] = 'G', |
129 | [KC_G] = 'G', |
119 | [KC_H] = 'H', |
130 | [KC_H] = 'H', |
120 | [KC_J] = 'J', |
131 | [KC_J] = 'J', |
121 | [KC_K] = 'K', |
132 | [KC_K] = 'K', |
122 | [KC_L] = 'L', |
133 | [KC_L] = 'L', |
123 | 134 | ||
124 | [KC_Z] = 'Y', |
135 | [KC_Z] = 'Y', |
125 | [KC_X] = 'X', |
136 | [KC_X] = 'X', |
126 | [KC_C] = 'C', |
137 | [KC_C] = 'C', |
127 | [KC_V] = 'V', |
138 | [KC_V] = 'V', |
128 | [KC_B] = 'B', |
139 | [KC_B] = 'B', |
129 | [KC_N] = 'N', |
140 | [KC_N] = 'N', |
130 | [KC_M] = 'M', |
141 | [KC_M] = 'M', |
131 | }; |
142 | }; |
132 | 143 | ||
133 | static wchar_t map_not_shifted[] = { |
144 | static wchar_t map_not_shifted[] = { |
134 | [KC_BACKTICK] = ';', |
145 | [KC_BACKTICK] = ';', |
135 | 146 | ||
136 | [KC_1] = '+', |
147 | [KC_1] = '+', |
137 | 148 | ||
138 | [KC_MINUS] = '=', |
149 | [KC_MINUS] = '=', |
139 | 150 | ||
140 | [KC_RBRACKET] = ')', |
151 | [KC_RBRACKET] = ')', |
141 | 152 | ||
142 | [KC_QUOTE] = L'§', |
153 | [KC_QUOTE] = L'§', |
143 | 154 | ||
144 | [KC_COMMA] = ',', |
155 | [KC_COMMA] = ',', |
145 | [KC_PERIOD] = '.', |
156 | [KC_PERIOD] = '.', |
146 | [KC_SLASH] = '-', |
157 | [KC_SLASH] = '-', |
147 | }; |
158 | }; |
148 | 159 | ||
149 | static wchar_t map_shifted[] = { |
160 | static wchar_t map_shifted[] = { |
150 | [KC_1] = '1', |
161 | [KC_1] = '1', |
151 | [KC_2] = '2', |
162 | [KC_2] = '2', |
152 | [KC_3] = '3', |
163 | [KC_3] = '3', |
153 | [KC_4] = '4', |
164 | [KC_4] = '4', |
154 | [KC_5] = '5', |
165 | [KC_5] = '5', |
155 | [KC_6] = '6', |
166 | [KC_6] = '6', |
156 | [KC_7] = '7', |
167 | [KC_7] = '7', |
157 | [KC_8] = '8', |
168 | [KC_8] = '8', |
158 | [KC_9] = '9', |
169 | [KC_9] = '9', |
159 | [KC_0] = '0', |
170 | [KC_0] = '0', |
160 | 171 | ||
161 | [KC_MINUS] = '%', |
172 | [KC_MINUS] = '%', |
162 | 173 | ||
163 | [KC_LBRACKET] = '/', |
174 | [KC_LBRACKET] = '/', |
164 | [KC_RBRACKET] = '(', |
175 | [KC_RBRACKET] = '(', |
165 | 176 | ||
166 | [KC_SEMICOLON] = '"', |
177 | [KC_SEMICOLON] = '"', |
167 | [KC_QUOTE] = '!', |
178 | [KC_QUOTE] = '!', |
168 | [KC_BACKSLASH] = '\'', |
179 | [KC_BACKSLASH] = '\'', |
169 | 180 | ||
170 | [KC_COMMA] = '?', |
181 | [KC_COMMA] = '?', |
171 | [KC_PERIOD] = ':', |
182 | [KC_PERIOD] = ':', |
172 | [KC_SLASH] = '_', |
183 | [KC_SLASH] = '_', |
173 | }; |
184 | }; |
174 | 185 | ||
175 | static wchar_t map_neutral[] = { |
186 | static wchar_t map_neutral[] = { |
176 | [KC_BACKSPACE] = '\b', |
187 | [KC_BACKSPACE] = '\b', |
177 | [KC_TAB] = '\t', |
188 | [KC_TAB] = '\t', |
178 | [KC_ENTER] = '\n', |
189 | [KC_ENTER] = '\n', |
179 | [KC_SPACE] = ' ', |
190 | [KC_SPACE] = ' ', |
180 | 191 | ||
181 | [KC_NSLASH] = '/', |
192 | [KC_NSLASH] = '/', |
182 | [KC_NTIMES] = '*', |
193 | [KC_NTIMES] = '*', |
183 | [KC_NMINUS] = '-', |
194 | [KC_NMINUS] = '-', |
184 | [KC_NPLUS] = '+', |
195 | [KC_NPLUS] = '+', |
185 | [KC_NENTER] = '\n' |
196 | [KC_NENTER] = '\n' |
186 | }; |
197 | }; |
187 | 198 | ||
188 | static wchar_t map_numeric[] = { |
199 | static wchar_t map_numeric[] = { |
189 | [KC_N7] = '7', |
200 | [KC_N7] = '7', |
190 | [KC_N8] = '8', |
201 | [KC_N8] = '8', |
191 | [KC_N9] = '9', |
202 | [KC_N9] = '9', |
192 | [KC_N4] = '4', |
203 | [KC_N4] = '4', |
193 | [KC_N5] = '5', |
204 | [KC_N5] = '5', |
194 | [KC_N6] = '6', |
205 | [KC_N6] = '6', |
195 | [KC_N1] = '1', |
206 | [KC_N1] = '1', |
196 | [KC_N2] = '2', |
207 | [KC_N2] = '2', |
197 | [KC_N3] = '3', |
208 | [KC_N3] = '3', |
198 | 209 | ||
199 | [KC_N0] = '0', |
210 | [KC_N0] = '0', |
200 | [KC_NPERIOD] = '.' |
211 | [KC_NPERIOD] = '.' |
201 | }; |
212 | }; |
202 | 213 | ||
- | 214 | static wchar_t map_hacek_lcase[] = { |
|
- | 215 | [KC_E] = L'ě', |
|
- | 216 | [KC_R] = L'ř', |
|
- | 217 | [KC_T] = L'ť', |
|
- | 218 | [KC_Y] = L'ž', |
|
- | 219 | [KC_U] = L'ů', |
|
- | 220 | ||
- | 221 | [KC_S] = L'š', |
|
- | 222 | [KC_D] = L'ď', |
|
- | 223 | ||
- | 224 | [KC_C] = L'č', |
|
- | 225 | [KC_N] = L'ň' |
|
- | 226 | }; |
|
- | 227 | ||
- | 228 | static wchar_t map_hacek_ucase[] = { |
|
- | 229 | [KC_E] = L'Ě', |
|
- | 230 | [KC_R] = L'Ř', |
|
- | 231 | [KC_T] = L'Ť', |
|
- | 232 | [KC_Y] = L'Ž', |
|
- | 233 | [KC_U] = L'Ů', |
|
- | 234 | ||
- | 235 | [KC_S] = L'Š', |
|
- | 236 | [KC_D] = L'Ď', |
|
- | 237 | ||
- | 238 | [KC_C] = L'Č', |
|
- | 239 | [KC_N] = L'Ň' |
|
- | 240 | }; |
|
- | 241 | ||
- | 242 | static wchar_t map_carka_lcase[] = { |
|
- | 243 | [KC_E] = L'é', |
|
- | 244 | [KC_U] = L'ú', |
|
- | 245 | [KC_I] = L'í', |
|
- | 246 | [KC_O] = L'ó', |
|
- | 247 | ||
- | 248 | [KC_A] = L'á', |
|
- | 249 | ||
- | 250 | [KC_Z] = L'ý', |
|
- | 251 | }; |
|
- | 252 | ||
- | 253 | static wchar_t map_carka_ucase[] = { |
|
- | 254 | [KC_E] = L'É', |
|
- | 255 | [KC_U] = L'Ú', |
|
- | 256 | [KC_I] = L'Í', |
|
- | 257 | [KC_O] = L'Ó', |
|
- | 258 | ||
- | 259 | [KC_A] = L'Á', |
|
- | 260 | ||
- | 261 | [KC_Z] = L'Ý', |
|
- | 262 | }; |
|
- | 263 | ||
203 | static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length) |
264 | static wchar_t translate(unsigned int key, wchar_t *map, size_t map_length) |
204 | { |
265 | { |
205 | if (key >= map_length) |
266 | if (key >= map_length) |
206 | return 0; |
267 | return 0; |
207 | return map[key]; |
268 | return map[key]; |
208 | } |
269 | } |
209 | 270 | ||
210 | static wchar_t layout_parse_ev(kbd_event_t *ev) |
271 | static wchar_t parse_ms_hacek(kbd_event_t *ev) |
- | 272 | { |
|
- | 273 | wchar_t c; |
|
- | 274 | ||
- | 275 | mstate = ms_start; |
|
- | 276 | ||
- | 277 | /* Produce no characters when Ctrl or Alt is pressed. */ |
|
- | 278 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
|
- | 279 | return 0; |
|
- | 280 | ||
- | 281 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
|
- | 282 | c = translate(ev->key, map_hacek_ucase, sizeof(map_hacek_ucase) / sizeof(wchar_t)); |
|
- | 283 | else |
|
- | 284 | c = translate(ev->key, map_hacek_lcase, sizeof(map_hacek_lcase) / sizeof(wchar_t)); |
|
- | 285 | ||
- | 286 | return c; |
|
- | 287 | } |
|
- | 288 | ||
- | 289 | static wchar_t parse_ms_carka(kbd_event_t *ev) |
|
211 | { |
290 | { |
212 | wchar_t c; |
291 | wchar_t c; |
213 | 292 | ||
- | 293 | mstate = ms_start; |
|
- | 294 | ||
214 | /* Produce no characters when Ctrl or Alt is pressed. */ |
295 | /* Produce no characters when Ctrl or Alt is pressed. */ |
215 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
296 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
216 | return 0; |
297 | return 0; |
217 | 298 | ||
- | 299 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
|
- | 300 | c = translate(ev->key, map_carka_ucase, sizeof(map_carka_ucase) / sizeof(wchar_t)); |
|
- | 301 | else |
|
- | 302 | c = translate(ev->key, map_carka_lcase, sizeof(map_carka_lcase) / sizeof(wchar_t)); |
|
- | 303 | ||
- | 304 | return c; |
|
- | 305 | } |
|
- | 306 | ||
- | 307 | static wchar_t parse_ms_start(kbd_event_t *ev) |
|
- | 308 | { |
|
- | 309 | wchar_t c; |
|
- | 310 | ||
- | 311 | /* Produce no characters when Ctrl or Alt is pressed. */ |
|
- | 312 | if ((ev->mods & (KM_CTRL | KM_ALT)) != 0) |
|
- | 313 | return 0; |
|
- | 314 | ||
- | 315 | if (ev->key == KC_EQUALS) { |
|
- | 316 | if ((ev->mods & KM_SHIFT) != 0) |
|
- | 317 | mstate = ms_hacek; |
|
- | 318 | else |
|
- | 319 | mstate = ms_carka; |
|
- | 320 | ||
- | 321 | return 0; |
|
- | 322 | } |
|
- | 323 | ||
218 | c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t)); |
324 | c = translate(ev->key, map_neutral, sizeof(map_neutral) / sizeof(wchar_t)); |
219 | if (c != 0) |
325 | if (c != 0) |
220 | return c; |
326 | return c; |
221 | 327 | ||
222 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
328 | if (((ev->mods & KM_SHIFT) != 0) ^ ((ev->mods & KM_CAPS_LOCK) != 0)) |
223 | c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t)); |
329 | c = translate(ev->key, map_ucase, sizeof(map_ucase) / sizeof(wchar_t)); |
224 | else |
330 | else |
225 | c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t)); |
331 | c = translate(ev->key, map_lcase, sizeof(map_lcase) / sizeof(wchar_t)); |
226 | 332 | ||
227 | if (c != 0) |
333 | if (c != 0) |
228 | return c; |
334 | return c; |
229 | 335 | ||
230 | if ((ev->mods & KM_SHIFT) != 0) |
336 | if ((ev->mods & KM_SHIFT) != 0) |
231 | c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t)); |
337 | c = translate(ev->key, map_shifted, sizeof(map_shifted) / sizeof(wchar_t)); |
232 | else |
338 | else |
233 | c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t)); |
339 | c = translate(ev->key, map_not_shifted, sizeof(map_not_shifted) / sizeof(wchar_t)); |
234 | 340 | ||
235 | if (c != 0) |
341 | if (c != 0) |
236 | return c; |
342 | return c; |
237 | 343 | ||
238 | if ((ev->mods & KM_NUM_LOCK) != 0) |
344 | if ((ev->mods & KM_NUM_LOCK) != 0) |
239 | c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t)); |
345 | c = translate(ev->key, map_numeric, sizeof(map_numeric) / sizeof(wchar_t)); |
240 | else |
346 | else |
241 | c = 0; |
347 | c = 0; |
242 | 348 | ||
243 | return c; |
349 | return c; |
244 | } |
350 | } |
- | 351 | ||
- | 352 | static bool key_is_mod(unsigned key) |
|
- | 353 | { |
|
- | 354 | switch (key) { |
|
- | 355 | case KC_LSHIFT: |
|
- | 356 | case KC_RSHIFT: |
|
- | 357 | case KC_LALT: |
|
- | 358 | case KC_RALT: |
|
- | 359 | case KC_LCTRL: |
|
- | 360 | case KC_RCTRL: |
|
- | 361 | return true; |
|
- | 362 | default: |
|
- | 363 | return false; |
|
- | 364 | } |
|
- | 365 | } |
|
- | 366 | ||
- | 367 | static void layout_reset(void) |
|
- | 368 | { |
|
- | 369 | mstate = ms_start; |
|
- | 370 | } |
|
- | 371 | ||
- | 372 | static wchar_t layout_parse_ev(kbd_event_t *ev) |
|
- | 373 | { |
|
- | 374 | if (ev->type != KE_PRESS) |
|
- | 375 | return '\0'; |
|
- | 376 | ||
- | 377 | if (key_is_mod(ev->key)) |
|
- | 378 | return '\0'; |
|
- | 379 | ||
- | 380 | switch (mstate) { |
|
- | 381 | case ms_start: return parse_ms_start(ev); |
|
- | 382 | case ms_hacek: return parse_ms_hacek(ev); |
|
- | 383 | case ms_carka: return parse_ms_carka(ev); |
|
- | 384 | } |
|
- | 385 | } |
|
245 | 386 | ||
246 | /** |
387 | /** |
247 | * @} |
388 | * @} |
248 | */ |
389 | */ |
249 | 390 |