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_3
, VK_OEM_8
,
57 /* Third letters row */
59 'B', 'N', 'M', VK_OEM_COMMA
,
60 VK_OEM_PERIOD
,VK_OEM_2
, VK_RSHIFT
|KEXT
,
63 VK_MULTIPLY
, VK_MENU
, 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_OEM_5
, 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
[] = {
110 {0x1c, VK_RETURN
|KEXT
}, //Keypad return
111 {0x1d, VK_RCONTROL
|KEXT
},//Right control key
112 {0x35, VK_DIVIDE
|KEXT
}, // Numpad div
113 {0x38, VK_RMENU
|KEXT
}, //AltGr?
117 ROSDATA VSC_VK extcode1_to_vk
[] = {
121 ROSDATA VK_TO_BIT modifier_keys
[] = {
122 { VK_SHIFT
, KSHIFT
},
123 { VK_CONTROL
, KCTRL
},
128 ROSDATA MODIFIERS modifier_bits
= {
131 { 0, 1, 2, 3 ,0, 0,4,5} /* Modifier bit order, NONE, SHIFT, CTRL, SHIFT+CTRL,ALT(not used),SHIFT-ALT (not used), CTR+ALT, SHIFT-CTRL-ALT*/
135 #define CAPS KSHIFT /* Caps -> shift */
137 ROSDATA VK_TO_WCHARS2 key_to_chars_2mod
[] = {
138 /* Normal vs Shifted */
140 { '1', NOCAPS
, {'1', '!'} },
141 { '2', NOCAPS
, {'2', '\"'} },
142 { '3', NOCAPS
, {'3', 0xa3} },
143 { '5', NOCAPS
, {'5', '%'} },
144 { '7', NOCAPS
, {'7', '&'} },
145 { '8', NOCAPS
, {'8', '*'} },
146 { '9', NOCAPS
, {'9', '('} },
147 { '0', NOCAPS
, {'0', ')'} },
148 { VK_OEM_PLUS
,NOCAPS
, {'=', '+'} },
149 /* First letter row */
150 { 'Q', CAPS
, {'q', 'Q'} },
151 { 'W', CAPS
, {'w', 'W'} },
152 { 'R', CAPS
, {'r', 'R'} },
153 { 'T', CAPS
, {'t', 'T'} },
154 { 'Y', CAPS
, {'y', 'Y'} },
155 { 'P', CAPS
, {'p', 'P'} },
156 /* Second letter row */
157 { 'S', CAPS
, {'s', 'S'} },
158 { 'D', CAPS
, {'d', 'D'} },
159 { 'F', CAPS
, {'f', 'F'} },
160 { 'G', CAPS
, {'g', 'G'} },
161 { 'H', CAPS
, {'h', 'H'} },
162 { 'J', CAPS
, {'j', 'J'} },
163 { 'K', CAPS
, {'k', 'K'} },
164 { 'L', CAPS
, {'l', 'L'} },
165 { VK_OEM_1
,NOCAPS
, {';', ':'} },
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'} },
175 { VK_OEM_COMMA
, NOCAPS
, {',', '<'} },
176 { VK_OEM_PERIOD
, NOCAPS
, {'.', '>'} },
177 { VK_OEM_2
, NOCAPS
, {'/', '?'} },
180 /* Keys that do not have shift states */
181 { VK_TAB
, NOCAPS
, {'\t','\t'} },
182 { VK_ADD
, NOCAPS
, {'+', '+'} },
183 { VK_SUBTRACT
, NOCAPS
, {'-', '-'} },
184 { VK_MULTIPLY
, NOCAPS
, {'*', '*'} },
185 { VK_DIVIDE
, NOCAPS
, {'/', '/'} },
186 { VK_ESCAPE
, NOCAPS
, {'\x1b','\x1b'} },
187 { VK_SPACE
, NOCAPS
, {' ', ' '} },
191 ROSDATA VK_TO_WCHARS3 key_to_chars_3mod
[] = {
192 /* Normal, Shifted, Ctrl */
193 /* Legacy (telnet-style) ascii escapes */
194 { VK_OEM_4
, NOCAPS
, {'[', '{', 0x1b} },
195 { VK_OEM_6
, NOCAPS
, {']', '}', 0x1d} },
196 { VK_OEM_7
, NOCAPS
, {'#', '~', 0x1c} },
197 { VK_OEM_5
, 0, {'\\', '|', 0x1c} },
198 { VK_RETURN
, 0, {'\r', '\r', '\n'} },
202 ROSDATA VK_TO_WCHARS4 key_to_chars_4mod
[] = {
203 /* Normal, Shifted, Ctrl, C-Shift */
204 /* Legacy Ascii generators */
206 { '6', NOCAPS
, {'6', '^', WCH_NONE
, 0x1e} },
207 { VK_OEM_MINUS
, NOCAPS
, {'-', '_', WCH_NONE
, 0x1f} },
208 { VK_OEM_3
, NOCAPS
, {'\'', '@', WCH_NONE
, 0x00} },
212 ROSDATA VK_TO_WCHARS5 key_to_chars_5mod
[] = {
213 /* Normal, Shifted, Ctrl, Sh-Ctrl,Sh-Alt,Ctl-Alt */
214 /* Ctrl-sh-6 generates RS */
215 {VK_OEM_8
, NOCAPS
, {'`', 0x00ac, WCH_NONE
, WCH_NONE
, 0xa6} },
216 { '4', NOCAPS
, {'4', '$', WCH_NONE
, WCH_NONE
, 0x20ac} },
220 ROSDATA VK_TO_WCHARS6 key_to_chars_6mod
[] = {
221 /* Normal, Shifted, Ctrl, Sh-Ctrl,Sh-Alt,Ctl-Alt,Ctl-Sh-Alt */
223 { 'E', CAPS
, {'e', 'E', WCH_NONE
, WCH_NONE
, 0x00e9, 0x00c9} },
224 { 'U', CAPS
, {'u', 'U', WCH_NONE
, WCH_NONE
, 0x00fa, 0x00da} },
225 { 'I', CAPS
, {'i', 'I', WCH_NONE
, WCH_NONE
, 0x00ed, 0x00cd} },
226 { 'O', CAPS
, {'o', 'O', WCH_NONE
, WCH_NONE
, 0x00f3, 0x00d3} },
227 { 'A', CAPS
, {'a', 'A', WCH_NONE
, WCH_NONE
, 0x00e1, 0x00c1} },
231 ROSDATA VK_TO_WCHARS1 keypad_numbers
[] = {
232 { VK_DECIMAL
, 0, {'.'} },
233 { VK_NUMPAD0
, 0, {'0'} },
234 { VK_NUMPAD1
, 0, {'1'} },
235 { VK_NUMPAD2
, 0, {'2'} },
236 { VK_NUMPAD3
, 0, {'3'} },
237 { VK_NUMPAD4
, 0, {'4'} },
238 { VK_NUMPAD5
, 0, {'5'} },
239 { VK_NUMPAD6
, 0, {'6'} },
240 { VK_NUMPAD7
, 0, {'7'} },
241 { VK_NUMPAD8
, 0, {'8'} },
242 { VK_NUMPAD9
, 0, {'9'} },
243 { VK_BACK
, 0, {'\010'} },
247 #define vk_master(n,x) { (PVK_TO_WCHARS1)x, n, sizeof(x[0]) }
249 ROSDATA VK_TO_WCHAR_TABLE vk_to_wchar_master_table
[] = {
250 vk_master(1,keypad_numbers
),
251 vk_master(2,key_to_chars_2mod
),
252 vk_master(3,key_to_chars_3mod
),
253 vk_master(4,key_to_chars_4mod
),
254 vk_master(5,key_to_chars_5mod
),
255 vk_master(6,key_to_chars_6mod
),
259 ROSDATA VSC_LPWSTR key_names
[] = {
262 { 0x0e, L
"Backspace" },
267 { 0x36, L
"Right Shift" },
271 { 0x3a, L
"Caps Lock" },
283 { 0x46, L
"Scroll Lock" },
296 { 0x53, L
"Num Del" },
297 { 0x54, L
"Sys Req" },
315 ROSDATA VSC_LPWSTR extended_key_names
[] = {
316 { 0x1c, L
"Num Enter" },
317 { 0x1d, L
"Right Ctrl" },
319 { 0x37, L
"Prnt Scrn" },
320 { 0x38, L
"Right Alt" },
321 { 0x45, L
"Num Lock" },
325 { 0x49, L
"Page Up" },
331 { 0x51, L
"Page Down" },
334 { 0x54, L
"<ReactOS>" },
336 { 0x56, L
"Left Windows" },
337 { 0x5b, L
"Right Windows" },
341 /* Finally, the master table */
342 ROSDATA KBDTABLES keyboard_layout_table
= {
343 /* modifier assignments */
346 /* character from vk tables */
347 vk_to_wchar_master_table
,
349 /* diacritical marks -- currently implemented by wine code */
350 /* English doesn't have any, anyway */
354 (VSC_LPWSTR
*)key_names
,
355 (VSC_LPWSTR
*)extended_key_names
,
356 NULL
, /* Dead key names */
358 /* scan code to virtual key maps */
360 sizeof(scancode_to_vk
) / sizeof(scancode_to_vk
[0]),
365 MAKELONG(0,1), /* Version 1.0 */
367 /* Ligatures -- English doesn't have any */
373 PKBDTABLES STDCALL
KbdLayerDescriptor() {
374 return &keyboard_layout_table
;