2 * ReactOS USASCII Keyboard layout
3 * Copyright (C) 2003 ReactOS
4 * License: LGPL, see: LGPL.txt
6 * Thanks to: http://www.barcodeman.com/altek/mule/scandoc.php
7 * and http://win.tue.nl/~aeb/linux/kbd/scancodes-1.html
11 #include <internal/kbd.h>
14 #define ROSDATA static __declspec(allocate(".data"))
16 #pragma data_seg(".data")
17 #define ROSDATA static
20 #define VK_EMPTY 0xff /* The non-existent VK */
21 #define KSHIFT 0x001 /* Shift modifier */
22 #define KCTRL 0x002 /* Ctrl modifier */
23 #define KALT 0x004 /* Alt modifier */
24 #define KEXT 0x100 /* Extended key code */
25 #define KMULTI 0x200 /* Multi-key */
26 #define KSPEC 0x400 /* Special key */
27 #define KNUMP 0x800 /* Number-pad */
28 #define KNUMS 0xc00 /* Special + number pad */
29 #define KMEXT 0x300 /* Multi + ext */
31 /* Thanks to http://asp.flaaten.dk/pforum/keycode/keycode.htm */
36 #define VK_OEM_PLUS 0xbb
39 #define VK_OEM_COMMA 0xbc
42 #define VK_OEM_MINUS 0xbd
45 #define VK_OEM_PERIOD 0xbe
69 #define VK_OEM_102 0xe1
72 ROSDATA USHORT scancode_to_vk[] = {
75 /* 1 ... 2 ... 3 ... 4 ... */
76 VK_EMPTY, VK_ESCAPE, '1', '2',
79 VK_OEM_MINUS, VK_OEM_PLUS, VK_BACK,
81 /* First Letters Row */
82 VK_TAB, 'Q', 'W', 'E',
85 VK_OEM_4, VK_OEM_6, VK_RETURN,
87 /* Second Letters Row */
91 'L', VK_OEM_1, VK_OEM_7, VK_OEM_3,
94 /* Third letters row */
96 'B', 'N', 'M', VK_OEM_COMMA,
97 VK_OEM_PERIOD,VK_OEM_2, VK_RSHIFT,
100 VK_EMPTY, VK_RSHIFT | KEXT,
101 VK_MULTIPLY, VK_LMENU,
106 VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6,
107 VK_F7, VK_F8, VK_F9, VK_F10,
114 VK_HOME | KNUMS, VK_UP | KNUMS, VK_PRIOR | KNUMS, VK_SUBTRACT,
115 VK_LEFT | KNUMS, VK_CLEAR | KNUMS, VK_RIGHT | KNUMS, VK_ADD,
116 VK_END | KNUMS, VK_DOWN | KNUMS, VK_NEXT | KNUMS,
117 VK_INSERT | KNUMS, VK_DELETE | KNUMS,
119 /* Presumably PrtSc */
122 /* Oddities, and the remaining standard F-Keys */
123 VK_EMPTY, VK_EMPTY, VK_F11, VK_F12,
125 VK_CLEAR, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* EREOF */
126 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* ZOOM */
129 /* Even more F-Keys (for example, NCR keyboards from the early 90's) */
130 VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, VK_F19, VK_F20,
131 VK_F21, VK_F22, VK_F23,
133 /* Not sure who uses these codes */
134 VK_EMPTY, VK_EMPTY, VK_EMPTY,
136 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
141 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY,
142 VK_EMPTY, VK_EMPTY, VK_EMPTY, VK_EMPTY, /* PA1 */
148 ROSDATA VSC_VK extcode0_to_vk[] = {
152 ROSDATA VSC_VK extcode1_to_vk[] = {
158 ROSDATA VK_TO_BIT modifier_keys[] = {
159 { VK_SHIFT, KSHIFT },
160 { VK_CONTROL, KCTRL },
165 typedef struct _mymod {
169 } INTERNAL_KBD_MODIFIERS;
171 ROSDATA INTERNAL_KBD_MODIFIERS modifier_bits[] = {
174 { 0, 1, 2, 3 } /* Modifier bit order, NONE, SHIFT, CTRL, ALT */
178 #define CAPS KSHIFT /* Caps -> shift */
180 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod[] = {
181 /* Normal vs Shifted */
183 { '1', NOCAPS, '1', '!' },
184 /* Ctrl-2 generates NUL */
185 { '3', NOCAPS, '3', '#' },
186 { '4', NOCAPS, '4', '$' },
187 { '5', NOCAPS, '5', '%' },
188 /* Ctrl-6 generates RS */
189 { '7', NOCAPS, '7', '&' },
190 { '8', NOCAPS, '8', '*' },
191 { '9', NOCAPS, '9', '(' },
192 { '0', NOCAPS, '0', ')' },
193 /* First letter row */
194 { 'Q', CAPS, 'q', 'Q' },
195 { 'W', CAPS, 'w', 'W' },
196 { 'E', CAPS, 'e', 'E' },
197 { 'R', CAPS, 'r', 'R' },
198 { 'T', CAPS, 't', 'T' },
199 { 'Y', CAPS, 'y', 'Y' },
200 { 'U', CAPS, 'u', 'U' },
201 { 'I', CAPS, 'i', 'I' },
202 { 'O', CAPS, 'o', 'O' },
203 { 'P', CAPS, 'p', 'P' },
204 /* Second letter row */
205 { 'A', CAPS, 'a', 'A' },
206 { 'S', CAPS, 's', 'S' },
207 { 'D', CAPS, 'd', 'D' },
208 { 'F', CAPS, 'f', 'F' },
209 { 'G', CAPS, 'g', 'G' },
210 { 'H', CAPS, 'h', 'H' },
211 { 'J', CAPS, 'j', 'J' },
212 { 'K', CAPS, 'k', 'K' },
213 { 'L', CAPS, 'l', 'L' },
214 /* Third letter row */
215 { 'Z', CAPS, 'z', 'Z' },
216 { 'X', CAPS, 'x', 'X' },
217 { 'C', CAPS, 'c', 'C' },
218 { 'V', CAPS, 'v', 'V' },
219 { 'B', CAPS, 'b', 'B' },
220 { 'N', CAPS, 'n', 'N' },
221 { 'M', CAPS, 'm', 'M' },
224 /* Ctrl-_ generates US */
225 { VK_OEM_PLUS ,NOCAPS, '=', '+' },
226 { VK_OEM_1 ,NOCAPS, ';', ':' },
227 { VK_OEM_7 ,NOCAPS, '\'','\"'},
228 { VK_OEM_3 ,NOCAPS, '`', '~' },
229 { VK_OEM_COMMA ,NOCAPS, ',', '<' },
230 { VK_OEM_PERIOD ,NOCAPS, '.', '>' },
231 { VK_OEM_2 ,NOCAPS, '/', '?' },
232 /* Keys that do not have shift states */
233 { VK_TAB ,NOCAPS, '\t','\t'},
234 { VK_ADD ,NOCAPS, '+', '+' },
235 { VK_SUBTRACT,NOCAPS, '-', '-' },
236 { VK_MULTIPLY,NOCAPS, '*', '*' },
237 { VK_DIVIDE ,NOCAPS, '/', '/' },
238 { VK_ESCAPE ,NOCAPS, '\x1b','\x1b' },
239 { VK_SPACE ,NOCAPS, ' ', ' ' },
243 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod[] = {
244 /* Normal, Shifted, Ctrl */
245 /* Legacy (telnet-style) ascii escapes */
246 { VK_OEM_4, 0, '[', '{', 0x1b /* ESC */ },
247 { VK_OEM_6, 0, ']', '}', 0x1d /* GS */ },
248 { VK_OEM_5, 0, '\\','|', 0x1c /* FS */ },
249 { VK_RETURN,0, '\r', '\r', '\n' },
253 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod[] = {
254 /* Normal, Shifted, Ctrl, C-S-x */
255 /* Legacy Ascii generators */
256 { '2', NOCAPS, '2', '@', WCH_NONE, 0 },
257 { '6', NOCAPS, '6', '^', WCH_NONE, 0x1e /* RS */ },
258 { VK_OEM_MINUS, NOCAPS, '-', '_', WCH_NONE, 0x1f /* US */ },
262 ROSDATA VK_TO_WCHARS1 keypad_numbers[] = {
263 { VK_NUMPAD0, 0, '0' },
264 { VK_NUMPAD1, 0, '1' },
265 { VK_NUMPAD2, 0, '2' },
266 { VK_NUMPAD3, 0, '3' },
267 { VK_NUMPAD4, 0, '4' },
268 { VK_NUMPAD5, 0, '5' },
269 { VK_NUMPAD6, 0, '6' },
270 { VK_NUMPAD7, 0, '7' },
271 { VK_NUMPAD8, 0, '8' },
272 { VK_NUMPAD9, 0, '9' },
273 { VK_BACK, 0, '\010' },
277 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) }
279 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table[] = {
280 vk_master(1,keypad_numbers),
281 vk_master(2,key_to_chars_2mod),
282 vk_master(3,key_to_chars_3mod),
283 vk_master(4,key_to_chars_4mod),
287 ROSDATA VSC_LPWSTR key_names[] = {
290 { 0x0e, L"Backspace" },
295 { 0x36, L"Right Shift" },
299 { 0x3a, L"Caps Lock" },
311 { 0x46, L"Scroll Lock" },
324 { 0x53, L"Num Del" },
325 { 0x54, L"Sys Req" },
343 ROSDATA VSC_LPWSTR extended_key_names[] = {
344 { 0x1c, L"Num Enter" },
345 { 0x1d, L"Right Ctrl" },
347 { 0x37, L"Prnt Scrn" },
348 { 0x38, L"Right Alt" },
349 { 0x45, L"Num Lock" },
353 { 0x49, L"Page Up" },
359 { 0x51, L"Page Down" },
362 { 0x54, L"<ReactOS>" },
364 { 0x56, L"Left Windows" },
365 { 0x5b, L"Right Windows" },
369 /* Finally, the master table */
370 ROSDATA KBDTABLES keyboard_layout_table = {
371 /* modifier assignments */
372 (PMODIFIERS)modifier_bits,
374 /* character from vk tables */
375 vk_to_wchar_master_table,
377 /* diacritical marks -- currently implemented by wine code */
378 /* English doesn't have any, anyway */
382 (VSC_LPWSTR *)key_names,
383 (VSC_LPWSTR *)extended_key_names,
384 NULL, /* Dead key names */
386 /* scan code to virtual key maps */
388 sizeof(scancode_to_vk) / sizeof(scancode_to_vk[0]),
392 MAKELONG(0,1), /* Version 1.0 */
394 /* Ligatures -- English doesn't have any */
400 PKBDTABLES STDCALL KbdLayerDescriptor() {
401 return &keyboard_layout_table;