omkbdmap.c revision 1.3 1 /* $NetBSD: omkbdmap.c,v 1.3 2023/01/15 05:08:33 tsutsui Exp $ */
2 /* $OpenBSD: omkbdmap.c,v 1.2 2013/11/16 18:31:44 miod Exp $ */
3
4 /* Partially from:
5 * NetBSD: lunaws.c,v 1.6 2002/03/17 19:40:42 atatat Exp
6 *
7 * Copyright (c) 2000 The NetBSD Foundation, Inc.
8 * All rights reserved.
9 *
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Tohru Nishimura.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "opt_wsdisplay_compat.h"
36
37 #include <sys/types.h>
38
39 #include <dev/wscons/wsksymdef.h>
40 #include <dev/wscons/wsksymvar.h>
41
42 #include <luna68k/dev/omkbdmap.h>
43
44 #ifdef WSDISPLAY_COMPAT_RAWKBD
45
46 /*
47 * Translate LUNA keycodes to US keyboard XT scancodes, for proper
48 * X11-over-wsmux operation.
49 *
50 * XXX: Needs re-think how we should treat RAWKBD code on NetBSD.
51 */
52 const uint8_t omkbd_raw[0x80] = {
53 0x00, /* 0x00 */
54 0x00, /* 0x01 */
55 0x00, /* 0x02 */
56 0x00, /* 0x03 */
57 0x00, /* 0x04 */
58 0x00, /* 0x05 */
59 0x00, /* 0x06 */
60 0x00, /* 0x07 */
61 0x00, /* 0x08 */
62 0x0f, /* 0x09 */
63 0x1d, /* 0x0a */
64 0x70, /* 0x0b: Kana / No RAWKEY_XXX symbol */
65 0x36, /* 0x0c */
66 0x2a, /* 0x0d */
67 0x3a, /* 0x0e */
68 0x38, /* 0x0f: Zenmen */
69 0x01, /* 0x10 */
70 0x0e, /* 0x11 */
71 0x1c, /* 0x12 */
72 0x00, /* 0x13 */
73 0x39, /* 0x14 */
74 0xd3, /* 0x15 */
75 0x38, /* 0x16: Henkan */
76 0xb8, /* 0x17: Kakutei */
77 0x57, /* 0x18: Shokyo */
78 0x58, /* 0x19: Yobidashi */
79 0x00, /* 0x1a: Bunsetsu L / f13 */
80 0x00, /* 0x1b: Bunsetsu R / f14 */
81 0x48, /* 0x1c */
82 0x4b, /* 0x1d */
83 0x4d, /* 0x1e */
84 0x50, /* 0x1f */
85 0x57, /* 0x20 */
86 0x58, /* 0x21 */
87 0x02, /* 0x22: exclam */
88 0x03, /* 0x23: quotedbl */
89 0x04, /* 0x24: numbersign */
90 0x05, /* 0x25: dollar */
91 0x06, /* 0x26: percent */
92 0x07, /* 0x27: ampersand */
93 0x08, /* 0x28: apostrophe */
94 0x09, /* 0x29: parenleft */
95 0x0a, /* 0x2a: parenright */
96 0x0b, /* 0x2b */
97 0x0c, /* 0x2c: equal */
98 0x0d, /* 0x2d: asciitilde */
99 0x7d, /* 0x2e: bar */
100 0x00, /* 0x2f */
101 0x00, /* 0x30: f13 */
102 0x00, /* 0x31: f14 */
103 0x10, /* 0x32 */
104 0x11, /* 0x33 */
105 0x12, /* 0x34 */
106 0x13, /* 0x35 */
107 0x14, /* 0x36 */
108 0x15, /* 0x37 */
109 0x16, /* 0x38 */
110 0x17, /* 0x39 */
111 0x18, /* 0x3a */
112 0x19, /* 0x3b */
113 0x1a, /* 0x3c: grave */
114 0x1b, /* 0x3d: braceleft */
115 0x00, /* 0x3e */
116 0x00, /* 0x3f */
117 0x00, /* 0x40 */
118 0x00, /* 0x41 */
119 0x1e, /* 0x42 */
120 0x1f, /* 0x43 */
121 0x20, /* 0x44 */
122 0x21, /* 0x45 */
123 0x22, /* 0x46 */
124 0x23, /* 0x47 */
125 0x24, /* 0x48 */
126 0x25, /* 0x49 */
127 0x26, /* 0x4a */
128 0x27, /* 0x4b: plus */
129 0x28, /* 0x4c: asterisk */
130 0x2b, /* 0x4d: braceright */
131 0x00, /* 0x4e */
132 0x00, /* 0x4f */
133 0x00, /* 0x50 */
134 0x00, /* 0x51 */
135 0x2c, /* 0x52 */
136 0x2d, /* 0x53 */
137 0x2e, /* 0x54 */
138 0x2f, /* 0x55 */
139 0x30, /* 0x56 */
140 0x31, /* 0x57 */
141 0x32, /* 0x58 */
142 0x33, /* 0x59: less */
143 0x34, /* 0x5a: greater */
144 0x35, /* 0x5b: question */
145 0x73, /* 0x5c: underscore */
146 0x00, /* 0x5d */
147 0x00, /* 0x5e */
148 0x00, /* 0x5f */
149 0x53, /* 0x60 */
150 0x4e, /* 0x61 */
151 0x4a, /* 0x62 */
152 0x47, /* 0x63: KP 7 */
153 0x48, /* 0x64: KP 8 */
154 0x49, /* 0x65: KP 9 */
155 0x4b, /* 0x66: KP 4 */
156 0x4c, /* 0x67: KP 5 */
157 0x4d, /* 0x68: KP 6 */
158 0x4f, /* 0x69: KP 1 */
159 0x50, /* 0x6a: KP 2 */
160 0x51, /* 0x6b: KP 3 */
161 0x52, /* 0x6c: KP 0 */
162 0x53, /* 0x6d: KP Decimal */
163 0x9c, /* 0x6e */
164 0x00, /* 0x6f */
165 0x00, /* 0x70 */
166 0x00, /* 0x71 */
167 0x3b, /* 0x72 */
168 0x3c, /* 0x73 */
169 0x3d, /* 0x74 */
170 0x3e, /* 0x75 */
171 0x3f, /* 0x76 */
172 0x40, /* 0x77 */
173 0x41, /* 0x78 */
174 0x42, /* 0x79 */
175 0x43, /* 0x7a */
176 0x44, /* 0x7b */
177 0x37, /* 0x7c */
178 0xb5, /* 0x7d */
179 0x76, /* 0x7E */
180 0x00, /* 0x7f: KP Separator */
181 };
182 #endif
183
184 #define KC(n) KS_KEYCODE(n)
185
186 static const keysym_t omkbd_keydesc_jp[] = {
187 /* pos command normal shifted */
188 KC(0x09), KS_Tab,
189 KC(0x0a), KS_Cmd1, KS_Control_L,
190 KC(0x0b), KS_Mode_switch, /* Kana */
191 KC(0x0c), KS_Shift_R,
192 KC(0x0d), KS_Shift_L,
193 KC(0x0e), KS_Caps_Lock,
194 KC(0x0f), KS_Cmd2, KS_Meta_L, /* Zenmen */
195 KC(0x10), KS_Cmd_Debugger, KS_Escape,
196 KC(0x11), KS_BackSpace,
197 KC(0x12), KS_Return,
198 KC(0x14), KS_space,
199 KC(0x15), KS_Delete,
200 KC(0x16), KS_Alt_L, /* Henkan */
201 KC(0x17), KS_Alt_R, /* Kakutei */
202 KC(0x18), KS_f11, /* Shokyo */
203 KC(0x19), KS_f12, /* Yobidashi */
204 KC(0x1a), KS_f13, /* Bunsetsu L */
205 KC(0x1b), KS_f14, /* Bunsetsu R */
206 KC(0x1c), KS_KP_Up,
207 KC(0x1d), KS_KP_Left,
208 KC(0x1e), KS_KP_Right,
209 KC(0x1f), KS_KP_Down,
210 /* 0x20, KS_f11, */
211 /* 0x21, KS_f12, */
212 KC(0x22), KS_1, KS_exclam,
213 KC(0x23), KS_2, KS_quotedbl,
214 KC(0x24), KS_3, KS_numbersign,
215 KC(0x25), KS_4, KS_dollar,
216 KC(0x26), KS_5, KS_percent,
217 KC(0x27), KS_6, KS_ampersand,
218 KC(0x28), KS_7, KS_apostrophe,
219 KC(0x29), KS_8, KS_parenleft,
220 KC(0x2a), KS_9, KS_parenright,
221 KC(0x2b), KS_0,
222 KC(0x2c), KS_minus, KS_equal,
223 KC(0x2d), KS_asciicircum, KS_asciitilde,
224 KC(0x2e), KS_backslash, KS_bar,
225
226 /* 0x30, KS_f13, */
227 /* 0x31, KS_f14, */
228 KC(0x32), KS_q,
229 KC(0x33), KS_w,
230 KC(0x34), KS_e,
231 KC(0x35), KS_r,
232 KC(0x36), KS_t,
233 KC(0x37), KS_y,
234 KC(0x38), KS_u,
235 KC(0x39), KS_i,
236 KC(0x3a), KS_o,
237 KC(0x3b), KS_p,
238 KC(0x3c), KS_at, KS_grave,
239 KC(0x3d), KS_bracketleft, KS_braceleft,
240
241 KC(0x42), KS_a,
242 KC(0x43), KS_s,
243 KC(0x44), KS_d,
244 KC(0x45), KS_f,
245 KC(0x46), KS_g,
246 KC(0x47), KS_h,
247 KC(0x48), KS_j,
248 KC(0x49), KS_k,
249 KC(0x4a), KS_l,
250 KC(0x4b), KS_semicolon, KS_plus,
251 KC(0x4c), KS_colon, KS_asterisk,
252 KC(0x4d), KS_bracketright, KS_braceright,
253
254 KC(0x52), KS_z,
255 KC(0x53), KS_x,
256 KC(0x54), KS_c,
257 KC(0x55), KS_v,
258 KC(0x56), KS_b,
259 KC(0x57), KS_n,
260 KC(0x58), KS_m,
261 KC(0x59), KS_comma, KS_less,
262 KC(0x5a), KS_period, KS_greater,
263 KC(0x5b), KS_slash, KS_question,
264 KC(0x5c), KS_underscore,
265
266 KC(0x60), KS_KP_Delete,
267 KC(0x61), KS_KP_Add,
268 KC(0x62), KS_KP_Subtract,
269 KC(0x63), KS_KP_7,
270 KC(0x64), KS_KP_8,
271 KC(0x65), KS_KP_9,
272 KC(0x66), KS_KP_4,
273 KC(0x67), KS_KP_5,
274 KC(0x68), KS_KP_6,
275 KC(0x69), KS_KP_1,
276 KC(0x6a), KS_KP_2,
277 KC(0x6b), KS_KP_3,
278 KC(0x6c), KS_KP_0,
279 KC(0x6d), KS_KP_Decimal,
280 KC(0x6e), KS_KP_Enter,
281
282 KC(0x72), KS_f1,
283 KC(0x73), KS_f2,
284 KC(0x74), KS_f3,
285 KC(0x75), KS_f4,
286 KC(0x76), KS_f5,
287 KC(0x77), KS_f6,
288 KC(0x78), KS_f7,
289 KC(0x79), KS_f8,
290 KC(0x7a), KS_f9,
291 KC(0x7b), KS_f10,
292 KC(0x7c), KS_KP_Multiply,
293 KC(0x7d), KS_KP_Divide,
294 KC(0x7e), KS_KP_Equal,
295 KC(0x7f), KS_KP_Separator,
296 };
297
298 #define SIZE(map) (sizeof(map)/sizeof(keysym_t))
299
300 const struct wscons_keydesc omkbd_keydesctab[] = {
301 { KB_JP, 0, SIZE(omkbd_keydesc_jp), omkbd_keydesc_jp, },
302 { 0, 0, 0, 0 },
303 };
304