1 /*        $NetBSD: hilkbdmap.c,v 1.4 2022/08/11 23:38:45 gutteridge Exp $       */
2 /*        $OpenBSD: hilkbdmap.c,v 1.7 2005/05/07 22:42:30 miod Exp $  */
3 /*
4  * Copyright (c) 2003, Miodrag Vallat.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 #include "opt_wsdisplay_compat.h"
31 
32 #include <sys/types.h>
33 #include <dev/wscons/wsksymdef.h>
34 #include <dev/wscons/wsksymvar.h>
35 #include <dev/hil/hilkbdmap.h>
36 
37 #ifdef WSDISPLAY_COMPAT_RAWKBD
38 
39 /*
40  * Translate HIL keycodes to US keyboard XT scancodes, for proper
41  * X11-over-wsmux operation.
42  *
43  * XXX: Needs re-think how we should treat RAWKBD code on NetBSD.
44  */
45 const uint8_t hilkbd_raw[0x80] = {
46           0x9d, 0x00, 0xb8, 0x38, 0x36, 0x2a, 0x1d, 0x6a,
47           0x4b, 0x48, 0x4c, 0x49, 0x4d, 0x47, 0x53, 0x9c,
48           0x4f, 0xb5, 0x50, 0x4e, 0x51, 0x37, 0x52, 0x4a,
49           0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x00, 0x00, 0x01,
50           0x00, 0x44, 0x00, 0x57, 0x53, 0x43, 0x0f, 0x58,
51           0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x00, 0x3a,
52           0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f,
53           0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x29,
54           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55           0x67, 0x3e, 0x3d, 0x3c, 0x3b, 0x00, 0x46, 0x1c,
56           0x45, 0x3f, 0x40, 0x41, 0x42, 0x00, 0x00, 0x00,
57           0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x00, 0x00,
58           0x17, 0x18, 0x19, 0x1a, 0x1b, 0x2b, 0xd2, 0xd3,
59           0x24, 0x25, 0x26, 0x27, 0x28, 0x1c, 0xc7, 0xc9,
60           0x32, 0x33, 0x34, 0x35, 0x00, 0xcf, 0x00, 0xd1,
61           0x31, 0x39, 0x00, 0x00, 0xcb, 0xd0, 0xc8, 0xcd
62 };
63 #endif
64 
65 #define KC(n) KS_KEYCODE(n)
66 
67 /*
68  * 1f. US ASCII
69  *
70  * We use the same table for PS/2 and old HIL keyboards, as the only
71  * differences are a few keys which are only present in one of both layouts,
72  * and the one-function-only keypad in the old HIL flavour (hilkbd.c knows
73  * about this and does The Right Thing).
74  */
75 
76 static const keysym_t hilkbd_keydesc_us[] = {
77 /*  pos      command                    normal              shifted */
78     KC(0),   KS_Cmd1,                   KS_Control_R,
79     KC(2),   KS_Cmd2,                   KS_Mode_switch,     KS_Multi_key,
80     KC(3),   KS_Cmd2,                   KS_Alt_L,
81     KC(4),   KS_Cmd,                    KS_Shift_R,
82     KC(5),   KS_Cmd,                    KS_Shift_L,
83     KC(6),   KS_Cmd1,                   KS_Control_L,
84     KC(7),   KS_Cmd_Debugger,                     /* Break/Reset */
85     KC(8),                              KS_KP_Left,         KS_KP_4,
86     KC(9),                              KS_KP_Up, KS_KP_8,
87     KC(10),                             KS_KP_Begin,        KS_KP_5,
88     KC(11),                             KS_KP_Prior,        KS_KP_9,
89     KC(12),                             KS_KP_Right,        KS_KP_6,
90     KC(13),                             KS_KP_Home,         KS_KP_7,
91     KC(14),                             KS_KP_Separator,
92     KC(15),                             KS_KP_Enter,
93     KC(16),                             KS_KP_End,          KS_KP_1,
94     KC(17),                             KS_KP_Divide,
95     KC(18),                             KS_KP_Down,         KS_KP_2,
96     KC(19),                             KS_KP_Add,
97     KC(20),                             KS_KP_Next,         KS_KP_3,
98     KC(21),                             KS_KP_Multiply,
99     KC(22),                             KS_KP_Insert,       KS_KP_0,
100     KC(23),                             KS_KP_Subtract,
101     KC(24),                             KS_b,
102     KC(25),                             KS_v,               KS_V,               KS_section,
103     KC(26),                             KS_c,               KS_C,               KS_ccedilla,
104     KC(27),                             KS_x,               KS_X,
105     KC(28),                             KS_z,               KS_Z,               KS_paragraph,
106     /* 29 Kanji Left */
107 
108     KC(31), KS_Cmd_Debugger,  KS_Escape,          KS_Delete,
109     KC(33), KS_Cmd_Screen9,   KS_f10,             /* also KS_KP_F2 */
110     KC(35),                             KS_f11,             /* also KS_KP_F3 */
111     KC(36),                             KS_KP_Delete,       KS_KP_Decimal,
112     KC(37), KS_Cmd_Screen8,   KS_f9,              /* also KS_KP_F1 */
113     KC(38),                             KS_Tab,             /* numeric pad */
114     KC(39),                             KS_f12,             /* also KS_KP_F4 */
115     KC(40),                             KS_h,               KS_H,               KS_yen,
116     KC(41),                             KS_g,               KS_G,               KS_currency,
117     KC(42),                             KS_f,
118     KC(43),                             KS_d,               KS_D,               KS_eth,
119     KC(44),                             KS_s,               KS_S,               KS_ssharp,
120     KC(45),                             KS_a,               KS_A,               KS_aring,
121     /* 46 Mode_Switch ??? */
122     KC(47),                             KS_Caps_Lock,
123     KC(48),                             KS_u,               KS_U,               KS_dead_diaeresis,
124     KC(49),                             KS_y,               KS_Y,               KS_dead_circumflex,
125     KC(50),                             KS_t,               KS_T,               KS_dead_grave,
126     KC(51),                             KS_r,               KS_R,               KS_dead_acute,
127     KC(52),                             KS_e,               KS_E,               KS_ae,
128     KC(53),                             KS_w,               KS_W,               KS_asciitilde,
129     KC(54),                             KS_q,               KS_Q,               KS_periodcentered,
130     KC(55),                             KS_Tab,
131     KC(56),                             KS_7,               KS_ampersand,       KS_backslash,
132     KC(57),                             KS_6,               KS_asciicircum,     KS_asciicircum,
133     KC(58),                             KS_5,               KS_percent,         KS_onehalf,
134     KC(59),                             KS_4,               KS_dollar,
135                                         KS_onequarter,      KS_threequarters,
136     KC(60),                             KS_3,               KS_numbersign,      KS_numbersign,
137     KC(61),                             KS_2,               KS_at,              KS_at,
138     KC(62),                             KS_1,               KS_exclam,          KS_exclamdown,
139     KC(63),                             KS_grave, KS_asciitilde,
140                                         KS_guillemotleft,KS_guillemotright,
141 
142     KC(72),                             KS_Print_Screen, /* Menu */
143     KC(73),  KS_Cmd_Screen3,  KS_f4,
144     KC(74),  KS_Cmd_Screen2,  KS_f3,
145     KC(75),  KS_Cmd_Screen1,  KS_f2,
146     KC(76),  KS_Cmd_Screen0,  KS_f1,
147 
148     KC(78),                             KS_Hold_Screen,
149     KC(79),                             KS_Return,          KS_Print_Screen,
150     KC(80),                             KS_Num_Lock,        /* System/User */
151     KC(81),  KS_Cmd_Screen4,  KS_f5,
152     KC(82),  KS_Cmd_Screen5,  KS_f6,
153     KC(83),  KS_Cmd_Screen6,  KS_f7,
154     KC(84),  KS_Cmd_Screen7,  KS_f8,
155 
156     /* 86 Clear line */
157     KC(87),                             KS_Clear,
158     KC(88),                             KS_8,               KS_asterisk,
159                                         KS_bracketleft,     KS_braceleft,
160     KC(89),                             KS_9,               KS_parenleft,
161                                         KS_bracketright,KS_braceright,
162     KC(90),                             KS_0,               KS_parenright,      KS_questiondown,
163     KC(91),                             KS_minus, KS_underscore,      KS_macron,
164     KC(92),                             KS_equal, KS_plus,  KS_plusminus,
165     KC(93),  KS_Cmd_ResetEmul,          KS_Delete,          /* Backspace */
166     /* 94 Insert line */
167     /* 95 Delete line */
168     KC(96),                             KS_i,               KS_I,               KS_dead_tilde,
169     KC(97),                             KS_o,               KS_O,               KS_oslash,
170     KC(98),                             KS_p,               KS_P,               KS_thorn,
171     KC(99),                             KS_bracketleft,     KS_braceleft,       KS_degree,
172     KC(100),                            KS_bracketright,KS_braceright,
173                                         KS_bar,             KS_brokenbar,
174     KC(101),                            KS_backslash,       KS_bar,             KS_mu,
175     KC(102),                            KS_Insert,
176     KC(103),                            KS_Delete,
177     KC(104),                            KS_j,               KS_J,               KS_dollar,
178     KC(105),                            KS_k,               KS_K,               KS_cent,
179     KC(106),                            KS_l,               KS_L,               KS_sterling,
180     KC(107),                            KS_semicolon,       KS_colon,
181     KC(108),                            KS_apostrophe,      KS_quotedbl,
182                                         KS_grave, KS_apostrophe,
183     KC(109),                            KS_Return,
184     KC(110),                            KS_Home,
185     KC(111),                            KS_Prior,
186     KC(112),                            KS_m,               KS_M,               KS_masculine,
187     KC(113),                            KS_comma, KS_less,  KS_less,
188     KC(114),                            KS_period,          KS_greater,         KS_greater,
189     KC(115),                            KS_slash, KS_question,        KS_underscore,
190 
191     KC(117),                            KS_End,             /* Select */
192 
193     KC(119),                            KS_Next,
194     KC(120),                            KS_n,               KS_N,               KS_ordfeminine,
195     KC(121),                            KS_space,
196 
197     /* 123 Kanji Right */
198     KC(124),                            KS_Left,
199     KC(125),                            KS_Down,
200     KC(126),                            KS_Up,
201     KC(127),                            KS_Right,
202 };
203 
204 /*
205  * 0e. Swedish
206  */
207 
208 static const keysym_t hilkbd_keydesc_sv[] = {
209     KC(56),         KS_7,               KS_slash, KS_backslash,
210     KC(57),         KS_6,               KS_ampersand,       KS_asciicircum,
211     KC(61),         KS_2,               KS_quotedbl,        KS_at,
212     KC(63),         KS_less,  KS_greater,
213                     KS_guillemotleft,KS_guillemotright,
214     KC(88),         KS_8,               KS_parenleft,       KS_bracketleft,     KS_braceleft,
215     KC(89),         KS_9,               KS_parenright,      KS_bracketright,KS_braceright,
216     KC(90),         KS_0,               KS_equal, KS_exclamdown,
217     KC(91),         KS_plus,  KS_question,        KS_macron,
218     KC(92),         KS_eacute,          KS_Eacute,          KS_plusminus,
219     KC(99),         KS_aring, KS_Aring, KS_degree,
220     KC(100),        KS_udiaeresis,      KS_Udiaeresis,      KS_bar,             KS_brokenbar,
221     KC(101),        KS_apostrophe,      KS_asterisk,        KS_mu,
222     KC(107),        KS_odiaeresis,
223     KC(108),        KS_adiaeresis,      KS_Adiaeresis,      KS_grave, KS_apostrophe,
224     KC(113),        KS_comma, KS_semicolon,       KS_less,
225     KC(114),        KS_period,          KS_colon, KS_greater,
226     KC(115),        KS_minus, KS_underscore,      KS_underscore
227 };
228 
229 static const keysym_t hilkbd_keydesc_sv_nodead[] = {
230     KC(48),         KS_u,               KS_U,               KS_diaeresis,
231     KC(49),         KS_y,               KS_Y,               KS_asciicircum,
232     KC(50),         KS_t,               KS_T,               KS_grave,
233     KC(51),         KS_r,               KS_R,               KS_apostrophe,
234     KC(96),         KS_i,               KS_I,               KS_asciitilde,
235 };
236 
237 static const keysym_t hilkbd_keydesc_sv_ps2[] = {
238     KC(24),         KS_b,
239     KC(25),         KS_v,
240     KC(26),         KS_c,
241     KC(27),         KS_x,
242     KC(28),         KS_z,
243     KC(36),         KS_KP_Separator,KS_KP_Delete,
244     KC(40),         KS_h,
245     KC(41),         KS_g,
246     KC(42),         KS_f,
247     KC(43),         KS_d,
248     KC(44),         KS_s,
249     KC(45),         KS_a,
250     KC(48),         KS_u,
251     KC(49),         KS_y,
252     KC(50),         KS_t,
253     KC(51),         KS_r,
254     KC(52),         KS_e,
255     KC(53),         KS_w,
256     KC(54),         KS_q,
257     KC(56),         KS_7,               KS_slash, KS_braceleft,
258     KC(57),         KS_6,               KS_ampersand,
259     KC(58),         KS_5,               KS_percent,
260     KC(59),         KS_4,               KS_currency,        KS_dollar,
261     KC(60),         KS_3,               KS_numbersign,      KS_sterling,
262     KC(61),         KS_2,               KS_quotedbl,        KS_at,
263     KC(62),         KS_1,               KS_exclam,
264     KC(63),         KS_section,         KS_onehalf,
265     KC(88),         KS_8,               KS_parenleft,       KS_bracketleft,
266     KC(89),         KS_9,               KS_parenright,      KS_bracketright,
267     KC(90),         KS_0,               KS_equal, KS_braceright,
268     KC(91),         KS_minus, KS_question,        KS_backslash,
269     KC(92),         KS_dead_acute,      KS_dead_grave,
270     KC(96),         KS_i,
271     KC(97),         KS_o,
272     KC(98),         KS_p,
273     KC(99),         KS_aring,
274     KC(100),        KS_dead_diaeresis,KS_dead_circumflex,KS_dead_tilde,
275     KC(104),        KS_j,
276     KC(105),        KS_k,
277     KC(106),        KS_l,
278     KC(107),        KS_odiaeresis,
279     KC(108),        KS_adiaeresis,
280     KC(112),        KS_m,
281     KC(113),        KS_comma, KS_semicolon,
282     KC(114),        KS_period,          KS_colon,
283     KC(115),        KS_minus, KS_underscore,
284     KC(116),        KS_apostrophe,      KS_asterisk,
285     KC(118),        KS_less,  KS_greater,         KS_bar,
286     KC(120),        KS_n
287 };
288 
289 static const keysym_t hilkbd_keydesc_sv_ps2_nodead[] = {
290     KC(92),         KS_apostrophe,      KS_grave,
291     KC(100),        KS_diaeresis,       KS_asciicircum,     KS_asciitilde,
292 };
293 
294 /*
295  * 0f. German
296  */
297 
298 static const keysym_t hilkbd_keydesc_de[] = {
299     KC(28),         KS_y,               KS_Y,               KS_paragraph,
300     KC(49),         KS_z,               KS_Z,               KS_dead_circumflex,
301     KC(56),         KS_7,               KS_slash, KS_backslash,
302     KC(57),         KS_6,               KS_ampersand,       KS_asciicircum,
303     KC(60),         KS_3,               KS_section,         KS_numbersign,
304     KC(61),         KS_2,               KS_quotedbl,        KS_at,
305     KC(63),         KS_less,  KS_greater,
306                     KS_guillemotleft,KS_guillemotright,
307     KC(88),         KS_8,               KS_parenleft,
308                     KS_bracketleft,     KS_braceleft,
309     KC(89),         KS_9,               KS_parenright,
310                     KS_bracketright,KS_braceright,
311     KC(90),         KS_0,               KS_equal, KS_exclamdown,
312     KC(91),         KS_ssharp,          KS_question,        KS_macron,
313     KC(92),         KS_dead_acute,      KS_dead_grave,      KS_plusminus,
314     KC(99),         KS_udiaeresis,      KS_Udiaeresis,      KS_dead_abovering,
315     KC(100),        KS_plus,  KS_asterisk,        KS_bar,             KS_brokenbar,
316     KC(101),        KS_sterling,        KS_dead_circumflex,KS_mu,
317     KC(107),        KS_odiaeresis,
318     KC(108),        KS_adiaeresis,      KS_Adiaeresis,      KS_grave, KS_apostrophe,
319     KC(113),        KS_comma, KS_semicolon,       KS_less,
320     KC(114),        KS_period,          KS_colon, KS_greater,
321     KC(115),        KS_minus, KS_underscore,      KS_underscore
322 };
323 
324 static const keysym_t hilkbd_keydesc_de_nodead[] = {
325     KC(48),         KS_u,               KS_U,               KS_diaeresis,
326     KC(49),         KS_z,               KS_Z,               KS_asciicircum,
327     KC(50),         KS_t,               KS_T,               KS_grave,
328     KC(51),         KS_r,               KS_R,               KS_apostrophe,
329     KC(92),         KS_apostrophe,      KS_grave, KS_plusminus,
330     KC(99),         KS_udiaeresis,      KS_Udiaeresis,      KS_degree,
331     KC(101),        KS_sterling,        KS_asciicircum,     KS_mu,
332     KC(96),         KS_i,               KS_I,               KS_asciitilde
333 };
334 
335 static const keysym_t hilkbd_keydesc_de_ps2[] = {
336     KC(24),         KS_b,
337     KC(25),         KS_v,
338     KC(26),         KS_c,
339     KC(27),         KS_x,
340     KC(28),         KS_y,
341     KC(36),         KS_KP_Separator,KS_KP_Delete,
342     KC(40),         KS_h,
343     KC(41),         KS_g,
344     KC(42),         KS_f,
345     KC(43),         KS_d,
346     KC(44),         KS_s,
347     KC(45),         KS_a,
348     KC(48),         KS_u,
349     KC(49),         KS_z,               KS_Z,               KS_dead_circumflex,
350     KC(50),         KS_t,
351     KC(51),         KS_r,
352     KC(52),         KS_e,
353     KC(53),         KS_w,
354     KC(54),         KS_q,               KS_Q,               KS_at,
355     KC(56),         KS_7,               KS_slash, KS_braceleft,
356     KC(57),         KS_6,               KS_ampersand,
357     KC(58),         KS_5,               KS_percent,
358     KC(59),         KS_4,               KS_dollar,
359     KC(60),         KS_3,               KS_section,         KS_threesuperior,
360     KC(61),         KS_2,               KS_quotedbl,        KS_twosuperior,
361     KC(62),         KS_1,               KS_exclam,
362     KC(63),         KS_dead_circumflex, KS_dead_abovering,
363     KC(88),         KS_8,               KS_parenleft,       KS_bracketleft,
364     KC(89),         KS_9,               KS_parenright,      KS_bracketright,
365     KC(90),         KS_0,               KS_equal, KS_braceright,
366     KC(91),         KS_ssharp,          KS_question,        KS_backslash,
367     KC(92),         KS_dead_acute,      KS_dead_grave,
368     KC(96),         KS_i,
369     KC(97),         KS_o,
370     KC(98),         KS_p,
371     KC(99),         KS_udiaeresis,
372     KC(100),        KS_plus,  KS_asterisk,        KS_dead_tilde,
373     KC(104),        KS_j,
374     KC(105),        KS_k,
375     KC(106),        KS_l,
376     KC(107),        KS_odiaeresis,
377     KC(108),        KS_adiaeresis,
378     KC(112),        KS_m,               KS_M,               KS_mu,
379     KC(113),        KS_comma, KS_semicolon,
380     KC(114),        KS_period,          KS_colon,
381     KC(115),        KS_minus, KS_underscore,
382     KC(116),        KS_numbersign,      KS_apostrophe,
383     KC(118),        KS_less,  KS_greater,         KS_bar,
384     KC(120),        KS_n
385 };
386 
387 static const keysym_t hilkbd_keydesc_de_ps2_nodead[] = {
388     KC(49),         KS_z,               KS_Z,               KS_asciicircum,
389     KC(63),         KS_asciicircum,     KS_degree,
390     KC(92),         KS_apostrophe,      KS_grave,
391     KC(100),        KS_plus,  KS_asterisk,        KS_asciitilde
392 };
393 
394 /*
395  * 17. English
396  */
397 
398 static const keysym_t hilkbd_keydesc_uk[] = {
399     KC(56),         KS_7,               KS_asciicircum,     KS_backslash,
400     KC(57),         KS_6,               KS_ampersand,       KS_asciicircum,
401     KC(60),         KS_3,               KS_sterling,        KS_numbersign,
402     KC(61),         KS_2,               KS_quotedbl,        KS_at,
403     KC(88),         KS_8,               KS_parenleft,       KS_bracketleft,     KS_braceleft,
404     KC(89),         KS_9,               KS_parenright,      KS_bracketright,KS_braceright,
405     KC(90),         KS_0,               KS_equal, KS_questiondown,
406     KC(91),         KS_plus,  KS_question,        KS_macron,
407     KC(92),         KS_apostrophe,      KS_slash, KS_plusminus,
408     KC(101),        KS_less,  KS_greater,         KS_mu,
409     KC(107),        KS_asterisk,        KS_at,
410     KC(108),        KS_backslash,       KS_bar,             KS_grave, KS_apostrophe,
411     KC(113),        KS_comma, KS_semicolon,       KS_less,
412     KC(114),        KS_period,          KS_colon, KS_greater,
413     KC(115),        KS_minus, KS_underscore,      KS_underscore
414 };
415 
416 static const keysym_t hilkbd_keydesc_uk_ps2[] = {
417     KC(24),         KS_b,
418     KC(25),         KS_v,
419     KC(26),         KS_c,
420     KC(27),         KS_x,
421     KC(28),         KS_z,
422     KC(40),         KS_h,
423     KC(41),         KS_g,
424     KC(42),         KS_f,
425     KC(43),         KS_d,
426     KC(44),         KS_s,
427     KC(45),         KS_a,
428     KC(48),         KS_u,
429     KC(49),         KS_y,
430     KC(50),         KS_t,
431     KC(51),         KS_r,
432     KC(52),         KS_e,
433     KC(53),         KS_w,
434     KC(54),         KS_q,
435     KC(56),         KS_7,               KS_ampersand,
436     KC(57),         KS_6,               KS_asciicircum,
437     KC(58),         KS_5,               KS_percent,
438     KC(59),         KS_4,               KS_dollar,
439     KC(60),         KS_3,               KS_sterling,
440     KC(61),         KS_2,               KS_quotedbl,
441     KC(62),         KS_1,               KS_exclam,
442     KC(63),         KS_grave, KS_notsign,         KS_bar,
443     KC(88),         KS_8,               KS_asterisk,
444     KC(89),         KS_9,               KS_parenleft,
445     KC(90),         KS_0,               KS_parenright,
446     KC(91),         KS_minus, KS_underscore,
447     KC(92),         KS_equal, KS_plus,
448     KC(96),         KS_i,
449     KC(97),         KS_o,
450     KC(98),         KS_p,
451     KC(99),         KS_bracketleft,     KS_braceleft,
452     KC(100),        KS_bracketright,KS_braceright,
453     KC(104),        KS_j,
454     KC(105),        KS_k,
455     KC(106),        KS_l,
456     KC(107),        KS_semicolon,       KS_colon,
457     KC(108),        KS_apostrophe,      KS_at,
458     KC(112),        KS_m,
459     KC(113),        KS_comma, KS_less,
460     KC(114),        KS_period,          KS_greater,
461     KC(115),        KS_slash, KS_question,
462     KC(116),        KS_numbersign,      KS_asciitilde,
463     KC(118),        KS_backslash,       KS_brokenbar,
464     KC(120),        KS_n
465 };
466 
467 /*
468  * 1b. French
469  */
470 
471 static const keysym_t hilkbd_keydesc_fr[] = {
472     KC(28),         KS_w,               KS_W,               KS_paragraph,
473     KC(45),         KS_q,               KS_Q,               KS_aring,
474     KC(53),         KS_z,               KS_Z,               KS_asciitilde,
475     KC(54),         KS_a,               KS_A,               KS_periodcentered,
476     KC(56),         KS_egrave,          KS_7,               KS_backslash,
477     KC(57),         KS_section,         KS_6,               KS_asciicircum,
478     KC(58),         KS_parenleft,       KS_5,               KS_onehalf,
479     KC(59),         KS_apostrophe,      KS_4,               KS_onequarter,      KS_threequarters,
480     KC(60),         KS_quotedbl,        KS_3,               KS_numbersign,
481     KC(61),         KS_eacute,          KS_2,               KS_at,
482     KC(62),         KS_ampersand,       KS_1,               KS_exclamdown,
483     KC(63),         KS_dollar,          KS_sterling,
484                     KS_guillemotleft,KS_guillemotright,
485     KC(88),         KS_exclam,          KS_8,               KS_bracketleft,     KS_braceleft,
486     KC(89),         KS_ccedilla,        KS_9,               KS_bracketright,KS_braceright,
487     KC(90),         KS_agrave,          KS_0,               KS_questiondown,
488     KC(91),         KS_parenright,      KS_degree,          KS_macron,
489     KC(92),         KS_minus, KS_underscore,      KS_plusminus,
490     KC(99),         KS_dead_circumflex, KS_dead_diaeresis,  KS_dead_abovering,
491     KC(100),        KS_grave, KS_asterisk,        KS_bar,             KS_brokenbar,
492     KC(101),        KS_less,  KS_greater,         KS_mu,
493     KC(107),        KS_m,
494     KC(108),        KS_ugrave,          KS_percent,         KS_grave, KS_apostrophe,
495     KC(112),        KS_comma, KS_question,        KS_masculine,
496     KC(113),        KS_semicolon,       KS_period,          KS_less,
497     KC(114),        KS_colon, KS_slash, KS_greater,
498     KC(115),        KS_equal, KS_plus,  KS_underscore
499 };
500 
501 static const keysym_t hilkbd_keydesc_fr_ps2[] = {
502     KC(24),         KS_b,
503     KC(25),         KS_v,
504     KC(26),         KS_c,
505     KC(27),         KS_x,
506     KC(28),         KS_w,
507     KC(40),         KS_h,
508     KC(41),         KS_g,
509     KC(42),         KS_f,
510     KC(43),         KS_d,
511     KC(44),         KS_s,
512     KC(45),         KS_q,
513     KC(48),         KS_u,
514     KC(49),         KS_y,
515     KC(50),         KS_t,
516     KC(51),         KS_r,
517     KC(52),         KS_e,
518     KC(53),         KS_z,
519     KC(54),         KS_a,
520     KC(56),         KS_egrave,          KS_7,               KS_grave,
521     KC(57),         KS_minus, KS_6,               KS_bar,
522     KC(58),         KS_parenleft,       KS_5,               KS_bracketleft,
523     KC(59),         KS_apostrophe,      KS_4,               KS_braceleft,
524     KC(60),         KS_quotedbl,        KS_3,               KS_numbersign,
525     KC(61),         KS_eacute,          KS_2,               KS_asciitilde,
526     KC(62),         KS_ampersand,       KS_1,
527     KC(63),         KS_twosuperior,
528     KC(88),         KS_underscore,      KS_8,               KS_backslash,
529     KC(89),         KS_ccedilla,        KS_9,               KS_asciicircum,
530     KC(90),         KS_agrave,          KS_0,               KS_at,
531     KC(91),         KS_parenright,      KS_degree,          KS_bracketright,
532     KC(92),         KS_equal, KS_plus,  KS_braceright,
533     KC(96),         KS_i,
534     KC(97),         KS_o,
535     KC(98),         KS_p,
536     KC(99),         KS_dead_circumflex,KS_dead_diaeresis,
537     KC(100),        KS_dollar,          KS_sterling,        KS_currency,
538     KC(104),        KS_j,
539     KC(105),        KS_k,
540     KC(106),        KS_l,
541     KC(107),        KS_m,
542     KC(108),        KS_ugrave,          KS_percent,
543     KC(112),        KS_comma, KS_question,
544     KC(113),        KS_semicolon,       KS_period,
545     KC(114),        KS_colon, KS_slash,
546     KC(115),        KS_exclam,          KS_section,
547     KC(116),        KS_asterisk,        KS_mu,
548     KC(118),        KS_less,  KS_greater,
549                     KS_guillemotleft,KS_guillemotright,
550     KC(120),        KS_n
551 };
552 
553 #define KBD_MAP(name, base, map) \
554                               { name, base, sizeof(map)/sizeof(keysym_t), map }
555 
556 const struct wscons_keydesc hilkbd_keydesctab[] = {
557           KBD_MAP(KB_US,                          0,        hilkbd_keydesc_us),
558           KBD_MAP(KB_DE,                          KB_US,    hilkbd_keydesc_de),
559           KBD_MAP(KB_DE | KB_NODEAD,    KB_DE,    hilkbd_keydesc_de_nodead),
560           KBD_MAP(KB_FR,                          KB_US,    hilkbd_keydesc_fr),
561           KBD_MAP(KB_UK,                          KB_US,    hilkbd_keydesc_uk),
562           KBD_MAP(KB_SV,                          KB_US,    hilkbd_keydesc_sv),
563           KBD_MAP(KB_SV | KB_NODEAD,    KB_SV,    hilkbd_keydesc_sv_nodead),
564           {0, 0, 0, 0},
565 };
566 
567 const struct wscons_keydesc hilkbd_keydesctab_ps2[] = {
568           KBD_MAP(KB_US,                          0,        hilkbd_keydesc_us),
569           KBD_MAP(KB_DE,                          KB_US,    hilkbd_keydesc_de_ps2),
570           KBD_MAP(KB_DE | KB_NODEAD,    KB_DE,    hilkbd_keydesc_de_ps2_nodead),
571           KBD_MAP(KB_FR,                          KB_US,    hilkbd_keydesc_fr_ps2),
572           KBD_MAP(KB_UK,                          KB_US,    hilkbd_keydesc_uk_ps2),
573           KBD_MAP(KB_SV,                          KB_US,    hilkbd_keydesc_sv_ps2),
574           KBD_MAP(KB_SV | KB_NODEAD,    KB_SV,    hilkbd_keydesc_sv_ps2_nodead),
575           {0, 0, 0, 0},
576 };
577 
578 /*
579  * Keyboard ID to layout table
580  */
581 const kbd_t hilkbd_layouts[MAXHILKBDLAYOUT] = {
582           -1,       /* 00 Undefined or custom layout */
583           -1,       /* 01 Undefined */
584           -1,       /* 02 Japanese */
585           -1,       /* 03 Swiss French */
586           -1,       /* 04 Portuguese */
587           -1,       /* 05 Arabic */
588           -1,       /* 06 Hebrew */
589           -1,       /* 07 Canadian English */
590           -1,       /* 08 Turkish */
591           -1,       /* 09 Greek */
592           -1,       /* 0a Thai */
593           -1,       /* 0b Italian */
594           -1,       /* 0c Korean */
595           -1,       /* 0d Dutch */
596           KB_SV,    /* 0e Swedish */
597           KB_DE,    /* 0f German */
598           -1,       /* 10 Simplified Chinese */
599           -1,       /* 11 Traditional Chinese */
600           -1,       /* 12 Swiss French 2 */
601           -1,       /* 13 Euro Spanish */
602           -1,       /* 14 Swiss German 2 */
603           -1,       /* 15 Belgian */
604           -1,       /* 16 Finnish */
605           KB_UK,    /* 17 UK English */
606           -1,       /* 18 Canadian French */
607           -1,       /* 19 Swiss German */
608           -1,       /* 1a Norwegian */
609           KB_FR,    /* 1b French */
610           -1,       /* 1c Danish */
611           -1,       /* 1d Katakana */
612           -1,       /* 1e Latin Spanish */
613           KB_US,    /* 1f US ASCII */
614 };
615