1d49df8baStsutsui/* $NetBSD: ws_KbdMap.c,v 1.1 2023/11/07 14:29:00 tsutsui Exp $	*/
2d49df8baStsutsui/* $XConsortium: sunKeyMap.c,v 4.22 94/05/18 11:16:07 kaleb Exp $ */
3d49df8baStsutsui/************************************************************
4d49df8baStsutsuiCopyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
5d49df8baStsutsui
6d49df8baStsutsui                    All Rights Reserved
7d49df8baStsutsui
8d49df8baStsutsuiPermission  to  use,  copy,  modify,  and  distribute   this
9d49df8baStsutsuisoftware  and  its documentation for any purpose and without
10d49df8baStsutsuifee is hereby granted, provided that the above copyright no-
11d49df8baStsutsuitice  appear  in all copies and that both that copyright no-
12d49df8baStsutsuitice and this permission notice appear in  supporting  docu-
13d49df8baStsutsuimentation,  and  that the names of Sun or X Consortium
14d49df8baStsutsuinot be used in advertising or publicity pertaining to
15d49df8baStsutsuidistribution  of  the software  without specific prior
16d49df8baStsutsuiwritten permission. Sun and X Consortium make no
17d49df8baStsutsuirepresentations about the suitability of this software for
18d49df8baStsutsuiany purpose. It is provided "as is" without any express or
19d49df8baStsutsuiimplied warranty.
20d49df8baStsutsui
21d49df8baStsutsuiSUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
22d49df8baStsutsuiINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
23d49df8baStsutsuiNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
24d49df8baStsutsuiABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
25d49df8baStsutsuiANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
26d49df8baStsutsuiPROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
27d49df8baStsutsuiOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
28d49df8baStsutsuiTHE USE OR PERFORMANCE OF THIS SOFTWARE.
29d49df8baStsutsui
30d49df8baStsutsui********************************************************/
31d49df8baStsutsui
32d49df8baStsutsui/*
33d49df8baStsutsui * Generate XKB keymap from wskbd keymap provided by WSKBDIO_GETMAP ioctl
34d49df8baStsutsui *
35d49df8baStsutsui * Taken from:
36d49df8baStsutsui * 	xsrc/xfree/xc/programs/Xserver/hw/netbsd/hpc/hpcKeymap.c
37d49df8baStsutsui * 	NetBSD: hpcKeymap.c,v 1.2 2004/07/22 18:08:59 uch Exp
38d49df8baStsutsui */
39d49df8baStsutsui
40d49df8baStsutsui#ifdef HAVE_CONFIG_H
41d49df8baStsutsui#include "config.h"
42d49df8baStsutsui#endif
43d49df8baStsutsui
44d49df8baStsutsui#include "xf86.h"
45d49df8baStsutsui#include "xf86OSKbd.h"
46d49df8baStsutsui#include "atKeynames.h"
47d49df8baStsutsui#include "xf86Keymap.h"
48d49df8baStsutsui#include "xkbsrv.h"
49d49df8baStsutsui
50d49df8baStsutsui#include "bsd_kbd.h"
51d49df8baStsutsui
52d49df8baStsutsui#include <sys/ioctl.h>
53d49df8baStsutsui#include <dev/wscons/wsconsio.h>
54d49df8baStsutsui#include <dev/wscons/wsksymdef.h>
55d49df8baStsutsui
56d49df8baStsutsuistatic void KeymapSetSymbol(KeySym *, CARD8 *, struct wscons_keymap *);
57d49df8baStsutsui
58d49df8baStsutsuistatic KeySym wsksym_to_xkeysym[] = {
59d49df8baStsutsui	[KS_BackSpace] = XK_BackSpace,
60d49df8baStsutsui	[KS_Tab] = XK_Tab,
61d49df8baStsutsui	[KS_Linefeed] = XK_Linefeed,
62d49df8baStsutsui	[KS_Clear] = XK_Clear,
63d49df8baStsutsui	[KS_Return] = XK_Return,
64d49df8baStsutsui	[KS_Escape] = XK_Escape,
65d49df8baStsutsui	[KS_space] = XK_space,
66d49df8baStsutsui	[KS_exclam] = XK_exclam,
67d49df8baStsutsui	[KS_quotedbl] = XK_quotedbl,
68d49df8baStsutsui	[KS_numbersign] = XK_numbersign,
69d49df8baStsutsui	[KS_dollar] = XK_dollar,
70d49df8baStsutsui	[KS_percent] = XK_percent,
71d49df8baStsutsui	[KS_ampersand] = XK_ampersand,
72d49df8baStsutsui	[KS_apostrophe] = XK_apostrophe,
73d49df8baStsutsui	[KS_parenleft] = XK_parenleft,
74d49df8baStsutsui	[KS_parenright] = XK_parenright,
75d49df8baStsutsui	[KS_asterisk] = XK_asterisk,
76d49df8baStsutsui	[KS_plus] = XK_plus,
77d49df8baStsutsui	[KS_comma] = XK_comma,
78d49df8baStsutsui	[KS_minus] = XK_minus,
79d49df8baStsutsui	[KS_period] = XK_period,
80d49df8baStsutsui	[KS_slash] = XK_slash,
81d49df8baStsutsui	[KS_0] = XK_0,
82d49df8baStsutsui	[KS_1] = XK_1,
83d49df8baStsutsui	[KS_2] = XK_2,
84d49df8baStsutsui	[KS_3] = XK_3,
85d49df8baStsutsui	[KS_4] = XK_4,
86d49df8baStsutsui	[KS_5] = XK_5,
87d49df8baStsutsui	[KS_6] = XK_6,
88d49df8baStsutsui	[KS_7] = XK_7,
89d49df8baStsutsui	[KS_8] = XK_8,
90d49df8baStsutsui	[KS_9] = XK_9,
91d49df8baStsutsui	[KS_colon] = XK_colon,
92d49df8baStsutsui	[KS_semicolon] = XK_semicolon,
93d49df8baStsutsui	[KS_less] = XK_less,
94d49df8baStsutsui	[KS_equal] = XK_equal,
95d49df8baStsutsui	[KS_greater] = XK_greater,
96d49df8baStsutsui	[KS_question] = XK_question,
97d49df8baStsutsui	[KS_at] = XK_at,
98d49df8baStsutsui	[KS_A] = XK_A,
99d49df8baStsutsui	[KS_B] = XK_B,
100d49df8baStsutsui	[KS_C] = XK_C,
101d49df8baStsutsui	[KS_D] = XK_D,
102d49df8baStsutsui	[KS_E] = XK_E,
103d49df8baStsutsui	[KS_F] = XK_F,
104d49df8baStsutsui	[KS_G] = XK_G,
105d49df8baStsutsui	[KS_H] = XK_H,
106d49df8baStsutsui	[KS_I] = XK_I,
107d49df8baStsutsui	[KS_J] = XK_J,
108d49df8baStsutsui	[KS_K] = XK_K,
109d49df8baStsutsui	[KS_L] = XK_L,
110d49df8baStsutsui	[KS_M] = XK_M,
111d49df8baStsutsui	[KS_N] = XK_N,
112d49df8baStsutsui	[KS_O] = XK_O,
113d49df8baStsutsui	[KS_P] = XK_P,
114d49df8baStsutsui	[KS_Q] = XK_Q,
115d49df8baStsutsui	[KS_R] = XK_R,
116d49df8baStsutsui	[KS_S] = XK_S,
117d49df8baStsutsui	[KS_T] = XK_T,
118d49df8baStsutsui	[KS_U] = XK_U,
119d49df8baStsutsui	[KS_V] = XK_V,
120d49df8baStsutsui	[KS_W] = XK_W,
121d49df8baStsutsui	[KS_X] = XK_X,
122d49df8baStsutsui	[KS_Y] = XK_Y,
123d49df8baStsutsui	[KS_Z] = XK_Z,
124d49df8baStsutsui	[KS_bracketleft] = XK_bracketleft,
125d49df8baStsutsui	[KS_backslash] = XK_backslash,
126d49df8baStsutsui	[KS_bracketright] = XK_bracketright,
127d49df8baStsutsui	[KS_asciicircum] = XK_asciicircum,
128d49df8baStsutsui	[KS_underscore] = XK_underscore,
129d49df8baStsutsui	[KS_grave] = XK_grave,
130d49df8baStsutsui	[KS_a] = XK_a,
131d49df8baStsutsui	[KS_b] = XK_b,
132d49df8baStsutsui	[KS_c] = XK_c,
133d49df8baStsutsui	[KS_d] = XK_d,
134d49df8baStsutsui	[KS_e] = XK_e,
135d49df8baStsutsui	[KS_f] = XK_f,
136d49df8baStsutsui	[KS_g] = XK_g,
137d49df8baStsutsui	[KS_h] = XK_h,
138d49df8baStsutsui	[KS_i] = XK_i,
139d49df8baStsutsui	[KS_j] = XK_j,
140d49df8baStsutsui	[KS_k] = XK_k,
141d49df8baStsutsui	[KS_l] = XK_l,
142d49df8baStsutsui	[KS_m] = XK_m,
143d49df8baStsutsui	[KS_n] = XK_n,
144d49df8baStsutsui	[KS_o] = XK_o,
145d49df8baStsutsui	[KS_p] = XK_p,
146d49df8baStsutsui	[KS_q] = XK_q,
147d49df8baStsutsui	[KS_r] = XK_r,
148d49df8baStsutsui	[KS_s] = XK_s,
149d49df8baStsutsui	[KS_t] = XK_t,
150d49df8baStsutsui	[KS_u] = XK_u,
151d49df8baStsutsui	[KS_v] = XK_v,
152d49df8baStsutsui	[KS_w] = XK_w,
153d49df8baStsutsui	[KS_x] = XK_x,
154d49df8baStsutsui	[KS_y] = XK_y,
155d49df8baStsutsui	[KS_z] = XK_z,
156d49df8baStsutsui	[KS_braceleft] = XK_braceleft,
157d49df8baStsutsui	[KS_bar] = XK_bar,
158d49df8baStsutsui	[KS_braceright] = XK_braceright,
159d49df8baStsutsui	[KS_asciitilde] = XK_asciitilde,
160d49df8baStsutsui	[KS_Delete] = XK_Delete,
161d49df8baStsutsui	[KS_nobreakspace] = XK_nobreakspace,
162d49df8baStsutsui	[KS_exclamdown] = XK_exclamdown,
163d49df8baStsutsui	[KS_cent] = XK_cent,
164d49df8baStsutsui	[KS_sterling] = XK_sterling,
165d49df8baStsutsui	[KS_currency] = XK_currency,
166d49df8baStsutsui	[KS_yen] = XK_yen,
167d49df8baStsutsui	[KS_brokenbar] = XK_brokenbar,
168d49df8baStsutsui	[KS_section] = XK_section,
169d49df8baStsutsui	[KS_diaeresis] = XK_diaeresis,
170d49df8baStsutsui	[KS_copyright] = XK_copyright,
171d49df8baStsutsui	[KS_ordfeminine] = XK_ordfeminine,
172d49df8baStsutsui	[KS_guillemotleft] = XK_guillemotleft,
173d49df8baStsutsui	[KS_notsign] = XK_notsign,
174d49df8baStsutsui	[KS_hyphen] = XK_hyphen,
175d49df8baStsutsui	[KS_registered] = XK_registered,
176d49df8baStsutsui	[KS_macron] = XK_macron,
177d49df8baStsutsui	[KS_degree] = XK_degree,
178d49df8baStsutsui	[KS_plusminus] = XK_plusminus,
179d49df8baStsutsui	[KS_twosuperior] = XK_twosuperior,
180d49df8baStsutsui	[KS_threesuperior] = XK_threesuperior,
181d49df8baStsutsui	[KS_acute] = XK_acute,
182d49df8baStsutsui	[KS_mu] = XK_mu,
183d49df8baStsutsui	[KS_paragraph] = XK_paragraph,
184d49df8baStsutsui	[KS_periodcentered] = XK_periodcentered,
185d49df8baStsutsui	[KS_cedilla] = XK_cedilla,
186d49df8baStsutsui	[KS_onesuperior] = XK_onesuperior,
187d49df8baStsutsui	[KS_masculine] = XK_masculine,
188d49df8baStsutsui	[KS_guillemotright] = XK_guillemotright,
189d49df8baStsutsui	[KS_onequarter] = XK_onequarter,
190d49df8baStsutsui	[KS_onehalf] = XK_onehalf,
191d49df8baStsutsui	[KS_threequarters] = XK_threequarters,
192d49df8baStsutsui	[KS_questiondown] = XK_questiondown,
193d49df8baStsutsui	[KS_Agrave] = XK_Agrave,
194d49df8baStsutsui	[KS_Aacute] = XK_Aacute,
195d49df8baStsutsui	[KS_Acircumflex] = XK_Acircumflex,
196d49df8baStsutsui	[KS_Atilde] = XK_Atilde,
197d49df8baStsutsui	[KS_Adiaeresis] = XK_Adiaeresis,
198d49df8baStsutsui	[KS_Aring] = XK_Aring,
199d49df8baStsutsui	[KS_AE] = XK_AE,
200d49df8baStsutsui	[KS_Ccedilla] = XK_Ccedilla,
201d49df8baStsutsui	[KS_Egrave] = XK_Egrave,
202d49df8baStsutsui	[KS_Eacute] = XK_Eacute,
203d49df8baStsutsui	[KS_Ecircumflex] = XK_Ecircumflex,
204d49df8baStsutsui	[KS_Ediaeresis] = XK_Ediaeresis,
205d49df8baStsutsui	[KS_Igrave] = XK_Igrave,
206d49df8baStsutsui	[KS_Iacute] = XK_Iacute,
207d49df8baStsutsui	[KS_Icircumflex] = XK_Icircumflex,
208d49df8baStsutsui	[KS_Idiaeresis] = XK_Idiaeresis,
209d49df8baStsutsui	[KS_ETH] = XK_ETH,
210d49df8baStsutsui	[KS_Ntilde] = XK_Ntilde,
211d49df8baStsutsui	[KS_Ograve] = XK_Ograve,
212d49df8baStsutsui	[KS_Oacute] = XK_Oacute,
213d49df8baStsutsui	[KS_Ocircumflex] = XK_Ocircumflex,
214d49df8baStsutsui	[KS_Otilde] = XK_Otilde,
215d49df8baStsutsui	[KS_Odiaeresis] = XK_Odiaeresis,
216d49df8baStsutsui	[KS_multiply] = XK_multiply,
217d49df8baStsutsui	[KS_Ooblique] = XK_Ooblique,
218d49df8baStsutsui	[KS_Ugrave] = XK_Ugrave,
219d49df8baStsutsui	[KS_Uacute] = XK_Uacute,
220d49df8baStsutsui	[KS_Ucircumflex] = XK_Ucircumflex,
221d49df8baStsutsui	[KS_Udiaeresis] = XK_Udiaeresis,
222d49df8baStsutsui	[KS_Yacute] = XK_Yacute,
223d49df8baStsutsui	[KS_THORN] = XK_THORN,
224d49df8baStsutsui	[KS_ssharp] = XK_ssharp,
225d49df8baStsutsui	[KS_agrave] = XK_agrave,
226d49df8baStsutsui	[KS_aacute] = XK_aacute,
227d49df8baStsutsui	[KS_acircumflex] = XK_acircumflex,
228d49df8baStsutsui	[KS_atilde] = XK_atilde,
229d49df8baStsutsui	[KS_adiaeresis] = XK_adiaeresis,
230d49df8baStsutsui	[KS_aring] = XK_aring,
231d49df8baStsutsui	[KS_ae] = XK_ae,
232d49df8baStsutsui	[KS_ccedilla] = XK_ccedilla,
233d49df8baStsutsui	[KS_egrave] = XK_egrave,
234d49df8baStsutsui	[KS_eacute] = XK_eacute,
235d49df8baStsutsui	[KS_ecircumflex] = XK_ecircumflex,
236d49df8baStsutsui	[KS_ediaeresis] = XK_ediaeresis,
237d49df8baStsutsui	[KS_igrave] = XK_igrave,
238d49df8baStsutsui	[KS_iacute] = XK_iacute,
239d49df8baStsutsui	[KS_icircumflex] = XK_icircumflex,
240d49df8baStsutsui	[KS_idiaeresis] = XK_idiaeresis,
241d49df8baStsutsui	[KS_eth] = XK_eth,
242d49df8baStsutsui	[KS_ntilde] = XK_ntilde,
243d49df8baStsutsui	[KS_ograve] = XK_ograve,
244d49df8baStsutsui	[KS_oacute] = XK_oacute,
245d49df8baStsutsui	[KS_ocircumflex] = XK_ocircumflex,
246d49df8baStsutsui	[KS_otilde] = XK_otilde,
247d49df8baStsutsui	[KS_odiaeresis] = XK_odiaeresis,
248d49df8baStsutsui	[KS_division] = XK_division,
249d49df8baStsutsui	[KS_oslash] = XK_oslash,
250d49df8baStsutsui	[KS_ugrave] = XK_ugrave,
251d49df8baStsutsui	[KS_uacute] = XK_uacute,
252d49df8baStsutsui	[KS_ucircumflex] = XK_ucircumflex,
253d49df8baStsutsui	[KS_udiaeresis] = XK_udiaeresis,
254d49df8baStsutsui	[KS_yacute] = XK_yacute,
255d49df8baStsutsui	[KS_thorn] = XK_thorn,
256d49df8baStsutsui	[KS_ydiaeresis] = XK_ydiaeresis,
257d49df8baStsutsui	[KS_Odoubleacute] = XK_Odoubleacute,
258d49df8baStsutsui	[KS_odoubleacute] = XK_odoubleacute,
259d49df8baStsutsui	[KS_Udoubleacute] = XK_Udoubleacute,
260d49df8baStsutsui	[KS_udoubleacute] = XK_udoubleacute,
261d49df8baStsutsui	[KS_dead_grave] = XK_dead_grave,
262d49df8baStsutsui	[KS_dead_acute] = XK_dead_acute,
263d49df8baStsutsui	[KS_dead_circumflex] = XK_dead_circumflex,
264d49df8baStsutsui	[KS_dead_tilde] = XK_dead_tilde,
265d49df8baStsutsui	[KS_dead_diaeresis] = XK_dead_diaeresis,
266d49df8baStsutsui	[KS_dead_abovering] = XK_dead_abovering,
267d49df8baStsutsui	[KS_dead_cedilla] = XK_dead_cedilla,
268d49df8baStsutsui	[KS_Shift_L] = XK_Shift_L,
269d49df8baStsutsui	[KS_Shift_R] = XK_Shift_R,
270d49df8baStsutsui	[KS_Control_L] = XK_Control_L,
271d49df8baStsutsui	[KS_Control_R] = XK_Control_R,
272d49df8baStsutsui	[KS_Caps_Lock] = XK_Caps_Lock,
273d49df8baStsutsui	[KS_Shift_Lock] = XK_Shift_Lock,
274d49df8baStsutsui	[KS_Alt_L] = XK_Alt_L,
275d49df8baStsutsui	[KS_Alt_R] = XK_Alt_R,
276d49df8baStsutsui	[KS_Multi_key] = XK_Multi_key,
277d49df8baStsutsui	[KS_Mode_switch] = XK_Mode_switch,
278d49df8baStsutsui	[KS_Num_Lock] = XK_Num_Lock,
279d49df8baStsutsui	[KS_Meta_L] = XK_Meta_L,
280d49df8baStsutsui	[KS_Meta_R] = XK_Meta_R,
281d49df8baStsutsui	[KS_Zenkaku_Hankaku] = XK_Zenkaku_Hankaku,
282d49df8baStsutsui	[KS_Hiragana_Katakana] = XK_Hiragana_Katakana,
283d49df8baStsutsui	[KS_Henkan_Mode] = XK_Henkan_Mode,
284d49df8baStsutsui	[KS_Henkan] = XK_Henkan,
285d49df8baStsutsui	[KS_Muhenkan] = XK_Muhenkan,
286d49df8baStsutsui	[KS_KP_F1] = XK_KP_F1,
287d49df8baStsutsui	[KS_KP_F2] = XK_KP_F2,
288d49df8baStsutsui	[KS_KP_F3] = XK_KP_F3,
289d49df8baStsutsui	[KS_KP_F4] = XK_KP_F4,
290d49df8baStsutsui	[KS_KP_Home] = XK_KP_Home,
291d49df8baStsutsui	[KS_KP_Left] = XK_KP_Left,
292d49df8baStsutsui	[KS_KP_Up] = XK_KP_Up,
293d49df8baStsutsui	[KS_KP_Right] = XK_KP_Right,
294d49df8baStsutsui	[KS_KP_Down] = XK_KP_Down,
295d49df8baStsutsui	[KS_KP_Prior] = XK_KP_Prior,
296d49df8baStsutsui	[KS_KP_Next] = XK_KP_Next,
297d49df8baStsutsui	[KS_KP_End] = XK_KP_End,
298d49df8baStsutsui	[KS_KP_Begin] = XK_KP_Begin,
299d49df8baStsutsui	[KS_KP_Insert] = XK_KP_Insert,
300d49df8baStsutsui	[KS_KP_Delete] = XK_KP_Delete,
301d49df8baStsutsui	[KS_KP_Space] = XK_KP_Space,
302d49df8baStsutsui	[KS_KP_Tab] = XK_KP_Tab,
303d49df8baStsutsui	[KS_KP_Enter] = XK_KP_Enter,
304d49df8baStsutsui	[KS_KP_Equal] = XK_KP_Equal,
305d49df8baStsutsui	[KS_KP_Numbersign] = XK_numbersign,
306d49df8baStsutsui	[KS_KP_Multiply] = XK_KP_Multiply,
307d49df8baStsutsui	[KS_KP_Add] = XK_KP_Add,
308d49df8baStsutsui	[KS_KP_Separator] = XK_KP_Separator,
309d49df8baStsutsui	[KS_KP_Subtract] = XK_KP_Subtract,
310d49df8baStsutsui	[KS_KP_Decimal] = XK_KP_Decimal,
311d49df8baStsutsui	[KS_KP_Divide] = XK_KP_Divide,
312d49df8baStsutsui	[KS_KP_0] = XK_KP_0,
313d49df8baStsutsui	[KS_KP_1] = XK_KP_1,
314d49df8baStsutsui	[KS_KP_2] = XK_KP_2,
315d49df8baStsutsui	[KS_KP_3] = XK_KP_3,
316d49df8baStsutsui	[KS_KP_4] = XK_KP_4,
317d49df8baStsutsui	[KS_KP_5] = XK_KP_5,
318d49df8baStsutsui	[KS_KP_6] = XK_KP_6,
319d49df8baStsutsui	[KS_KP_7] = XK_KP_7,
320d49df8baStsutsui	[KS_KP_8] = XK_KP_8,
321d49df8baStsutsui	[KS_KP_9] = XK_KP_9,
322d49df8baStsutsui	[KS_f1] = XK_F1,
323d49df8baStsutsui	[KS_f2] = XK_F2,
324d49df8baStsutsui	[KS_f3] = XK_F3,
325d49df8baStsutsui	[KS_f4] = XK_F4,
326d49df8baStsutsui	[KS_f5] = XK_F5,
327d49df8baStsutsui	[KS_f6] = XK_F6,
328d49df8baStsutsui	[KS_f7] = XK_F7,
329d49df8baStsutsui	[KS_f8] = XK_F8,
330d49df8baStsutsui	[KS_f9] = XK_F9,
331d49df8baStsutsui	[KS_f10] = XK_F10,
332d49df8baStsutsui	[KS_f11] = XK_F11,
333d49df8baStsutsui	[KS_f12] = XK_F12,
334d49df8baStsutsui	[KS_f13] = XK_F13,
335d49df8baStsutsui	[KS_f14] = XK_F14,
336d49df8baStsutsui	[KS_f15] = XK_F15,
337d49df8baStsutsui	[KS_f16] = XK_F16,
338d49df8baStsutsui	[KS_f17] = XK_F17,
339d49df8baStsutsui	[KS_f18] = XK_F18,
340d49df8baStsutsui	[KS_f19] = XK_F19,
341d49df8baStsutsui	[KS_f20] = XK_F20,
342d49df8baStsutsui	[KS_F1] = XK_F1,
343d49df8baStsutsui	[KS_F2] = XK_F2,
344d49df8baStsutsui	[KS_F3] = XK_F3,
345d49df8baStsutsui	[KS_F4] = XK_F4,
346d49df8baStsutsui	[KS_F5] = XK_F5,
347d49df8baStsutsui	[KS_F6] = XK_F6,
348d49df8baStsutsui	[KS_F7] = XK_F7,
349d49df8baStsutsui	[KS_F8] = XK_F8,
350d49df8baStsutsui	[KS_F9] = XK_F9,
351d49df8baStsutsui	[KS_F10] = XK_F10,
352d49df8baStsutsui	[KS_F11] = XK_F11,
353d49df8baStsutsui	[KS_F12] = XK_F12,
354d49df8baStsutsui	[KS_F13] = XK_F13,
355d49df8baStsutsui	[KS_F14] = XK_F14,
356d49df8baStsutsui	[KS_F15] = XK_F15,
357d49df8baStsutsui	[KS_F16] = XK_F16,
358d49df8baStsutsui	[KS_F17] = XK_F17,
359d49df8baStsutsui	[KS_F18] = XK_F18,
360d49df8baStsutsui	[KS_F19] = XK_F19,
361d49df8baStsutsui	[KS_F20] = XK_F20,
362d49df8baStsutsui	[KS_Home] = XK_Home,
363d49df8baStsutsui	[KS_Prior] = XK_Prior,
364d49df8baStsutsui	[KS_Next] = XK_Next,
365d49df8baStsutsui	[KS_Up] = XK_Up,
366d49df8baStsutsui	[KS_Down] = XK_Down,
367d49df8baStsutsui	[KS_Left] = XK_Left,
368d49df8baStsutsui	[KS_Right] = XK_Right,
369d49df8baStsutsui	[KS_End] = XK_End,
370d49df8baStsutsui	[KS_Insert] = XK_Insert,
371d49df8baStsutsui	[KS_Help] = XK_Help,
372d49df8baStsutsui	[KS_Execute] = XK_Execute,
373d49df8baStsutsui	[KS_Find] = XK_Find,
374d49df8baStsutsui	[KS_Select] = XK_Select,
375d49df8baStsutsui	[KS_Undo] = XK_Undo,
376d49df8baStsutsui	[KS_Menu] = XK_Menu,
377d49df8baStsutsui	[KS_Pause] = XK_Pause,
378d49df8baStsutsui	[0xffff] = NoSymbol,
379d49df8baStsutsui};
380d49df8baStsutsui
381d49df8baStsutsuivoid
382d49df8baStsutsuiKbdGetMappingFromWsksym(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
383d49df8baStsutsui{
384d49df8baStsutsui	struct wskbd_map_data map_data;
385d49df8baStsutsui	struct wscons_keymap *wscons_keymap, *wscons_key;
386d49df8baStsutsui	KeySym *x_key;
387d49df8baStsutsui	CARD8 *x_mod;
388d49df8baStsutsui	int i;
389d49df8baStsutsui
390d49df8baStsutsui	wscons_keymap =
391d49df8baStsutsui	    malloc(sizeof(struct wscons_keymap) * WSKBDIO_MAXMAPLEN);
392d49df8baStsutsui	if (wscons_keymap == NULL) {
393d49df8baStsutsui		xf86Msg(X_ERROR, "%s: can't allocate wscons keymap memory\n",
394d49df8baStsutsui		    pInfo->name);
395d49df8baStsutsui		return;
396d49df8baStsutsui	}
397d49df8baStsutsui	memset(wscons_keymap, 0,
398d49df8baStsutsui	    sizeof(struct wscons_keymap) * WSKBDIO_MAXMAPLEN);
399d49df8baStsutsui	map_data.maplen = WSKBDIO_MAXMAPLEN;
400d49df8baStsutsui	map_data.map = wscons_keymap;
401d49df8baStsutsui
402d49df8baStsutsui	/* Get console keymap */
403d49df8baStsutsui	if (ioctl(pInfo->fd, WSKBDIO_GETMAP, &map_data) == -1) {
404d49df8baStsutsui		xf86Msg(X_ERROR, "%s: can't get wskbd keymap\n", pInfo->name);
405d49df8baStsutsui		return;
406d49df8baStsutsui	}
407d49df8baStsutsui	for (i = 0;
408d49df8baStsutsui	    i < sizeof wsksym_to_xkeysym / sizeof(wsksym_to_xkeysym[0]); i++)
409d49df8baStsutsui		if (wsksym_to_xkeysym[i] == 0)
410d49df8baStsutsui			wsksym_to_xkeysym[i] = NoSymbol;
411d49df8baStsutsui
412d49df8baStsutsui	pKeySyms->map        = map;
413d49df8baStsutsui	pKeySyms->mapWidth   = GLYPHS_PER_KEY;
414d49df8baStsutsui	pKeySyms->minKeyCode = MIN_KEYCODE;
415d49df8baStsutsui	pKeySyms->maxKeyCode = pKeySyms->minKeyCode + map_data.maplen - 1;
416d49df8baStsutsui
417d49df8baStsutsui	xf86Msg(X_INFO, "%s: Using keysyms via WSKBDIO_GETMAP\n", pInfo->name);
418d49df8baStsutsui	xf86Msg(X_INFO, "%s: total %d wskbd keysyms\n",
419d49df8baStsutsui	    pInfo->name, map_data.maplen);
420d49df8baStsutsui
421d49df8baStsutsui	/* Reconstruct keymap */
422d49df8baStsutsui	x_key = &pKeySyms->map[0];
423d49df8baStsutsui	x_mod = &pModMap[pKeySyms->minKeyCode];
424d49df8baStsutsui	wscons_key = wscons_keymap;
425d49df8baStsutsui	for (i = 0; i < map_data.maplen; i++) {
426d49df8baStsutsui		/* assume GLYPHS_PER_KEY is 4 */
427d49df8baStsutsui		if (i == NUM_KEYCODES) {
428d49df8baStsutsui			xf86Msg(X_WARNING, "%s: too many wskbd keysyms\n",
429d49df8baStsutsui			    pInfo->name);
430d49df8baStsutsui			break;
431d49df8baStsutsui		}
432d49df8baStsutsui		KeymapSetSymbol(x_key, x_mod, wscons_key);
433d49df8baStsutsui		x_key += GLYPHS_PER_KEY;
434d49df8baStsutsui		x_mod++;
435d49df8baStsutsui		wscons_key++;
436d49df8baStsutsui	}
437d49df8baStsutsui	free(wscons_keymap);
438d49df8baStsutsui}
439d49df8baStsutsui
440d49df8baStsutsuistatic void
441d49df8baStsutsuiKeymapSetSymbol(KeySym *xmap, CARD8 *pModMap, struct wscons_keymap *keymap)
442d49df8baStsutsui{
443d49df8baStsutsui
444d49df8baStsutsui	xmap[0] = wsksym_to_xkeysym[keymap->group1[0]];
445d49df8baStsutsui	xmap[1] = wsksym_to_xkeysym[keymap->group1[1]];
446d49df8baStsutsui	xmap[2] = wsksym_to_xkeysym[keymap->group2[0]];
447d49df8baStsutsui	xmap[3] = wsksym_to_xkeysym[keymap->group2[1]];
448d49df8baStsutsui
449d49df8baStsutsui	*pModMap = NoSymbol;
450d49df8baStsutsui	switch (xmap[0]) {
451d49df8baStsutsui	case XK_Shift_L:
452d49df8baStsutsui	case XK_Shift_R:
453d49df8baStsutsui		*pModMap = ShiftMask;
454d49df8baStsutsui		break;
455d49df8baStsutsui	case XK_Control_L:
456d49df8baStsutsui	case XK_Control_R:
457d49df8baStsutsui		*pModMap = ControlMask;
458d49df8baStsutsui		break;
459d49df8baStsutsui	case XK_Caps_Lock:
460d49df8baStsutsui		*pModMap = LockMask;
461d49df8baStsutsui		break;
462d49df8baStsutsui	case XK_Alt_L:
463d49df8baStsutsui		*pModMap = AltMask;
464d49df8baStsutsui		xmap[1] = XK_Meta_L;
465d49df8baStsutsui		break;
466d49df8baStsutsui	case XK_Alt_R:
467d49df8baStsutsui		*pModMap = AltMask;
468d49df8baStsutsui		xmap[1] = XK_Meta_R;
469d49df8baStsutsui		break;
470d49df8baStsutsui	case XK_Num_Lock:
471d49df8baStsutsui		*pModMap = NumLockMask;
472d49df8baStsutsui		break;
473d49df8baStsutsui	case XK_Scroll_Lock:
474d49df8baStsutsui		*pModMap = ScrollLockMask;
475d49df8baStsutsui		break;
476d49df8baStsutsui	case XK_Kana_Lock:
477d49df8baStsutsui	case XK_Kana_Shift:
478d49df8baStsutsui		*pModMap = KanaMask;
479d49df8baStsutsui		break;
480d49df8baStsutsui	case XK_Mode_switch:	/* XXX */
481d49df8baStsutsui		*pModMap = AltLangMask;
482d49df8baStsutsui		break;
483d49df8baStsutsui	default:
484d49df8baStsutsui		break;
485d49df8baStsutsui	}
486d49df8baStsutsui}
487