bsd_KbdMap.c revision 632d17a8
1/*
2 * Slightly modified xf86KbdBSD.c which is
3 *
4 * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
5 * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
6 * and from xf86KbdCODrv.c by Holger Veit
7 */
8
9#ifdef HAVE_CONFIG_H
10#include "config.h"
11#endif
12
13#include <xorg-server.h>
14#include <X11/X.h>
15#include <X11/Xmd.h>
16#include "input.h"
17#include "scrnintstr.h"
18
19#include "compiler.h"
20
21#include "xf86.h"
22#include "xf86Priv.h"
23#include "xf86_OSlib.h"
24#include "xf86Xinput.h"
25#include "xf86OSKbd.h"
26#include "atKeynames.h"
27#include "xf86Keymap.h"
28#include "bsd_kbd.h"
29
30#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
31#define KD_GET_ENTRY(i,n) \
32  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
33
34static unsigned char remap[NUM_KEYCODES] = {
35     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
36  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
37  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
38  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
39  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
40  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
41  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
42  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
43  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
44     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
45     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
46  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
47     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
48     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
49     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
50     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
51};
52
53/* This table assumes the ibm code page 437 coding for characters
54 * > 0x80. They are returned in this form by PCVT */
55static KeySym eascii_to_x[512] = {
56	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
57	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
58	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
59	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
60	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
61	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
62	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
63	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
64	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
65	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
66	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
67	XK_comma,	XK_minus,	XK_period,	XK_slash,
68	XK_0,		XK_1,		XK_2,		XK_3,
69	XK_4,		XK_5,		XK_6,		XK_7,
70	XK_8,		XK_9,		XK_colon,	XK_semicolon,
71	XK_less,	XK_equal,	XK_greater,	XK_question,
72	XK_at,		XK_A,		XK_B,		XK_C,
73	XK_D,		XK_E,		XK_F,		XK_G,
74	XK_H,		XK_I,		XK_J,		XK_K,
75	XK_L,		XK_M,		XK_N,		XK_O,
76	XK_P,		XK_Q,		XK_R,		XK_S,
77	XK_T,		XK_U,		XK_V,		XK_W,
78	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
79	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
80	XK_grave,	XK_a,		XK_b,		XK_c,
81	XK_d,		XK_e,		XK_f,		XK_g,
82	XK_h,		XK_i,		XK_j,		XK_k,
83	XK_l,		XK_m,		XK_n,		XK_o,
84	XK_p,		XK_q,		XK_r,		XK_s,
85	XK_t,		XK_u,		XK_v,		XK_w,
86	XK_x,		XK_y,		XK_z,		XK_braceleft,
87	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
88	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
89	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
90	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
91	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
92	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
93	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
94	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
95	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
96	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
97	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
98	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
99	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
100	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
101	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
102	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
103	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
104	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
105	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
106	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
107	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
108	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
109	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
110	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
111	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
112	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
113	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
114	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
115	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
116	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
117	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
118	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
119	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
120
121	/*
122	 * special marked entries (256 + x)
123	 */
124
125	/* This has been checked against what syscons actually does */
126	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
127	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
128	XK_ISO_Left_Tab,XK_Control_L,	NoSymbol,	NoSymbol,
129	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
130	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
131	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
132	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
133	XK_F2,		XK_F3,		XK_F4,		XK_F5,
134	XK_F6,		XK_F7,		XK_F8,		XK_F9,
135	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
136	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
137	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
138	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
139	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
140	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
141	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
142	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
143	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
144	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
145	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
146	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
147	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
148	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
149	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
150	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
151	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
152	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
153	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
154	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
155	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
156	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
157	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
158	XK_Control_R,	XK_Alt_R,	NoSymbol,	NoSymbol,
159	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
160	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
161	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
162	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
163	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
164	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
165	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
166	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
167	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
168	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
169	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
170	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
171	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
172	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
173	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
174	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
175	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
176	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
177	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
178	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
179	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
180	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
181	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
182	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
183	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
184	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
185	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
186	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
187	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
188	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
189	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
190};
191
192#ifdef __OpenBSD__
193/* don't mark AltR and  CtrlR for remapping, since they
194 * cannot be remapped by pccons */
195static unsigned char pccons_remap[128] = {
196     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
197  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
198  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
199  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
200  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
201  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
202  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
203  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
204  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
205     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
206     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
207  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
208     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
209     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
210     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x70 - 0x77 */
211     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
212};
213
214/* This table assumes an iso8859_1 encoding for the characters
215 * > 80, as returned by pccons */
216static KeySym latin1_to_x[256] = {
217	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
218	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
219	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
220	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
221	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
222	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
223	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
224	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
225	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
226	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
227	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
228	XK_comma,	XK_minus,	XK_period,	XK_slash,
229	XK_0,		XK_1,		XK_2,		XK_3,
230	XK_4,		XK_5,		XK_6,		XK_7,
231	XK_8,		XK_9,		XK_colon,	XK_semicolon,
232	XK_less,	XK_equal,	XK_greater,	XK_question,
233	XK_at,		XK_A,		XK_B,		XK_C,
234	XK_D,		XK_E,		XK_F,		XK_G,
235	XK_H,		XK_I,		XK_J,		XK_K,
236	XK_L,		XK_M,		XK_N,		XK_O,
237	XK_P,		XK_Q,		XK_R,		XK_S,
238	XK_T,		XK_U,		XK_V,		XK_W,
239	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
240	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
241	XK_grave,	XK_a,		XK_b,		XK_c,
242	XK_d,		XK_e,		XK_f,		XK_g,
243	XK_h,		XK_i,		XK_j,		XK_k,
244	XK_l,		XK_m,		XK_n,		XK_o,
245	XK_p,		XK_q,		XK_r,		XK_s,
246	XK_t,		XK_u,		XK_v,		XK_w,
247	XK_x,		XK_y,		XK_z,		XK_braceleft,
248	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
249	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
250	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
251	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
252	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
253	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
254	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
255	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
256	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
257	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
258	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
259	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
260	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
261	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
262	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
263	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
264	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
265	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
266	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
267	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
268	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
269	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
270	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
271	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
272	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
273	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
274	XK_adiaeresis,	XK_aring,	XK_ae,	        XK_ccedilla,
275	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
276	XK_igrave,	XK_iacute,	XK_icircumflex, XK_idiaeresis,
277	XK_eth,		XK_ntilde,	XK_ograve, 	XK_oacute,
278	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
279	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
280	XK_udiaeresis,	XK_yacute,	XK_thorn, 	XK_ydiaeresis
281      };
282#endif
283
284#ifdef SYSCONS_SUPPORT
285static
286unsigned char sysconsCODEMap[] = {
287	KEY_KP_Enter,	KEY_RCtrl,	KEY_KP_Divide,	KEY_Print,
288	KEY_AltLang,	KEY_KP_7,	KEY_KP_8,	KEY_KP_9,
289	KEY_KP_4,	KEY_KP_6,	KEY_KP_1,	KEY_KP_2,
290	KEY_KP_3,	KEY_KP_0,	KEY_KP_Decimal,	KEY_Pause,
291	KEY_LMeta,	KEY_RMeta,	KEY_Menu,	KEY_Break
292};
293static
294TransMapRec sysconsCODE = {
295    0x59,
296    0x6d,
297    sysconsCODEMap
298};
299#endif
300#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
301
302#ifdef WSCONS_SUPPORT
303
304static CARD8 wsUsbMap[] = {
305	/* 0 */ KEY_NOTUSED,
306	/* 1 */ KEY_NOTUSED,
307	/* 2 */ KEY_NOTUSED,
308	/* 3 */ KEY_NOTUSED,
309	/* 4 */ KEY_A,
310	/* 5 */ KEY_B,
311	/* 6 */ KEY_C,
312	/* 7 */ KEY_D,
313	/* 8 */ KEY_E,
314	/* 9 */ KEY_F,
315	/* 10 */ KEY_G,
316	/* 11 */ KEY_H,
317	/* 12 */ KEY_I,
318	/* 13 */ KEY_J,
319	/* 14 */ KEY_K,
320	/* 15 */ KEY_L,
321	/* 16 */ KEY_M,
322	/* 17 */ KEY_N,
323	/* 18 */ KEY_O,
324	/* 19 */ KEY_P,
325	/* 20 */ KEY_Q,
326	/* 21 */ KEY_R,
327	/* 22 */ KEY_S,
328	/* 23 */ KEY_T,
329	/* 24 */ KEY_U,
330	/* 25 */ KEY_V,
331	/* 26 */ KEY_W,
332	/* 27 */ KEY_X,
333	/* 28 */ KEY_Y,
334	/* 29 */ KEY_Z,
335	/* 30 */ KEY_1,		/* 1 !*/
336	/* 31 */ KEY_2,		/* 2 @ */
337	/* 32 */ KEY_3,		/* 3 # */
338	/* 33 */ KEY_4,		/* 4 $ */
339	/* 34 */ KEY_5,		/* 5 % */
340	/* 35 */ KEY_6,		/* 6 ^ */
341	/* 36 */ KEY_7,		/* 7 & */
342	/* 37 */ KEY_8,		/* 8 * */
343	/* 38 */ KEY_9,		/* 9 ( */
344	/* 39 */ KEY_0,		/* 0 ) */
345	/* 40 */ KEY_Enter,	/* Return  */
346	/* 41 */ KEY_Escape,	/* Escape */
347	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
348	/* 43 */ KEY_Tab,	/* Tab */
349	/* 44 */ KEY_Space,	/* Space */
350	/* 45 */ KEY_Minus,	/* - _ */
351	/* 46 */ KEY_Equal,	/* = + */
352	/* 47 */ KEY_LBrace,	/* [ { */
353	/* 48 */ KEY_RBrace,	/* ] } */
354	/* 49 */ KEY_BSlash,	/* \ | */
355	/* 50 */ KEY_BSlash2,	/* \ _ # ~ on some keyboards */
356	/* 51 */ KEY_SemiColon,	/* ; : */
357	/* 52 */ KEY_Quote,	/* ' " */
358	/* 53 */ KEY_Tilde,	/* ` ~ */
359	/* 54 */ KEY_Comma,	/* , <  */
360	/* 55 */ KEY_Period,	/* . > */
361	/* 56 */ KEY_Slash,	/* / ? */
362	/* 57 */ KEY_CapsLock,	/* Caps Lock */
363	/* 58 */ KEY_F1,		/* F1 */
364	/* 59 */ KEY_F2,		/* F2 */
365	/* 60 */ KEY_F3,		/* F3 */
366	/* 61 */ KEY_F4,		/* F4 */
367	/* 62 */ KEY_F5,		/* F5 */
368	/* 63 */ KEY_F6,		/* F6 */
369	/* 64 */ KEY_F7,		/* F7 */
370	/* 65 */ KEY_F8,		/* F8 */
371	/* 66 */ KEY_F9,		/* F9 */
372	/* 67 */ KEY_F10,	/* F10 */
373	/* 68 */ KEY_F11,	/* F11 */
374	/* 69 */ KEY_F12,	/* F12 */
375	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
376	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
377	/* 72 */ KEY_Pause,	/* Pause Break */
378	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
379	/* 74 */ KEY_Home,	/* Home */
380	/* 75 */ KEY_PgUp,	/* Page Up */
381	/* 76 */ KEY_Delete,	/* Delete */
382	/* 77 */ KEY_End,	/* End */
383	/* 78 */ KEY_PgDown,	/* Page Down */
384	/* 79 */ KEY_Right,	/* Right Arrow */
385	/* 80 */ KEY_Left,	/* Left Arrow */
386	/* 81 */ KEY_Down,	/* Down Arrow */
387	/* 82 */ KEY_Up,		/* Up Arrow */
388	/* 83 */ KEY_NumLock,	/* Num Lock */
389	/* 84 */ KEY_KP_Divide,	/* Keypad / */
390	/* 85 */ KEY_KP_Multiply, /* Keypad * */
391	/* 86 */ KEY_KP_Minus,	/* Keypad - */
392	/* 87 */ KEY_KP_Plus,	/* Keypad + */
393	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
394	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
395	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
396	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
397	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
398	/* 93 */ KEY_KP_5,	/* Keypad 5 */
399	/* 94 */ KEY_KP_6,	/* Keypad 6 */
400	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
401	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
402	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
403	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
404	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
405	/* 100 */ KEY_Less,	/* < > on some keyboards */
406	/* 101 */ KEY_Menu,	/* Menu */
407	/* 102 */ KEY_NOTUSED,
408	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
409	/* 104 */ KEY_NOTUSED,
410	/* 105 */ KEY_NOTUSED,
411	/* 106 */ KEY_NOTUSED,
412	/* 107 */ KEY_NOTUSED,
413	/* 108 */ KEY_NOTUSED,
414	/* 109 */ KEY_NOTUSED,
415	/* 110 */ KEY_NOTUSED,
416	/* 111 */ KEY_NOTUSED,
417	/* 112 */ KEY_NOTUSED,
418	/* 113 */ KEY_NOTUSED,
419	/* 114 */ KEY_NOTUSED,
420	/* 115 */ KEY_NOTUSED,
421	/* 116 */ KEY_NOTUSED,
422	/* 117 */ KEY_NOTUSED,
423	/* 118 */ KEY_NOTUSED,
424	/* 119 */ KEY_NOTUSED,
425	/* 120 */ KEY_NOTUSED,
426	/* 121 */ KEY_NOTUSED,
427	/* 122 */ KEY_NOTUSED,
428	/* 123 */ KEY_NOTUSED,
429	/* 124 */ KEY_NOTUSED,
430	/* 125 */ KEY_NOTUSED,
431	/* 126 */ KEY_NOTUSED,
432	/* 127 */ KEY_NOTUSED,
433	/* 128 */ KEY_NOTUSED,
434	/* 129 */ KEY_NOTUSED,
435	/* 130 */ KEY_NOTUSED,
436	/* 131 */ KEY_NOTUSED,
437	/* 132 */ KEY_NOTUSED,
438	/* 133 */ KEY_NOTUSED,
439	/* 134 */ KEY_NOTUSED,
440	/* 135 */ KEY_NOTUSED,
441	/* 136 */ KEY_NOTUSED,
442	/* 137 */ KEY_NOTUSED,
443	/* 138 */ KEY_NOTUSED,
444	/* 139 */ KEY_NOTUSED,
445	/* 140 */ KEY_NOTUSED,
446	/* 141 */ KEY_NOTUSED,
447	/* 142 */ KEY_NOTUSED,
448	/* 143 */ KEY_NOTUSED,
449	/* 144 */ KEY_NOTUSED,
450	/* 145 */ KEY_NOTUSED,
451	/* 146 */ KEY_NOTUSED,
452	/* 147 */ KEY_NOTUSED,
453	/* 148 */ KEY_NOTUSED,
454	/* 149 */ KEY_NOTUSED,
455	/* 150 */ KEY_NOTUSED,
456	/* 151 */ KEY_NOTUSED,
457	/* 152 */ KEY_NOTUSED,
458	/* 153 */ KEY_NOTUSED,
459	/* 154 */ KEY_NOTUSED,
460	/* 155 */ KEY_NOTUSED,
461	/* 156 */ KEY_NOTUSED,
462	/* 157 */ KEY_NOTUSED,
463	/* 158 */ KEY_NOTUSED,
464	/* 159 */ KEY_NOTUSED,
465	/* 160 */ KEY_NOTUSED,
466	/* 161 */ KEY_NOTUSED,
467	/* 162 */ KEY_NOTUSED,
468	/* 163 */ KEY_NOTUSED,
469	/* 164 */ KEY_NOTUSED,
470	/* 165 */ KEY_NOTUSED,
471	/* 166 */ KEY_NOTUSED,
472	/* 167 */ KEY_NOTUSED,
473	/* 168 */ KEY_NOTUSED,
474	/* 169 */ KEY_NOTUSED,
475	/* 170 */ KEY_NOTUSED,
476	/* 171 */ KEY_NOTUSED,
477	/* 172 */ KEY_NOTUSED,
478	/* 173 */ KEY_NOTUSED,
479	/* 174 */ KEY_NOTUSED,
480	/* 175 */ KEY_NOTUSED,
481	/* 176 */ KEY_NOTUSED,
482	/* 177 */ KEY_NOTUSED,
483	/* 178 */ KEY_NOTUSED,
484	/* 179 */ KEY_NOTUSED,
485	/* 180 */ KEY_NOTUSED,
486	/* 181 */ KEY_NOTUSED,
487	/* 182 */ KEY_NOTUSED,
488	/* 183 */ KEY_NOTUSED,
489	/* 184 */ KEY_NOTUSED,
490	/* 185 */ KEY_NOTUSED,
491	/* 186 */ KEY_NOTUSED,
492	/* 187 */ KEY_NOTUSED,
493	/* 188 */ KEY_NOTUSED,
494	/* 189 */ KEY_NOTUSED,
495	/* 190 */ KEY_NOTUSED,
496	/* 191 */ KEY_NOTUSED,
497	/* 192 */ KEY_NOTUSED,
498	/* 193 */ KEY_NOTUSED,
499	/* 194 */ KEY_NOTUSED,
500	/* 195 */ KEY_NOTUSED,
501	/* 196 */ KEY_NOTUSED,
502	/* 197 */ KEY_NOTUSED,
503	/* 198 */ KEY_NOTUSED,
504	/* 199 */ KEY_NOTUSED,
505	/* 200 */ KEY_NOTUSED,
506	/* 201 */ KEY_NOTUSED,
507	/* 202 */ KEY_NOTUSED,
508	/* 203 */ KEY_NOTUSED,
509	/* 204 */ KEY_NOTUSED,
510	/* 205 */ KEY_NOTUSED,
511	/* 206 */ KEY_NOTUSED,
512	/* 207 */ KEY_NOTUSED,
513	/* 208 */ KEY_NOTUSED,
514	/* 209 */ KEY_NOTUSED,
515	/* 210 */ KEY_NOTUSED,
516	/* 211 */ KEY_NOTUSED,
517	/* 212 */ KEY_NOTUSED,
518	/* 213 */ KEY_NOTUSED,
519	/* 214 */ KEY_NOTUSED,
520	/* 215 */ KEY_NOTUSED,
521	/* 216 */ KEY_NOTUSED,
522	/* 217 */ KEY_NOTUSED,
523	/* 218 */ KEY_NOTUSED,
524	/* 219 */ KEY_NOTUSED,
525	/* 220 */ KEY_NOTUSED,
526	/* 221 */ KEY_NOTUSED,
527	/* 222 */ KEY_NOTUSED,
528	/* 223 */ KEY_NOTUSED,
529	/* 224 */ KEY_LCtrl,	/* Left Control */
530	/* 225 */ KEY_ShiftL,	/* Left Shift */
531	/* 226 */ KEY_Alt,	/* Left Alt */
532	/* 227 */ KEY_LMeta,	/* Left Meta */
533	/* 228 */ KEY_RCtrl,	/* Right Control */
534	/* 229 */ KEY_ShiftR,	/* Right Shift */
535	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
536	/* 231 */ KEY_LMeta,	/* Right Meta XXX */
537};
538#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
539
540static
541TransMapRec wsUsb = {
542    0,
543    WS_USB_MAP_SIZE,
544    wsUsbMap
545};
546
547static CARD8 wsXtMap[] = {
548	/* 0 */ KEY_NOTUSED,
549	/* 1 */ KEY_Escape,
550	/* 2 */ KEY_1,
551	/* 3 */ KEY_2,
552	/* 4 */ KEY_3,
553	/* 5 */ KEY_4,
554	/* 6 */ KEY_5,
555	/* 7 */ KEY_6,
556	/* 8 */ KEY_7,
557	/* 9 */ KEY_8,
558	/* 10 */ KEY_9,
559	/* 11 */ KEY_0,
560	/* 12 */ KEY_Minus,
561	/* 13 */ KEY_Equal,
562	/* 14 */ KEY_BackSpace,
563	/* 15 */ KEY_Tab,
564	/* 16 */ KEY_Q,
565	/* 17 */ KEY_W,
566	/* 18 */ KEY_E,
567	/* 19 */ KEY_R,
568	/* 20 */ KEY_T,
569	/* 21 */ KEY_Y,
570	/* 22 */ KEY_U,
571	/* 23 */ KEY_I,
572	/* 24 */ KEY_O,
573	/* 25 */ KEY_P,
574	/* 26 */ KEY_LBrace,
575	/* 27 */ KEY_RBrace,
576	/* 28 */ KEY_Enter,
577	/* 29 */ KEY_LCtrl,
578	/* 30 */ KEY_A,
579	/* 31 */ KEY_S,
580	/* 32 */ KEY_D,
581	/* 33 */ KEY_F,
582	/* 34 */ KEY_G,
583	/* 35 */ KEY_H,
584	/* 36 */ KEY_J,
585	/* 37 */ KEY_K,
586	/* 38 */ KEY_L,
587	/* 39 */ KEY_SemiColon,
588	/* 40 */ KEY_Quote,
589	/* 41 */ KEY_Tilde,
590	/* 42 */ KEY_ShiftL,
591	/* 43 */ KEY_BSlash,
592	/* 44 */ KEY_Z,
593	/* 45 */ KEY_X,
594	/* 46 */ KEY_C,
595	/* 47 */ KEY_V,
596	/* 48 */ KEY_B,
597	/* 49 */ KEY_N,
598	/* 50 */ KEY_M,
599	/* 51 */ KEY_Comma,
600	/* 52 */ KEY_Period,
601	/* 53 */ KEY_Slash,
602	/* 54 */ KEY_ShiftR,
603	/* 55 */ KEY_KP_Multiply,
604	/* 56 */ KEY_Alt,
605	/* 57 */ KEY_Space,
606	/* 58 */ KEY_CapsLock,
607	/* 59 */ KEY_F1,
608	/* 60 */ KEY_F2,
609	/* 61 */ KEY_F3,
610	/* 62 */ KEY_F4,
611	/* 63 */ KEY_F5,
612	/* 64 */ KEY_F6,
613	/* 65 */ KEY_F7,
614	/* 66 */ KEY_F8,
615	/* 67 */ KEY_F9,
616	/* 68 */ KEY_F10,
617	/* 69 */ KEY_NumLock,
618	/* 70 */ KEY_ScrollLock,
619	/* 71 */ KEY_KP_7,
620	/* 72 */ KEY_KP_8,
621	/* 73 */ KEY_KP_9,
622	/* 74 */ KEY_KP_Minus,
623	/* 75 */ KEY_KP_4,
624	/* 76 */ KEY_KP_5,
625	/* 77 */ KEY_KP_6,
626	/* 78 */ KEY_KP_Plus,
627	/* 79 */ KEY_KP_1,
628	/* 80 */ KEY_KP_2,
629	/* 81 */ KEY_KP_3,
630	/* 82 */ KEY_KP_0,
631	/* 83 */ KEY_KP_Decimal,
632	/* 84 */ KEY_NOTUSED,
633	/* 85 */ KEY_NOTUSED,
634	/* 86 */ KEY_Less,	/* backslash on uk, < on german */
635	/* 87 */ KEY_F11,
636	/* 88 */ KEY_F12,
637	/* 89 */ KEY_NOTUSED,
638	/* 90 */ KEY_NOTUSED,
639	/* 91 */ KEY_NOTUSED,
640	/* 92 */ KEY_NOTUSED,
641	/* 93 */ KEY_NOTUSED,
642	/* 94 */ KEY_NOTUSED,
643	/* 95 */ KEY_NOTUSED,
644	/* 96 */ KEY_NOTUSED,
645	/* 97 */ KEY_NOTUSED,
646	/* 98 */ KEY_NOTUSED,
647	/* 99 */ KEY_NOTUSED,
648	/* 100 */ KEY_NOTUSED,
649	/* 101 */ KEY_NOTUSED,
650	/* 102 */ KEY_NOTUSED,
651	/* 103 */ KEY_NOTUSED,
652	/* 104 */ KEY_NOTUSED,
653	/* 105 */ KEY_NOTUSED,
654	/* 106 */ KEY_NOTUSED,
655	/* 107 */ KEY_NOTUSED,
656	/* 108 */ KEY_NOTUSED,
657	/* 109 */ KEY_NOTUSED,
658	/* 110 */ KEY_NOTUSED,
659	/* 111 */ KEY_NOTUSED,
660	/* 112 */ KEY_NOTUSED,
661	/* 113 */ KEY_NOTUSED,
662	/* 114 */ KEY_NOTUSED,
663	/* 115 */ KEY_NOTUSED,
664	/* 116 */ KEY_NOTUSED,
665	/* 117 */ KEY_NOTUSED,
666	/* 118 */ KEY_NOTUSED,
667	/* 119 */ KEY_NOTUSED,
668	/* 120 */ KEY_NOTUSED,
669	/* 121 */ KEY_NOTUSED,
670	/* 122 */ KEY_NOTUSED,
671	/* 123 */ KEY_NOTUSED,
672	/* 124 */ KEY_NOTUSED,
673	/* 125 */ KEY_NOTUSED,
674	/* 126 */ KEY_NOTUSED,
675	/* 127 */ KEY_Pause,
676	/* 128 */ KEY_NOTUSED,
677	/* 129 */ KEY_NOTUSED,
678	/* 130 */ KEY_NOTUSED,
679	/* 131 */ KEY_NOTUSED,
680	/* 132 */ KEY_NOTUSED,
681	/* 133 */ KEY_NOTUSED,
682	/* 134 */ KEY_NOTUSED,
683	/* 135 */ KEY_NOTUSED,
684	/* 136 */ KEY_NOTUSED,
685	/* 137 */ KEY_NOTUSED,
686	/* 138 */ KEY_NOTUSED,
687	/* 139 */ KEY_NOTUSED,
688	/* 140 */ KEY_NOTUSED,
689	/* 141 */ KEY_NOTUSED,
690	/* 142 */ KEY_NOTUSED,
691	/* 143 */ KEY_NOTUSED,
692	/* 144 */ KEY_NOTUSED,
693	/* 145 */ KEY_NOTUSED,
694	/* 146 */ KEY_NOTUSED,
695	/* 147 */ KEY_NOTUSED,
696	/* 148 */ KEY_NOTUSED,
697	/* 149 */ KEY_NOTUSED,
698	/* 150 */ KEY_NOTUSED,
699	/* 151 */ KEY_NOTUSED,
700	/* 152 */ KEY_NOTUSED,
701	/* 153 */ KEY_NOTUSED,
702	/* 154 */ KEY_NOTUSED,
703	/* 155 */ KEY_NOTUSED,
704	/* 156 */ KEY_KP_Enter,
705	/* 157 */ KEY_RCtrl,
706	/* 158 */ KEY_NOTUSED,
707	/* 159 */ KEY_NOTUSED,
708	/* 160 */ KEY_Mute,
709	/* 161 */ KEY_NOTUSED,
710	/* 162 */ KEY_NOTUSED,
711	/* 163 */ KEY_NOTUSED,
712	/* 164 */ KEY_NOTUSED,
713	/* 165 */ KEY_NOTUSED,
714	/* 166 */ KEY_NOTUSED,
715	/* 167 */ KEY_NOTUSED,
716	/* 168 */ KEY_NOTUSED,
717	/* 169 */ KEY_NOTUSED,
718	/* 170 */ KEY_Print,
719	/* 171 */ KEY_NOTUSED,
720	/* 172 */ KEY_NOTUSED,
721	/* 173 */ KEY_NOTUSED,
722	/* 174 */ KEY_AudioLower,
723	/* 175 */ KEY_AudioRaise,
724	/* 176 */ KEY_NOTUSED,
725	/* 177 */ KEY_NOTUSED,
726	/* 178 */ KEY_NOTUSED,
727	/* 179 */ KEY_NOTUSED,
728	/* 180 */ KEY_NOTUSED,
729	/* 181 */ KEY_KP_Divide,
730	/* 182 */ KEY_NOTUSED,
731	/* 183 */ KEY_Print,
732	/* 184 */ KEY_AltLang,
733	/* 185 */ KEY_NOTUSED,
734	/* 186 */ KEY_NOTUSED,
735	/* 187 */ KEY_NOTUSED,
736	/* 188 */ KEY_NOTUSED,
737	/* 189 */ KEY_NOTUSED,
738	/* 190 */ KEY_NOTUSED,
739	/* 191 */ KEY_NOTUSED,
740	/* 192 */ KEY_NOTUSED,
741	/* 193 */ KEY_NOTUSED,
742	/* 194 */ KEY_NOTUSED,
743	/* 195 */ KEY_NOTUSED,
744	/* 196 */ KEY_NOTUSED,
745	/* 197 */ KEY_NOTUSED,
746	/* 198 */ KEY_NOTUSED,
747	/* 199 */ KEY_Home,
748	/* 200 */ KEY_Up,
749	/* 201 */ KEY_PgUp,
750	/* 202 */ KEY_NOTUSED,
751	/* 203 */ KEY_Left,
752	/* 204 */ KEY_NOTUSED,
753	/* 205 */ KEY_Right,
754	/* 206 */ KEY_NOTUSED,
755	/* 207 */ KEY_End,
756	/* 208 */ KEY_Down,
757	/* 209 */ KEY_PgDown,
758	/* 210 */ KEY_Insert,
759	/* 211 */ KEY_Delete,
760	/* 212 */ KEY_NOTUSED,
761	/* 213 */ KEY_NOTUSED,
762	/* 214 */ KEY_NOTUSED,
763	/* 215 */ KEY_NOTUSED,
764	/* 216 */ KEY_NOTUSED,
765	/* 217 */ KEY_NOTUSED,
766	/* 218 */ KEY_NOTUSED,
767	/* 219 */ KEY_LMeta,
768	/* 220 */ KEY_RMeta,
769	/* 221 */ KEY_Menu,
770};
771#define WS_XT_MAP_SIZE (sizeof(wsXtMap)/sizeof(unsigned char))
772
773static
774TransMapRec wsXt = {
775    0,
776    WS_XT_MAP_SIZE,
777    wsXtMap
778};
779
780/* Map for adb keyboards  */
781static CARD8 wsAdbMap[] = {
782	/* 0 */ KEY_A,
783	/* 1 */ KEY_S,
784	/* 2 */ KEY_D,
785	/* 3 */ KEY_F,
786	/* 4 */ KEY_H,
787	/* 5 */ KEY_G,
788	/* 6 */ KEY_Z,
789	/* 7 */ KEY_X,
790	/* 8 */ KEY_C,
791	/* 9 */ KEY_V,
792	/* 10 */ KEY_UNKNOWN,	/* @ # on french keyboards */
793	/* 11 */ KEY_B,
794	/* 12 */ KEY_Q,
795	/* 13 */ KEY_W,
796	/* 14 */ KEY_E,
797	/* 15 */ KEY_R,
798	/* 16 */ KEY_Y,
799	/* 17 */ KEY_T,
800	/* 18 */ KEY_1,
801	/* 19 */ KEY_2,
802	/* 20 */ KEY_3,
803	/* 21 */ KEY_4,
804	/* 22 */ KEY_6,
805	/* 23 */ KEY_5,
806	/* 24 */ KEY_Equal,
807	/* 25 */ KEY_9,
808	/* 26 */ KEY_7,
809	/* 27 */ KEY_Minus,
810	/* 28 */ KEY_8,
811	/* 29 */ KEY_0,
812	/* 30 */ KEY_RBrace,
813	/* 31 */ KEY_O,
814	/* 32 */ KEY_U,
815	/* 33 */ KEY_LBrace,
816	/* 34 */ KEY_I,
817	/* 35 */ KEY_P,
818	/* 36 */ KEY_Enter,
819	/* 37 */ KEY_L,
820	/* 38 */ KEY_J,
821	/* 39 */ KEY_Quote,
822	/* 40 */ KEY_K,
823	/* 41 */ KEY_SemiColon,
824	/* 42 */ KEY_BSlash,
825	/* 43 */ KEY_Comma,
826	/* 44 */ KEY_Slash,
827	/* 45 */ KEY_N,
828	/* 46 */ KEY_M,
829	/* 47 */ KEY_Period,
830	/* 48 */ KEY_Tab,
831	/* 49 */ KEY_Space,
832	/* 50 */ KEY_Tilde,
833	/* 51 */ KEY_BackSpace,
834	/* 52 */ KEY_AltLang,
835	/* 53 */ KEY_Escape,
836	/* 54 */ KEY_LCtrl,
837	/* 55 */ KEY_LMeta,
838	/* 56 */ KEY_ShiftL,
839	/* 57 */ KEY_CapsLock,
840	/* 58 */ KEY_Alt,
841	/* 59 */ KEY_Left,
842	/* 60 */ KEY_Right,
843	/* 61 */ KEY_Down,
844	/* 62 */ KEY_Up,
845	/* 63 */ KEY_UNKNOWN,	/* Fn */
846	/* 64 */ KEY_NOTUSED,
847	/* 65 */ KEY_KP_Decimal,
848	/* 66 */ KEY_NOTUSED,
849	/* 67 */ KEY_KP_Multiply,
850	/* 68 */ KEY_NOTUSED,
851	/* 69 */ KEY_KP_Plus,
852	/* 70 */ KEY_NOTUSED,
853	/* 71 */ KEY_NumLock,	/* Clear */
854	/* 72 */ KEY_NOTUSED,
855	/* 73 */ KEY_NOTUSED,
856	/* 74 */ KEY_NOTUSED,
857	/* 75 */ KEY_KP_Divide,
858	/* 76 */ KEY_KP_Enter,
859	/* 77 */ KEY_NOTUSED,
860	/* 78 */ KEY_KP_Minus,
861	/* 79 */ KEY_NOTUSED,
862	/* 80 */ KEY_NOTUSED,
863	/* 81 */ KEY_KP_Equal,	/* Keypad = */
864	/* 82 */ KEY_KP_0,
865	/* 83 */ KEY_KP_1,
866	/* 84 */ KEY_KP_2,
867	/* 85 */ KEY_KP_3,
868	/* 86 */ KEY_KP_4,
869	/* 87 */ KEY_KP_5,
870	/* 88 */ KEY_KP_6,
871	/* 89 */ KEY_KP_7,
872	/* 90 */ KEY_NOTUSED,
873	/* 91 */ KEY_KP_8,
874	/* 92 */ KEY_KP_9,
875	/* 93 */ KEY_NOTUSED,
876	/* 94 */ KEY_NOTUSED,
877	/* 95 */ KEY_KP_Decimal,	/* Keypad ,  */
878	/* 96 */ KEY_F5,
879	/* 97 */ KEY_F6,
880	/* 98 */ KEY_F7,
881	/* 99 */ KEY_F3,
882	/* 100 */ KEY_F8,
883	/* 101 */ KEY_F9,
884	/* 102 */ KEY_NOTUSED,
885	/* 103 */ KEY_F11,
886	/* 104 */ KEY_NOTUSED,
887	/* 105 */ KEY_Print,
888	/* 106 */ KEY_KP_Enter,
889	/* 107 */ KEY_ScrollLock,
890	/* 108 */ KEY_NOTUSED,
891	/* 109 */ KEY_F10,
892	/* 110 */ KEY_NOTUSED,
893	/* 111 */ KEY_F12,
894	/* 112 */ KEY_NOTUSED,
895	/* 113 */ KEY_Pause,
896	/* 114 */ KEY_Insert,
897	/* 115 */ KEY_Home,
898	/* 116 */ KEY_PgUp,
899	/* 117 */ KEY_Delete,
900	/* 118 */ KEY_F4,
901	/* 119 */ KEY_End,
902	/* 120 */ KEY_F2,
903	/* 121 */ KEY_PgDown,
904	/* 122 */ KEY_F1,
905	/* 123 */ KEY_NOTUSED,
906	/* 124 */ KEY_NOTUSED,
907	/* 125 */ KEY_NOTUSED,
908	/* 126 */ KEY_NOTUSED,
909	/* 127 */ KEY_Power
910};
911#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
912
913static
914TransMapRec wsAdb = {
915    0,
916    WS_ADB_MAP_SIZE,
917    wsAdbMap
918};
919
920static CARD8 wsSunMap[] = {
921	/* 0x00 */ KEY_Help,
922	/* 0x01 */ KEY_L1,		/* stop */
923	/* 0x02 */ KEY_AudioLower,	/* BrightnessDown / S-VolumeDown */
924	/* 0x03 */ KEY_L2,		/* again */
925	/* 0x04 */ KEY_AudioRaise,	/* BridgtnessUp / S-VolumeUp */
926	/* 0x05 */ KEY_F1,
927	/* 0x06 */ KEY_F2,
928	/* 0x07 */ KEY_F10,
929	/* 0x08 */ KEY_F3,
930	/* 0x09 */ KEY_F11,
931	/* 0x0a */ KEY_F4,
932	/* 0x0b */ KEY_F12,
933	/* 0x0c */ KEY_F5,
934	/* 0x0d */ KEY_AltLang,
935	/* 0x0e */ KEY_F6,
936	/* 0x0f */ KEY_NOTUSED,
937	/* 0x10 */ KEY_F7,
938	/* 0x11 */ KEY_F8,
939	/* 0x12 */ KEY_F9,
940	/* 0x13 */ KEY_Alt,
941	/* 0x14 */ KEY_Up,
942	/* 0x15 */ KEY_Pause,
943	/* 0x16 */ KEY_Print,
944	/* 0x17 */ KEY_ScrollLock,
945	/* 0x18 */ KEY_Left,
946	/* 0x19 */ KEY_L3,		/* props */
947	/* 0x1a */ KEY_L4,		/* undo */
948	/* 0x1b */ KEY_Down,
949	/* 0x1c */ KEY_Right,
950	/* 0x1d */ KEY_Escape,
951	/* 0x1e */ KEY_1,
952	/* 0x1f */ KEY_2,
953	/* 0x20 */ KEY_3,
954	/* 0x21 */ KEY_4,
955	/* 0x22 */ KEY_5,
956	/* 0x23 */ KEY_6,
957	/* 0x24 */ KEY_7,
958	/* 0x25 */ KEY_8,
959	/* 0x26 */ KEY_9,
960	/* 0x27 */ KEY_0,
961	/* 0x28 */ KEY_Minus,
962	/* 0x29 */ KEY_Equal,
963	/* 0x2a */ KEY_Tilde,
964	/* 0x2b */ KEY_BackSpace,
965	/* 0x2c */ KEY_Insert,
966	/* 0x2d */ KEY_Mute,		/* Audio Mute */
967	/* 0x2e */ KEY_KP_Divide,
968	/* 0x2f */ KEY_KP_Multiply,
969	/* 0x30 */ KEY_Power,
970	/* 0x31 */ KEY_L5,		/* front */
971	/* 0x32 */ KEY_KP_Decimal,
972	/* 0x33 */ KEY_L6,		/* copy */
973	/* 0x34 */ KEY_Home,
974	/* 0x35 */ KEY_Tab,
975	/* 0x36 */ KEY_Q,
976	/* 0x37 */ KEY_W,
977	/* 0x38 */ KEY_E,
978	/* 0x39 */ KEY_R,
979	/* 0x3a */ KEY_T,
980	/* 0x3b */ KEY_Y,
981	/* 0x3c */ KEY_U,
982	/* 0x3d */ KEY_I,
983	/* 0x3e */ KEY_O,
984	/* 0x3f */ KEY_P,
985	/* 0x40 */ KEY_LBrace,
986	/* 0x41 */ KEY_RBrace,
987	/* 0x42 */ KEY_Delete,
988	/* 0x43 */ KEY_Menu,		/* compose */
989	/* 0x44 */ KEY_KP_7,
990	/* 0x45 */ KEY_KP_8,
991	/* 0x46 */ KEY_KP_9,
992	/* 0x47 */ KEY_KP_Minus,
993	/* 0x48 */ KEY_L7,		/* open */
994	/* 0x49 */ KEY_L8,		/* paste */
995	/* 0x4a */ KEY_End,
996	/* 0x4b */ KEY_NOTUSED,
997	/* 0x4c */ KEY_LCtrl,
998	/* 0x4d */ KEY_A,
999	/* 0x4e */ KEY_S,
1000	/* 0x4f */ KEY_D,
1001	/* 0x50 */ KEY_F,
1002	/* 0x51 */ KEY_G,
1003	/* 0x52 */ KEY_H,
1004	/* 0x53 */ KEY_J,
1005	/* 0x54 */ KEY_K,
1006	/* 0x55 */ KEY_L,
1007	/* 0x56 */ KEY_SemiColon,
1008	/* 0x57 */ KEY_Quote,
1009	/* 0x58 */ KEY_BSlash,
1010	/* 0x59 */ KEY_Enter,
1011	/* 0x5a */ KEY_KP_Enter,
1012	/* 0x5b */ KEY_KP_4,
1013	/* 0x5c */ KEY_KP_5,
1014	/* 0x5d */ KEY_KP_6,
1015	/* 0x5e */ KEY_KP_0,
1016	/* 0x5f */ KEY_L9,		/* find */
1017	/* 0x60 */ KEY_PgUp,
1018	/* 0x61 */ KEY_L10,		/* cut */
1019	/* 0x62 */ KEY_NumLock,
1020	/* 0x63 */ KEY_ShiftL,
1021	/* 0x64 */ KEY_Z,
1022	/* 0x65 */ KEY_X,
1023	/* 0x66 */ KEY_C,
1024	/* 0x67 */ KEY_V,
1025	/* 0x68 */ KEY_B,
1026	/* 0x69 */ KEY_N,
1027	/* 0x6a */ KEY_M,
1028	/* 0x6b */ KEY_Comma,
1029	/* 0x6c */ KEY_Period,
1030	/* 0x6d */ KEY_Slash,
1031	/* 0x6e */ KEY_ShiftR,
1032	/* 0x6f */ KEY_NOTUSED,		/* linefeed */
1033	/* 0x70 */ KEY_KP_1,
1034	/* 0x71 */ KEY_KP_2,
1035	/* 0x72 */ KEY_KP_3,
1036	/* 0x73 */ KEY_NOTUSED,
1037	/* 0x74 */ KEY_NOTUSED,
1038	/* 0x75 */ KEY_NOTUSED,
1039	/* 0x76 */ KEY_Help,		/* help */
1040	/* 0x77 */ KEY_CapsLock,
1041	/* 0x78 */ KEY_LMeta,
1042	/* 0x79 */ KEY_Space,
1043	/* 0x7a */ KEY_RMeta,
1044	/* 0x7b */ KEY_PgDown,
1045	/* 0x7c */ KEY_Less,		/* < > on some keyboards */
1046	/* 0x7d */ KEY_KP_Plus,
1047	/* 0x7e */ KEY_NOTUSED,
1048	/* 0x7f */ KEY_NOTUSED
1049};
1050#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
1051
1052static
1053TransMapRec wsSun = {
1054    0,
1055    WS_SUN_MAP_SIZE,
1056    wsSunMap
1057};
1058
1059#endif /* WSCONS_SUPPORT */
1060
1061/*ARGSUSED*/
1062
1063/*
1064 * KbdGetMapping --
1065 *	Get the national keyboard mapping. The keyboard type is set, a new map
1066 *      and the modifiermap is computed.
1067 */
1068
1069void
1070KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
1071{
1072  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
1073  KeySym        *k;
1074  int           i;
1075
1076#ifndef __bsdi__
1077  switch (pKbd->consType) {
1078
1079#ifdef PCCONS_SUPPORT
1080  case PCCONS:
1081#if defined(__OpenBSD__)
1082    /*
1083     * on OpenBSD, the pccons keymap is programmable, too
1084     */
1085    {
1086      pccons_keymap_t keymap[KB_NUM_KEYS];
1087      if (ioctl(pInfo->fd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
1088	for (i = 0; i < KB_NUM_KEYS; i++)
1089	  if (pccons_remap[i]) {
1090	    k = map + (pccons_remap[i] << 2);
1091	    switch (keymap[i].type) {
1092	    case KB_ASCII:
1093	      /* For ASCII keys, there is only one char in the keymap */
1094	      k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
1095	      k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
1096	      k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
1097	      k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
1098	      break;
1099	    case KB_SCROLL:
1100	      k[0] = XK_Scroll_Lock;
1101	      goto special;
1102	    case KB_NUM:
1103	      k[0] = XK_Num_Lock;
1104	      goto special;
1105	    case KB_CAPS:
1106	      k[0] = XK_Caps_Lock;
1107	      goto special;
1108	    case KB_SHIFT:
1109	      switch (keymap[i].unshift[0]) {
1110	      case 1:
1111		/* left shift */
1112		k[0] = XK_Shift_L;
1113		break;
1114	      case 2:
1115		/* right shift */
1116		k[0] = XK_Shift_R;
1117		break;
1118	      default:
1119		k[0] = NoSymbol;
1120	      }
1121	      goto special;
1122	    case KB_CTL:
1123	      k[0] = XK_Control_L;
1124	      goto special;
1125	    case KB_ALT:
1126	      k[0] = XK_Alt_L;
1127	      goto special;
1128	    case KB_FUNC:
1129	      switch (keymap[i].unshift[2]) {
1130	      case 'M':
1131		k[0] = XK_F1;
1132		break;
1133	      case 'N':
1134		k[0] = XK_F2;
1135		break;
1136	      case 'O':
1137		k[0] = XK_F3;
1138		break;
1139	      case 'P':
1140		k[0] = XK_F4;
1141		break;
1142	      case 'Q':
1143		k[0] = XK_F5;
1144		break;
1145	      case 'R':
1146		k[0] = XK_F6;
1147		break;
1148	      case 'S':
1149		k[0] = XK_F7;
1150		break;
1151	      case 'T':
1152		k[0] = XK_F8;
1153		break;
1154	      case 'U':
1155		k[0] = XK_F9;
1156		break;
1157	      case 'V':
1158		k[0] = XK_F10;
1159		break;
1160	      case 'W':
1161		k[0] = XK_F11;
1162		break;
1163	      case 'X':
1164		k[0] = XK_F12;
1165		break;
1166	      default:
1167		k[0] = NoSymbol;
1168		break;
1169	      }
1170	      goto special;
1171	    default:
1172	      k[0] = NoSymbol;
1173	    special:
1174	      k[1] = k[2] = k[3] = NoSymbol;
1175	    }
1176	  }
1177      } else {
1178	ErrorF("Can't read pccons keymap\n");
1179      }
1180    }
1181#endif /* __OpenBSD__ */
1182  break;
1183#endif
1184
1185/*
1186 * XXX wscons has no GIO_KEYMAP
1187 */
1188#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
1189  case SYSCONS:
1190  case PCVT:
1191    {
1192      keymap_t keymap;
1193
1194      if (ioctl(pInfo->fd, GIO_KEYMAP, &keymap) != -1) {
1195	for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
1196	  if (remap[i]) {
1197	    k = map + (remap[i] << 2);
1198	    k[0] = KD_GET_ENTRY(i,0);           /* non-shifed */
1199	    k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
1200	    k[2] = KD_GET_ENTRY(i,4);	      /* alt */
1201	    k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
1202	    if (k[3] == k[2]) k[3] = NoSymbol;
1203	    if (k[2] == k[1]) k[2] = NoSymbol;
1204	    if (k[1] == k[0]) k[1] = NoSymbol;
1205	    if (k[0] == k[2] && k[1] == k[3])
1206	      k[2] = k[3] = NoSymbol;
1207	  }
1208      }
1209    }
1210    break;
1211#endif /* SYSCONS || PCVT */
1212
1213  }
1214#endif /* !bsdi */
1215
1216  /*
1217   * compute the modifier map
1218   */
1219  for (i = 0; i < MAP_LENGTH; i++)
1220    pModMap[i] = NoSymbol;  /* make sure it is restored */
1221
1222  for (k = map, i = MIN_KEYCODE;
1223       i < (NUM_KEYCODES + MIN_KEYCODE);
1224       i++, k += 4)
1225
1226    switch(*k) {
1227
1228    case XK_Shift_L:
1229    case XK_Shift_R:
1230      pModMap[i] = ShiftMask;
1231      break;
1232
1233    case XK_Control_L:
1234    case XK_Control_R:
1235      pModMap[i] = ControlMask;
1236      break;
1237
1238    case XK_Caps_Lock:
1239      pModMap[i] = LockMask;
1240      break;
1241
1242    case XK_Alt_L:
1243    case XK_Alt_R:
1244      pModMap[i] = AltMask;
1245      break;
1246
1247    case XK_Num_Lock:
1248      pModMap[i] = NumLockMask;
1249      break;
1250
1251    case XK_Scroll_Lock:
1252      pModMap[i] = ScrollLockMask;
1253      break;
1254
1255      /* kana support */
1256    case XK_Kana_Lock:
1257    case XK_Kana_Shift:
1258      pModMap[i] = KanaMask;
1259      break;
1260
1261      /* alternate toggle for multinational support */
1262    case XK_Mode_switch:
1263      pModMap[i] = AltLangMask;
1264      break;
1265
1266    }
1267
1268  pKbd->kbdType = 0;
1269
1270  pKeySyms->map        = map;
1271  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
1272  pKeySyms->minKeyCode = MIN_KEYCODE;
1273  pKeySyms->maxKeyCode = MAX_KEYCODE;
1274
1275  switch(pKbd->consType) {
1276#ifdef SYSCONS_SUPPORT
1277      case SYSCONS:
1278           if (pKbd->CustomKeycodes)
1279              pKbd->scancodeMap = &sysconsCODE;
1280           else
1281              pKbd->RemapScanCode = ATScancode;
1282           break;
1283#endif
1284#if defined(PCCONS_SUPPORT) || defined (PCVT_SUPPORT)
1285      case PCCONS:
1286      case PCVT:
1287           pKbd->RemapScanCode = ATScancode;
1288	   break;
1289#endif
1290#ifdef WSCONS_SUPPORT
1291      case WSCONS:
1292	if (!pKbd->isConsole) {
1293           switch (pKbd->wsKbdType) {
1294	       case WSKBD_TYPE_PC_XT:
1295	       case WSKBD_TYPE_PC_AT:
1296                    pKbd->scancodeMap = &wsXt;
1297                    break;
1298	       case WSKBD_TYPE_USB:
1299#ifdef WSKBD_TYPE_MAPLE
1300	       case WSKBD_TYPE_MAPLE:
1301#endif
1302                    pKbd->scancodeMap = &wsUsb;
1303                    break;
1304#ifdef WSKBD_TYPE_ADB
1305	       case WSKBD_TYPE_ADB:
1306                    pKbd->scancodeMap = &wsAdb;
1307                    break;
1308#endif
1309#ifdef WSKBD_TYPE_SUN
1310#ifdef WSKBD_TYPE_SUN5
1311	       case WSKBD_TYPE_SUN5:
1312#endif
1313	       case WSKBD_TYPE_SUN:
1314                    pKbd->scancodeMap = &wsSun;
1315                    break;
1316#endif
1317	       default:
1318		    ErrorF("Unknown wskbd type %d\n", pKbd->wsKbdType);
1319           }
1320	} else {
1321           pKbd->RemapScanCode = ATScancode;
1322	}
1323      break;
1324#endif
1325  }
1326  return;
1327}
1328