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"))
17 #pragma data_seg(".data")
18 #define ROSDATA static
20 #define ROSDATA static __attribute__((section(".data")))
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 */
35 ROSDATA USHORT scancode_to_vk
[] = {
38 /* 1 ... 2 ... 3 ... 4 ... */
39 VK_EMPTY
, VK_ESCAPE
, '1', '2',
42 VK_OEM_MINUS
, VK_OEM_PLUS
, VK_BACK
,
44 /* First Letters Row */
45 VK_TAB
, 'Q', 'W', 'E',
48 VK_OEM_4
, VK_OEM_6
, VK_RETURN
,
50 /* Second Letters Row */
54 'L', VK_OEM_1
, VK_OEM_7
, VK_OEM_3
,
57 /* Third letters row */
59 'B', 'N', 'M', VK_OEM_COMMA
,
60 VK_OEM_PERIOD
,VK_OEM_2
, VK_RSHIFT
,
63 VK_MULTIPLY
, VK_LMENU
, VK_SPACE
, VK_CAPITAL
,
67 VK_F1
, VK_F2
, VK_F3
, VK_F4
, VK_F5
, VK_F6
,
68 VK_F7
, VK_F8
, VK_F9
, VK_F10
,
75 VK_HOME
| KNUMS
, VK_UP
| KNUMS
, VK_PRIOR
| KNUMS
, VK_SUBTRACT
,
76 VK_LEFT
| KNUMS
, VK_CLEAR
| KNUMS
, VK_RIGHT
| KNUMS
, VK_ADD
,
77 VK_END
| KNUMS
, VK_DOWN
| KNUMS
, VK_NEXT
| KNUMS
,
78 VK_INSERT
| KNUMS
, VK_DELETE
| KNUMS
,
80 /* Presumably PrtSc */
83 /* Oddities, and the remaining standard F-Keys */
84 VK_EMPTY
, VK_EMPTY
, VK_F11
, VK_F12
,
86 VK_CLEAR
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, /* EREOF */
87 VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, /* ZOOM */
90 /* Even more F-Keys (for example, NCR keyboards from the early 90's) */
91 VK_F13
, VK_F14
, VK_F15
, VK_F16
, VK_F17
, VK_F18
, VK_F19
, VK_F20
,
92 VK_F21
, VK_F22
, VK_F23
,
94 /* Not sure who uses these codes */
95 VK_EMPTY
, VK_EMPTY
, VK_EMPTY
,
97 VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
,
102 VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
,
103 VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, VK_EMPTY
, /* PA1 */
109 ROSDATA VSC_VK extcode0_to_vk
[] = {
113 ROSDATA VSC_VK extcode1_to_vk
[] = {
117 ROSDATA VK_TO_BIT modifier_keys
[] = {
118 { VK_SHIFT
, KSHIFT
},
119 { VK_CONTROL
, KCTRL
},
124 ROSDATA MODIFIERS modifier_bits
= {
127 { 0, 1, 2, 3 } /* Modifier bit order, NONE, SHIFT, CTRL, ALT */
131 #define CAPS KSHIFT /* Caps -> shift */
133 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod
[] = {
134 /* Normal vs Shifted */
136 { '1', NOCAPS
, {'1', '!'} },
137 /* Ctrl-2 generates NUL */
138 { '3', NOCAPS
, {'3', '#'} },
139 { '4', NOCAPS
, {'4', '$'} },
140 { '5', NOCAPS
, {'5', '%'} },
141 /* Ctrl-6 generates RS */
142 { '7', NOCAPS
, {'7', '&'} },
143 { '8', NOCAPS
, {'8', '*'} },
144 { '9', NOCAPS
, {'9', '('} },
145 { '0', NOCAPS
, {'0', ')'} },
146 /* First letter row */
147 { 'Q', CAPS
, {'q', 'Q'} },
148 { 'W', CAPS
, {'w', 'W'} },
149 { 'E', CAPS
, {'e', 'E'} },
150 { 'R', CAPS
, {'r', 'R'} },
151 { 'T', CAPS
, {'t', 'T'} },
152 { 'Y', CAPS
, {'y', 'Y'} },
153 { 'U', CAPS
, {'u', 'U'} },
154 { 'I', CAPS
, {'i', 'I'} },
155 { 'O', CAPS
, {'o', 'O'} },
156 { 'P', CAPS
, {'p', 'P'} },
157 /* Second letter row */
158 { 'A', CAPS
, {'a', 'A'} },
159 { 'S', CAPS
, {'s', 'S'} },
160 { 'D', CAPS
, {'d', 'D'} },
161 { 'F', CAPS
, {'f', 'F'} },
162 { 'G', CAPS
, {'g', 'G'} },
163 { 'H', CAPS
, {'h', 'H'} },
164 { 'J', CAPS
, {'j', 'J'} },
165 { 'K', CAPS
, {'k', 'K'} },
166 { 'L', CAPS
, {'l', 'L'} },
167 /* Third letter row */
168 { 'Z', CAPS
, {'z', 'Z'} },
169 { 'X', CAPS
, {'x', 'X'} },
170 { 'C', CAPS
, {'c', 'C'} },
171 { 'V', CAPS
, {'v', 'V'} },
172 { 'B', CAPS
, {'b', 'B'} },
173 { 'N', CAPS
, {'n', 'N'} },
174 { 'M', CAPS
, {'m', 'M'} },
177 /* Ctrl-_ generates US */
178 { VK_OEM_PLUS
,NOCAPS
, {'=', '+'} },
179 { VK_OEM_1
,NOCAPS
, {';', ':'} },
180 { VK_OEM_7
,NOCAPS
, {'\'','\"'} },
181 { VK_OEM_3
,NOCAPS
, {'`', '~'} },
182 { VK_OEM_COMMA
,NOCAPS
, {',', '<'} },
183 { VK_OEM_PERIOD
,NOCAPS
, {'.', '>'} },
184 { VK_OEM_2
,NOCAPS
, {'/', '?'} },
185 /* Keys that do not have shift states */
186 { VK_TAB
,NOCAPS
, {'\t','\t'} },
187 { VK_ADD
,NOCAPS
, {'+', '+'} },
188 { VK_SUBTRACT
,NOCAPS
, {'-', '-'} },
189 { VK_MULTIPLY
,NOCAPS
, {'*', '*'} },
190 { VK_DIVIDE
,NOCAPS
, {'/', '/'} },
191 { VK_ESCAPE
,NOCAPS
, {'\x1b','\x1b'} },
192 { VK_SPACE
,NOCAPS
, {' ', ' '} },
196 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod
[] = {
197 /* Normal, Shifted, Ctrl */
198 /* Legacy (telnet-style) ascii escapes */
199 { VK_OEM_4
, 0, {'[', '{', 0x1b /* ESC */} },
200 { VK_OEM_6
, 0, {']', '}', 0x1d /* GS */} },
201 { VK_OEM_5
, 0, {'\\','|', 0x1c /* FS */} },
202 { VK_RETURN
,0, {'\r', '\r', '\n'} },
206 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod
[] = {
207 /* Normal, Shifted, Ctrl, C-S-x */
208 /* Legacy Ascii generators */
209 { '2', NOCAPS
, {'2', '@', WCH_NONE
, 0} },
210 { '6', NOCAPS
, {'6', '^', WCH_NONE
, 0x1e /* RS */} },
211 { VK_OEM_MINUS
, NOCAPS
, {'-', '_', WCH_NONE
, 0x1f /* US */} },
215 ROSDATA VK_TO_WCHARS1 keypad_numbers
[] = {
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_DECIMAL
, 0, {'.'} },
227 { VK_BACK
, 0, {'\010'} },
231 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) }
233 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table
[] = {
234 vk_master(1,keypad_numbers
),
235 vk_master(2,key_to_chars_2mod
),
236 vk_master(3,key_to_chars_3mod
),
237 vk_master(4,key_to_chars_4mod
),
241 ROSDATA VSC_LPWSTR key_names
[] = {
244 { 0x0e, L
"Backspace" },
249 { 0x36, L
"Right Shift" },
253 { 0x3a, L
"Caps Lock" },
265 { 0x46, L
"Scroll Lock" },
278 { 0x53, L
"Num Del" },
279 { 0x54, L
"Sys Req" },
297 ROSDATA VSC_LPWSTR extended_key_names
[] = {
298 { 0x1c, L
"Num Enter" },
299 { 0x1d, L
"Right Ctrl" },
301 { 0x37, L
"Prnt Scrn" },
302 { 0x38, L
"Right Alt" },
303 { 0x45, L
"Num Lock" },
307 { 0x49, L
"Page Up" },
313 { 0x51, L
"Page Down" },
316 { 0x54, L
"<ReactOS>" },
318 { 0x56, L
"Left Windows" },
319 { 0x5b, L
"Right Windows" },
323 /* Finally, the master table */
324 ROSDATA KBDTABLES keyboard_layout_table
= {
325 /* modifier assignments */
328 /* character from vk tables */
329 vk_to_wchar_master_table
,
331 /* diacritical marks -- currently implemented by wine code */
332 /* English doesn't have any, anyway */
336 (VSC_LPWSTR
*)key_names
,
337 (VSC_LPWSTR
*)extended_key_names
,
338 NULL
, /* Dead key names */
340 /* scan code to virtual key maps */
342 sizeof(scancode_to_vk
) / sizeof(scancode_to_vk
[0]),
346 MAKELONG(0,1), /* Version 1.0 */
348 /* Ligatures -- English doesn't have any */
354 PKBDTABLES STDCALL
KbdLayerDescriptor() {
355 return &keyboard_layout_table
;