Create a branch for header work.
[reactos.git] / dll / keyboard / kbdcz1 / kbdcz1.c
1 /*
2 * ReactOS Czech (QWERTY) ASCII Keyboard layout
3 * Copyright (C) 2007 ReactOS
4 * License: LGPL, see: LGPL.txt
5 *
6 * Based on other kbd*.dlls
7 * modified by Kamil Hornicek (tykef at atlas dot cz)
8 */
9
10 #include <windows.h>
11 #include <internal/kbd.h>
12
13 #ifdef _M_IA64
14 #define ROSDATA static __declspec(allocate(".data"))
15 #else
16 #ifdef _MSC_VER
17 #pragma data_seg(".data")
18 #define ROSDATA static
19 #else
20 #define ROSDATA static __attribute__((section(".data")))
21 #endif
22 #endif
23
24 #define VK_EMPTY 0xff /* The non-existent VK */
25 #define KSHIFT 0x001 /* Shift modifier */
26 #define KCTRL 0x002 /* Ctrl modifier */
27 #define KALT 0x004 /* Alt modifier */
28 #define KEXT 0x100 /* Extended key code */
29 #define KMULTI 0x200 /* Multi-key */
30 #define KSPEC 0x400 /* Special key */
31 #define KNUMP 0x800 /* Number-pad */
32 #define KNUMS 0xc00 /* Special + number pad */
33 #define KMEXT 0x300 /* Multi + ext */
34
35 #define SHFT_INVALID 0x0F
36
37 ROSDATA USHORT scancode_to_vk[] = {
38 /* Numbers Row */
39 /* - 00 - */
40 /* 1 ... 2 ... 3 ... 4 ... */
41 VK_EMPTY, VK_ESCAPE, '1', '2',
42 '3', '4', '5', '6',
43 '7', '8', '9', '0',
44 VK_OEM_MINUS, VK_OEM_PLUS, VK_BACK,
45 /* - 0f - */
46 /* First Letters Row */
47 VK_TAB, 'Q', 'W', 'E',
48 'R', 'T', 'Y', 'U',
49 'I', 'O', 'P',
50 VK_OEM_4, VK_OEM_6, VK_RETURN,
51 /* - 1d - */
52 /* Second Letters Row */
53 VK_LCONTROL,
54 'A', 'S', 'D', 'F',
55 'G', 'H', 'J', 'K',
56 'L', VK_OEM_1, VK_OEM_7, VK_OEM_3,
57 VK_LSHIFT, VK_OEM_5,
58 /* - 2c - */
59 /* Third letters row */
60 'Z', 'X', 'C', 'V',
61 'B', 'N', 'M', VK_OEM_COMMA,
62 VK_OEM_PERIOD,VK_OEM_2, VK_RSHIFT,
63 /* - 37 - */
64 /* Bottom Row */
65 VK_MULTIPLY, VK_LMENU, VK_SPACE, VK_CAPITAL,
66
67 /* - 3b - */
68 /* F-Keys */
69 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
70 VK_F7, VK_F8, VK_F9, VK_F10,
71 /* - 45 - */
72 /* Locks */
73 VK_NUMLOCK | KMEXT,
74 VK_SCROLL | KMULTI,
75 /* - 47 - */
76 /* Number-Pad */
77 VK_HOME | KNUMS, VK_UP | KNUMS, VK_PRIOR | KNUMS, VK_SUBTRACT,
78 VK_LEFT | KNUMS, VK_CLEAR | KNUMS, VK_RIGHT | KNUMS, VK_ADD,
79 VK_END | KNUMS, VK_DOWN | KNUMS, VK_NEXT | KNUMS,
80 VK_INSERT | KNUMS, VK_DELETE | KNUMS,
81 /* - 54 - */
82 /* Presumably PrtSc */
83 VK_SNAPSHOT,
84 /* - 55 - */
85 /* Oddities, and the remaining standard F-Keys */
86 VK_EMPTY, VK_EMPTY, VK_F11, VK_F12,
87 /* - 59 - */
88 VK_CLEAR, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* EREOF */
89 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* ZOOM */
90 VK_HELP,
91 /* - 64 - */
92 /* Even more F-Keys (for example, NCR keyboards from the early 90's) */
93 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19, VK_F20,
94 VK_F21, VK_F22, VK_F23,
95 /* - 6f - */
96 /* Not sure who uses these codes */
97 VK_EMPTY, VK_EMPTY, VK_EMPTY,
98 /* - 72 - */
99 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
100 /* - 76 - */
101 /* One more f-key */
102 VK_F24,
103 /* - 77 - */
104 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
105 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* PA1 */
106 VK_EMPTY,
107 /* - 80 - */
108 0
109 };
110
111 ROSDATA VSC_VK extcode0_to_vk[] = {
112 { 0, 0 },
113 };
114
115 ROSDATA VSC_VK extcode1_to_vk[] = {
116 { 0, 0 },
117 };
118
119 ROSDATA VK_TO_BIT modifier_keys[] = {
120 { VK_SHIFT, KSHIFT },
121 { VK_CONTROL, KCTRL },
122 { VK_MENU, KALT },
123 { 0, 0 }
124 };
125
126 ROSDATA MODIFIERS modifier_bits = {
127 modifier_keys,
128 7,
129 { 0, 1, 2, 0, 0, 0, 3, 0 }
130 /* Modifier bit order: NONE, SHIFT, CTRL, SHIFT-CTRL, ALT (not used), SHIFT-ALT (not used), CTRL-ALT, SHIFT-CTRL-ALT */
131 };
132
133 #define NOCAPS 0
134 #define CAPS KSHIFT /* Caps -> shift */
135
136 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod[] = {
137 /* Keys that do not have shift states */
138 { VK_TAB, NOCAPS, {'\t','\t'} },
139 { VK_ADD, NOCAPS, {'+', '+'} },
140 { VK_SUBTRACT, NOCAPS, {'-', '-'} },
141 { VK_MULTIPLY, NOCAPS, {'*', '*'} },
142 { VK_DIVIDE, NOCAPS, {'/', '/'} },
143 { VK_OEM_2 ,NOCAPS, {'-', '_'} },
144 { VK_ESCAPE, NOCAPS, {'\x1b','\x1b'} },
145 { VK_SPACE, NOCAPS, {' ', ' '} },
146 { 0, 0 }
147 };
148
149
150 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod[] = {
151 /* normal - shift - ctrl */
152 /* The alphabet */
153 { 'A', CAPS, {'a', 'A', 0x01} },
154 { 'B', CAPS, {'b', 'B', 0x02} },
155 { 'C', CAPS, {'c', 'C', 0x03} },
156 { 'D', CAPS, {'d', 'D', 0x04} },
157 { 'F', CAPS, {'f', 'F', 0x06} },
158 { 'G', CAPS, {'g', 'G', 0x07} },
159 { 'H', CAPS, {'h', 'H', 0x08} },
160 { 'I', CAPS, {'i', 'I', 0x09} },
161 { 'J', CAPS, {'j', 'J', 0x0a} },
162 { 'K', CAPS, {'k', 'K', 0x0b} },
163 { 'L', CAPS, {'l', 'L', 0x0c} },
164 { 'M', CAPS, {'m', 'M', 0x0d} },
165 { 'N', CAPS, {'n', 'N', 0x0e} },
166 { 'O', CAPS, {'o', 'O', 0x0f} },
167 { 'P', CAPS, {'p', 'P', 0x10} },
168 { 'Q', CAPS, {'q', 'Q', 0x11} },
169 { 'R', CAPS, {'r', 'R', 0x12} },
170 { 'S', CAPS, {'s', 'S', 0x13} },
171 { 'T', CAPS, {'t', 'T', 0x14} },
172 { 'U', CAPS, {'u', 'U', 0x15} },
173 { 'V', CAPS, {'v', 'V', 0x16} },
174 { 'W', CAPS, {'w', 'W', 0x17} },
175 { 'X', CAPS, {'x', 'X', 0x18} },
176 { 'Y', CAPS, {'y', 'Y', 0x19} },
177 { 'Z', CAPS, {'z', 'Z', 0x1a} },
178
179 /* Legacy (telnet-style) ascii escapes */
180 { VK_RETURN, NOCAPS, {'\r', '\r', '\n'} },
181 { 0,0 }
182 };
183
184 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod[] = {
185 /* Normal, shifted, control, Alt+Gr */
186 { '1', NOCAPS, {'+', '1', WCH_NONE, '!' } },
187 { '2', NOCAPS, {0x011b, '2', 0, '@' } }, // e with caron
188 { '3', NOCAPS, {0x0161, '3', WCH_NONE, '#' } }, // s with caron
189 { '4', NOCAPS, {0x010d, '4', WCH_NONE, '$' } }, // c with caron
190 { '5', NOCAPS, {0x0159, '5', WCH_NONE, '%' } }, // r with caron
191 { '6', NOCAPS, {0x017e, '6', 0x1e, '^' } }, // z with caron
192 { '7', NOCAPS, {0x00fd, '7', WCH_NONE, '&' } }, // y with acute
193 { '8', NOCAPS, {0x00e1, '8', WCH_NONE, '*' } }, // a with acute
194 { '9', NOCAPS, {0x00ed, '9', WCH_NONE, '(' } }, // i with acute
195 { '0', NOCAPS, {0x00e9, '0', WCH_NONE, ')' } }, // e with acute
196 { VK_OEM_PLUS, NOCAPS, {WCH_DEAD, WCH_DEAD, WCH_NONE, '=' } }, // dead letters - acute, caron
197 { VK_EMPTY, 0, {0x00b4, 0x02c7, WCH_NONE, WCH_NONE } }, // VK_OEM_PLUS death
198 { VK_OEM_MINUS, NOCAPS, {'=', '%', 0x1f, '-' } },
199 { VK_OEM_1, NOCAPS, {0x016f, '\"', WCH_NONE, ';' } }, // u with ring
200 { VK_OEM_7, NOCAPS, {0x00a7, '!', WCH_NONE, 0x00a4 } }, // section sign
201 { VK_OEM_4, NOCAPS, {0x00fa, '/', WCH_NONE, '[' } }, // u with acute
202 { VK_OEM_5, NOCAPS, {WCH_DEAD, 0x2018, WCH_NONE, '\\' } }, // diaeresis, left single quotation mark
203 { VK_EMPTY, 0, {0x00a8, WCH_NONE, WCH_NONE, WCH_NONE } }, // VK_OEM_5 death
204 { VK_OEM_6, NOCAPS, {')', '(', WCH_NONE, ']' } },
205 { VK_OEM_3, NOCAPS, {';', WCH_DEAD, WCH_NONE, '`' } }, // ring
206 { VK_EMPTY, 0, {WCH_NONE, 0x00b0, WCH_NONE, WCH_NONE } }, // VK_OEM_3 death
207 { VK_OEM_COMMA, NOCAPS, {',', '?', WCH_NONE, '<' } },
208 { VK_OEM_PERIOD, NOCAPS, {'.', ':', WCH_NONE, '>' } },
209 { 'E', CAPS, {'e', 'E', 0x05, 0x20AC } }, // symbol for euro (currency)
210 { 0, 0 }
211 };
212
213
214 ROSDATA VK_TO_WCHARS1 keypad_numbers[] = {
215 { VK_DECIMAL, 0, {','} },
216 { VK_NUMPAD0, 0, {'0'} },
217 { VK_NUMPAD1, 0, {'1'} },
218 { VK_NUMPAD2, 0, {'2'} },
219 { VK_NUMPAD3, 0, {'3'} },
220 { VK_NUMPAD4, 0, {'4'} },
221 { VK_NUMPAD5, 0, {'5'} },
222 { VK_NUMPAD6, 0, {'6'} },
223 { VK_NUMPAD7, 0, {'7'} },
224 { VK_NUMPAD8, 0, {'8'} },
225 { VK_NUMPAD9, 0, {'9'} },
226 { VK_BACK, 0, {'\010'} },
227 { 0, 0 }
228 };
229
230 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) }
231
232 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table[] = {
233 vk_master(1,keypad_numbers),
234 vk_master(2,key_to_chars_2mod),
235 vk_master(3,key_to_chars_3mod),
236 vk_master(4,key_to_chars_4mod),
237 { 0,0,0 }
238 };
239
240 ROSDATA VSC_LPWSTR key_names[] = {
241 { 0x00, L"" },
242 { 0x01, L"Esc" },
243 { 0x0e, L"Backspace" },
244 { 0x0f, L"Tab" },
245 { 0x1c, L"Enter" },
246 { 0x1d, L"Ctrl" },
247 { 0x2a, L"Shift" },
248 { 0x36, L"Right Shift" },
249 { 0x37, L"Num *" },
250 { 0x38, L"Alt" },
251 { 0x39, L"Space" },
252 { 0x3a, L"Caps Lock" },
253 { 0x3b, L"F1" },
254 { 0x3c, L"F2" },
255 { 0x3d, L"F3" },
256 { 0x3e, L"F4" },
257 { 0x3f, L"F5" },
258 { 0x40, L"F6" },
259 { 0x41, L"F7" },
260 { 0x42, L"F8" },
261 { 0x43, L"F9" },
262 { 0x44, L"F10" },
263 { 0x45, L"Pause" },
264 { 0x46, L"Scroll Lock" },
265 { 0x47, L"Num 7" },
266 { 0x48, L"Num 8" },
267 { 0x49, L"Num 9" },
268 { 0x4a, L"Num -" },
269 { 0x4b, L"Num 4" },
270 { 0x4c, L"Num 5" },
271 { 0x4d, L"Num 6" },
272 { 0x4e, L"Num +" },
273 { 0x4f, L"Num 1" },
274 { 0x50, L"Num 2" },
275 { 0x51, L"Num 3" },
276 { 0x52, L"Num 0" },
277 { 0x53, L"Num Del" },
278 { 0x54, L"Sys Req" },
279 { 0x57, L"F11" },
280 { 0x58, L"F12" },
281 { 0x7c, L"F13" },
282 { 0x7d, L"F14" },
283 { 0x7e, L"F15" },
284 { 0x7f, L"F16" },
285 { 0x80, L"F17" },
286 { 0x81, L"F18" },
287 { 0x82, L"F19" },
288 { 0x83, L"F20" },
289 { 0x84, L"F21" },
290 { 0x85, L"F22" },
291 { 0x86, L"F23" },
292 { 0x87, L"F24" },
293 { 0, NULL },
294 };
295
296 ROSDATA VSC_LPWSTR extended_key_names[] = {
297 { 0x1c, L"Num Enter" },
298 { 0x1d, L"Right Ctrl" },
299 { 0x35, L"Num /" },
300 { 0x37, L"Prnt Scrn" },
301 { 0x38, L"Right Alt" },
302 { 0x45, L"Num Lock" },
303 { 0x46, L"Break" },
304 { 0x47, L"Home" },
305 { 0x48, L"Up" },
306 { 0x49, L"Page Up" },
307 { 0x4a, L"Left" },
308 { 0x4c, L"Center" },
309 { 0x4d, L"Right" },
310 { 0x4f, L"End" },
311 { 0x50, L"Down" },
312 { 0x51, L"Page Down" },
313 { 0x52, L"Insert" },
314 { 0x53, L"Delete" },
315 { 0x54, L"<ReactOS>" },
316 { 0x55, L"Help" },
317 { 0x56, L"Left Windows" },
318 { 0x5b, L"Right Windows" },
319 { 0, NULL },
320 };
321
322 #define DEADTRANS(ch, accent, comp, flags) MAKELONG(ch, accent), comp, flags
323
324 ROSDATA DEADKEY dead_key[] = {
325 { DEADTRANS(0x0043, 0x02c7, 0x010c, 0x0000) }, // C with caron
326 { DEADTRANS(0x0063, 0x02c7, 0x010d, 0x0000) }, // c with caron
327 { DEADTRANS(0x0045, 0x02c7, 0x011a, 0x0000) }, // E with caron
328 { DEADTRANS(0x0065, 0x02c7, 0x011b, 0x0000) }, // e with caron
329 { DEADTRANS(0x0044, 0x02c7, 0x010e, 0x0000) }, // D with caron
330 { DEADTRANS(0x0064, 0x02c7, 0x010f, 0x0000) }, // d with caron
331 { DEADTRANS(0x004c, 0x02c7, 0x013d, 0x0000) }, // L with caron
332 { DEADTRANS(0x006c, 0x02c7, 0x013e, 0x0000) }, // l with caron
333 { DEADTRANS(0x004e, 0x02c7, 0x0147, 0x0000) }, // N with caron
334 { DEADTRANS(0x006e, 0x02c7, 0x0148, 0x0000) }, // n with caron
335 { DEADTRANS(0x0053, 0x02c7, 0x0160, 0x0000) }, // S with caron
336 { DEADTRANS(0x0073, 0x02c7, 0x0161, 0x0000) }, // s with caron
337 { DEADTRANS(0x0052, 0x02c7, 0x0158, 0x0000) }, // R with acute
338 { DEADTRANS(0x0072, 0x02c7, 0x0159, 0x0000) }, // r with acute
339 { DEADTRANS(0x0054, 0x02c7, 0x0164, 0x0000) }, // T with caron
340 { DEADTRANS(0x0074, 0x02c7, 0x0165, 0x0000) }, // t with caron
341 { DEADTRANS(0x005a, 0x02c7, 0x017d, 0x0000) }, // Z with caron
342 { DEADTRANS(0x007a, 0x02c7, 0x017e, 0x0000) }, // z with caron
343 { DEADTRANS(0x0020, 0x02c7, 0x02c7, 0x0000) }, // space > caron
344
345 { DEADTRANS(0x0041, 0x00b4, 0x00c1, 0x0000) }, // A with acute
346 { DEADTRANS(0x0061, 0x00b4, 0x00e1, 0x0000) }, // a with acute
347 { DEADTRANS(0x0045, 0x00b4, 0x00c9, 0x0000) }, // E with acute
348 { DEADTRANS(0x0065, 0x00b4, 0x00e9, 0x0000) }, // e with acute
349 { DEADTRANS(0x0049, 0x00b4, 0x00cd, 0x0000) }, // I with acute
350 { DEADTRANS(0x0069, 0x00b4, 0x00ed, 0x0000) }, // i with acute
351 { DEADTRANS(0x004c, 0x00b4, 0x0139, 0x0000) }, // L with acute
352 { DEADTRANS(0x006c, 0x00b4, 0x013a, 0x0000) }, // l with acute
353 { DEADTRANS(0x004f, 0x00b4, 0x00d3, 0x0000) }, // O with acute
354 { DEADTRANS(0x006f, 0x00b4, 0x00f3, 0x0000) }, // o with acute
355 { DEADTRANS(0x0052, 0x00b4, 0x0154, 0x0000) }, // R with acute
356 { DEADTRANS(0x0072, 0x00b4, 0x0155, 0x0000) }, // r with acute
357 { DEADTRANS(0x0055, 0x00b4, 0x00da, 0x0000) }, // U with acute
358 { DEADTRANS(0x0075, 0x00b4, 0x00fa, 0x0000) }, // u with acute
359 { DEADTRANS(0x0059, 0x00b4, 0x00dd, 0x0000) }, // Y with acute
360 { DEADTRANS(0x0079, 0x00b4, 0x00fd, 0x0000) }, // y with acute
361 { DEADTRANS(0x005a, 0x00b4, 0x0179, 0x0000) }, // Z with acute
362 { DEADTRANS(0x007a, 0x00b4, 0x017a, 0x0000) }, // z with acute
363 { DEADTRANS(0x0020, 0x00b4, 0x00b4, 0x0000) }, // space > acute
364
365 { DEADTRANS(0x0041, 0x00a8, 0x00c4, 0x0000) }, // A with diaeresis
366 { DEADTRANS(0x0061, 0x00a8, 0x00e4, 0x0000) }, // a with diaeresis
367 { DEADTRANS(0x0045, 0x00a8, 0x00cb, 0x0000) }, // E with diaeresis
368 { DEADTRANS(0x0065, 0x00a8, 0x00eb, 0x0000) }, // e with diaeresis
369 { DEADTRANS(0x004f, 0x00a8, 0x00d6, 0x0000) }, // O with diaeresis
370 { DEADTRANS(0x006f, 0x00a8, 0x00f6, 0x0000) }, // o with diaeresis
371 { DEADTRANS(0x0055, 0x00a8, 0x00dc, 0x0000) }, // U with diaeresis
372 { DEADTRANS(0x0075, 0x00a8, 0x00fc, 0x0000) }, // u with diaeresis
373 { DEADTRANS(0x0020, 0x00a8, 0x00a8, 0x0000) }, // space > diaeresis
374
375 { DEADTRANS(0x0055, 0x00b0, 0x016e, 0x0000) }, // U with round
376 { DEADTRANS(0x0075, 0x00b0, 0x016f, 0x0000) }, // u with round
377 { DEADTRANS(0x0020, 0x00b0, 0x00b0, 0x0000) }, // space > round
378 { 0, 0, 0 },
379 };
380
381 ROSDATA DEADKEY_LPWSTR dead_key_names[] = {
382 L"\x00a1" L"hacek", // caron
383 L"\x00b4" L"carka", // acute
384 L"\x005e" L"krouzek", // round
385 NULL
386 };
387
388 /* Finally, the master table */
389 ROSDATA KBDTABLES keyboard_layout_table = {
390 /* modifier assignments */
391 &modifier_bits,
392
393 /* character from vk tables */
394 vk_to_wchar_master_table,
395
396 /* diacritical marks -- */
397 dead_key,
398
399 /* Key names */
400 (VSC_LPWSTR *)key_names,
401 (VSC_LPWSTR *)extended_key_names,
402 dead_key_names, /* Dead key names */
403
404 /* scan code to virtual key maps */
405 scancode_to_vk,
406 sizeof(scancode_to_vk) / sizeof(scancode_to_vk[0]),
407 extcode0_to_vk,
408 extcode1_to_vk,
409
410
411 MAKELONG(1,1), /* Version 1.0 */
412
413 /* Ligatures -- Czech keyboard doesn't have any */
414 0,
415 0,
416 NULL
417 };
418
419 PKBDTABLES WINAPI KbdLayerDescriptor(VOID) {
420 return &keyboard_layout_table;
421 }
422