Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / uts / common / io / kb8042 / kb8042_keytables.c
blobe1ae15dd27a7b4f622ed3b24bd948b4204b5be7c
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * This module contains the translation tables for PS/2 style keyboards.
31 #define KEYMAP_SIZE_VARIABLE
33 #include <sys/param.h>
34 #include <sys/kbd.h>
36 /* handy way to define control characters in the tables */
37 #define c(ch) (ch&0x1F)
38 #define ESC 0x1B
39 #define DEL 0x7F
41 #define KEYMAP_SIZE_PC 160
43 /* ***************************** */
44 /* PC-101 keyboard definitions */
45 /* ***************************** */
46 /* Unshifted keyboard table for PC keyboard */
48 /* BEGIN CSTYLED */
49 static keymap_entry_t keytab_pc_lc[KEYMAP_SIZE_PC] = {
50 /* 0 */ HOLE, '`', '1', '2', '3', '4', '5', '6',
51 /* 8 */ '7', '8', '9', '0', '-', '=', HOLE, '\b',
52 /* 16 */ '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u',
53 /* 24 */ 'i', 'o', 'p', '[', ']', '\\',
54 SHIFTKEYS+CAPSLOCK,
55 'a',
56 /* 32 */ 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
57 /* 40 */ ';', '\'', '\\', '\r',
58 SHIFTKEYS+LEFTSHIFT,
59 HOLE, 'z', 'x',
60 /* 48 */ 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
61 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
62 SHIFTKEYS+LEFTCTRL,
63 HOLE, SHIFTKEYS+LEFTALT,
64 ' ', SHIFTKEYS+
65 RIGHTALT,
66 HOLE,
67 /* 64 */ SHIFTKEYS+RIGHTCTRL,
68 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
69 /* 72 */ HOLE, HOLE, HOLE, BF(8), DEL,
70 NOP, HOLE,
71 STRING+LEFTARROW,
72 /* 80 */ RF(7), RF(13), HOLE,
73 STRING+UPARROW,
74 STRING+DOWNARROW,
75 RF(9), RF(15), HOLE,
76 /* 88 */ HOLE,
77 STRING+RIGHTARROW,
78 SHIFTKEYS+NUMLOCK,
79 RF(7), STRING+LEFTARROW,
80 RF(13), HOLE,
81 PADSLASH,
82 /* 96 */ STRING+UPARROW,
83 RF(11), STRING+DOWNARROW,
84 BF(8), PADSTAR,
85 RF(9),
86 STRING+RIGHTARROW,
87 RF(15),
88 /*104 */ DEL, PADMINUS,
89 PADPLUS,
90 HOLE, PADENTER,
91 HOLE, ESC, HOLE,
92 /*112 */ TF(1), TF(2), TF(3), TF(4), TF(5), TF(6), TF(7), TF(8),
93 /*120 */ TF(9), TF(10), TF(11), TF(12), NOP, NOP, NOP, HOLE,
94 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
95 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
96 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
97 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
98 /*160 */
101 /* Shifted keyboard table for PC keyboard */
103 static keymap_entry_t keytab_pc_uc[KEYMAP_SIZE_PC] = {
104 /* 0 */ HOLE, '~', '!', '@', '#', '$', '%', '^',
105 /* 8 */ '&', '*', '(', ')', '_', '+', HOLE, '\b',
106 /* 16 */ '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
107 /* 24 */ 'I', 'O', 'P', '{', '}', '|',
108 SHIFTKEYS+CAPSLOCK,
109 'A',
110 /* 32 */ 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L',
111 /* 40 */ ':', '"', '|', '\r',
112 SHIFTKEYS+LEFTSHIFT,
113 HOLE, 'Z', 'X',
114 /* 48 */ 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
115 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
116 SHIFTKEYS+LEFTCTRL,
117 HOLE,
118 SHIFTKEYS+LEFTALT,
119 ' ', SHIFTKEYS+
120 RIGHTALT,
121 HOLE,
122 /* 64 */ SHIFTKEYS+RIGHTCTRL,
123 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
124 /* 72 */ HOLE, HOLE, HOLE, BF(8), DEL, NOP, HOLE,
125 STRING+LEFTARROW,
126 /* 80 */ RF(7), RF(13), HOLE, STRING+UPARROW,
127 STRING+DOWNARROW,
128 RF(9), RF(15), HOLE,
129 /* 88 */ HOLE,
130 STRING+RIGHTARROW,
131 SHIFTKEYS+NUMLOCK,
132 '7', '4', '1', HOLE, '/',
133 /* 96 */ '8', '5', '2', '0', '*', '9', '6', '3',
134 /*104 */ '.', '-', '+', HOLE, '\n', HOLE, ESC, HOLE,
135 /*112 */ TF(1), TF(2), TF(3), TF(4), TF(5), TF(6), TF(7), TF(8),
136 /*120 */ TF(9), TF(10), TF(11), TF(12), NOP, NOP, NOP, HOLE,
137 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
138 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
139 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
140 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
141 /*160 */
144 /* Caps Locked keyboard table for PC keyboard */
146 static keymap_entry_t keytab_pc_cl[KEYMAP_SIZE_PC] = {
147 /* 0 */ HOLE, '`', '1', '2', '3', '4', '5', '6',
148 /* 8 */ '7', '8', '9', '0', '-', '=', HOLE, '\b',
149 /* 16 */ '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
150 /* 24 */ 'I', 'O', 'P', '[', ']', '\\',
151 SHIFTKEYS+CAPSLOCK,
152 'A',
153 /* 32 */ 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L',
154 /* 40 */ ';', '\'', '\\', '\r',
155 SHIFTKEYS+LEFTSHIFT,
156 HOLE, 'Z', 'X',
157 /* 48 */ 'C', 'V', 'B', 'N', 'M', ',', '.', '/',
158 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
159 SHIFTKEYS+LEFTCTRL,
160 HOLE,
161 SHIFTKEYS+LEFTALT,
162 ' ', SHIFTKEYS+
163 RIGHTALT,
164 HOLE,
165 /* 64 */ SHIFTKEYS+RIGHTCTRL,
166 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
167 /* 72 */ HOLE, HOLE, HOLE, BF(8), DEL, NOP, HOLE,
168 STRING+LEFTARROW,
169 /* 80 */ RF(7),
170 RF(13), HOLE,
171 STRING+UPARROW,
172 STRING+DOWNARROW,
173 RF(9), RF(15), HOLE,
174 /* 88 */ HOLE,
175 STRING+RIGHTARROW,
176 SHIFTKEYS+NUMLOCK,
177 RF(7), STRING+LEFTARROW,
178 RF(13), HOLE, PADSLASH,
179 /* 96 */ STRING+UPARROW,
180 RF(11), STRING+DOWNARROW,
181 BF(8), PADSTAR,
182 RF(9),
183 STRING+RIGHTARROW,
184 RF(15),
185 /*104 */ DEL, PADMINUS,
186 PADPLUS,
187 HOLE, PADENTER,
188 HOLE, ESC, HOLE,
189 /*112 */ TF(1), TF(2), TF(3), TF(4), TF(5), TF(6), TF(7), TF(8),
190 /*120 */ TF(9), TF(10), TF(11), TF(12), NOP, NOP, NOP, HOLE,
191 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
192 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
193 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
194 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
195 /*160 */
198 /* Alt Graph keyboard table for PC keyboard */
200 static keymap_entry_t keytab_pc_ag[KEYMAP_SIZE_PC] = {
201 /* 0 */ HOLE, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
202 /* 8 */ NOP, NOP, NOP, NOP, NOP, NOP, HOLE, NOP,
203 /* 16 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
204 /* 24 */ NOP, NOP, NOP, NOP, NOP, NOP,
205 SHIFTKEYS+CAPSLOCK,
206 NOP,
207 /* 32 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
208 /* 40 */ NOP, NOP, NOP, NOP,
209 SHIFTKEYS+LEFTSHIFT,
210 HOLE, NOP, NOP,
211 /* 48 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
212 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
213 SHIFTKEYS+LEFTCTRL,
214 HOLE,
215 SHIFTKEYS+LEFTALT,
216 ' ', SHIFTKEYS+
217 RIGHTALT,
218 HOLE,
219 /* 64 */ SHIFTKEYS+RIGHTCTRL,
220 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
221 /* 72 */ HOLE, HOLE, HOLE, BF(8), DEL, NOP, HOLE,
222 STRING+
223 LEFTARROW,
224 /* 80 */ RF(7), RF(13), HOLE, STRING+
225 UPARROW,STRING+
226 DOWNARROW,RF(9), RF(15), HOLE,
227 /* 88 */ HOLE, STRING+
228 RIGHTARROW,
229 SHIFTKEYS+NUMLOCK,
230 NOP, NOP, NOP, HOLE, NOP,
231 /* 96 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
232 /*104 */ NOP, NOP, NOP, HOLE, NOP, HOLE, ESC, HOLE,
233 /*112 */ TF(1), TF(2), TF(3), TF(4), TF(5), TF(6), TF(7), TF(8),
234 /*120 */ TF(9), TF(10), TF(11), TF(12), NOP, NOP, NOP, HOLE,
235 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
236 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
237 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
238 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
239 /*160 */
242 /* Num Locked keyboard table for PC keyboard */
244 static keymap_entry_t keytab_pc_nl[KEYMAP_SIZE_PC] = {
245 /* 0 */ HOLE, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
246 /* 8 */ NONL, NONL, NONL, NONL, NONL, NONL, HOLE, NONL,
247 /* 16 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
248 /* 24 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
249 /* 32 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
250 /* 40 */ NONL, NONL, NONL, NONL, NONL, HOLE, NONL, NONL,
251 /* 48 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
252 /* 56 */ NONL, NONL, NONL, HOLE, NONL, NONL, NONL, HOLE,
253 /* 64 */ NONL, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
254 /* 72 */ HOLE, HOLE, HOLE, NONL, NONL, NONL, HOLE, NONL,
255 /* 80 */ NONL, NONL, HOLE, NONL, NONL, NONL, NONL, HOLE,
256 /* 88 */ HOLE, NONL, NONL, PAD7, PAD4, PAD1, HOLE, NONL,
257 /* 96 */ PAD8, PAD5, PAD2, PAD0, NONL, PAD9, PAD6, PAD3,
258 /*104 */ PADDOT, NONL, NONL, HOLE, NONL, HOLE, NONL, HOLE,
259 /*112 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, NONL,
260 /*120 */ NONL, NONL, NONL, NONL, NONL, NONL, NONL, HOLE,
261 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
262 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
263 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
264 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
265 /*160 */
268 /* Controlled keyboard table for PC keyboard */
270 static keymap_entry_t keytab_pc_ct[KEYMAP_SIZE_PC] = {
271 /* 0 */ HOLE, c('^'), '1', c('@'), '3', '4', '5', c('^'),
272 /* 8 */ '7', '8', '9', '0', c('_'), '=', HOLE, '\b',
273 /* 16 */ '\t', c('q'), c('w'), c('e'), c('r'), c('t'), c('y'), c('u'),
274 /* 24 */ c('i'), c('o'), c('p'), c('['), c(']'), c('\\'),
275 SHIFTKEYS+CAPSLOCK,
276 c('a'),
277 /* 32 */ c('s'), c('d'), c('f'), c('g'), c('h'), c('j'), c('k'), c('l'),
278 /* 40 */ ';', '\'', '\\', '\r',
279 SHIFTKEYS+LEFTSHIFT,
280 HOLE, c('z'), c('x'),
281 /* 48 */ c('c'), c('v'), c('b'), c('n'), c('m'), ',', '.', c('_'),
282 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
283 SHIFTKEYS+LEFTCTRL,
284 HOLE,
285 SHIFTKEYS+LEFTALT,
286 ' ', SHIFTKEYS+
287 RIGHTALT,
288 HOLE,
289 /* 64 */ SHIFTKEYS+RIGHTCTRL,
290 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
291 /* 72 */ HOLE, HOLE, HOLE, BF(8), DEL, NOP, HOLE,
292 STRING+LEFTARROW,
293 /* 80 */ RF(7), RF(13), HOLE,
294 STRING+UPARROW,
295 STRING+DOWNARROW,
296 RF(9), RF(15), HOLE,
297 /* 88 */ HOLE,
298 STRING+RIGHTARROW,
299 SHIFTKEYS+NUMLOCK,
300 PAD7, PAD4, PAD1, HOLE,
301 PADSLASH,
302 /* 96 */ PAD8, PAD5, PAD2, PAD0, PADSTAR,
303 PAD9, PAD6, PAD3,
304 /*104 */ PADDOT, PADMINUS,
305 PADPLUS,
306 HOLE, PADENTER,
307 HOLE, ESC, HOLE,
308 /*112 */ TF(1), TF(2), TF(3), TF(4), TF(5), TF(6), TF(7), TF(8),
309 /*120 */ TF(9), TF(10), TF(11), TF(12), NOP, NOP, NOP, HOLE,
310 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
311 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
312 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
313 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
314 /*160 */
317 /* "Key Up" keyboard table for PC keyboard */
320 static keymap_entry_t keytab_pc_up[KEYMAP_SIZE_PC] = {
321 /* 0 */ HOLE, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
322 /* 8 */ NOP, NOP, NOP, NOP, NOP, NOP, HOLE, NOP,
323 /* 16 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
324 /* 24 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
325 /* 32 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
326 /* 40 */ NOP, NOP, NOP, NOP,
327 SHIFTKEYS+LEFTSHIFT,
328 HOLE, NOP, NOP,
329 /* 48 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
330 /* 56 */ NOP, SHIFTKEYS+RIGHTSHIFT,
331 SHIFTKEYS+LEFTCTRL,
332 HOLE, SHIFTKEYS+LEFTALT,
333 NOP, SHIFTKEYS+
334 RIGHTALT,
335 HOLE,
336 /* 64 */ SHIFTKEYS+RIGHTCTRL,
337 HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
338 /* 72 */ HOLE, HOLE, HOLE, NOP, NOP, NOP, HOLE, NOP,
339 /* 80 */ NOP, NOP, HOLE, NOP, NOP, NOP, NOP, HOLE,
340 /* 88 */ HOLE, NOP, NOP, NOP, NOP, NOP, HOLE, NOP,
341 /* 96 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
342 /*104 */ NOP, NOP, NOP, HOLE, NOP, HOLE, NOP, HOLE,
343 /*112 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP,
344 /*120 */ NOP, NOP, NOP, NOP, NOP, NOP, NOP, HOLE,
345 /*128 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
346 /*136 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
347 /*144 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
348 /*152 */ HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE, HOLE,
349 /*160 */
352 /* END CSTYLED */
354 #define M(x) (1 << (x))
355 #define MASK_ALL (M(LEFTSHIFT) | \
356 M(RIGHTSHIFT) | \
357 CTRLMASK | \
358 ALTMASK | \
359 ALTGRAPHMASK)
362 * Make Ctrl+Shift+F1 be Compose. This is SOOOO hokey.
364 static struct exception_map exceptions_pc[] = {
365 { MASK_ALL, M(LEFTSHIFT)|M(LEFTCTRL), 112, COMPOSE, },
366 { MASK_ALL, M(LEFTSHIFT)|M(RIGHTCTRL), 112, COMPOSE, },
367 { MASK_ALL, M(RIGHTSHIFT)|M(LEFTCTRL), 112, COMPOSE, },
368 { MASK_ALL, M(RIGHTSHIFT)|M(RIGHTCTRL), 112, COMPOSE, },
369 { 0, },
372 /* Index to keymaps for PC keyboard */
373 struct keyboard keyindex_pc = {
374 KEYMAP_SIZE_PC,
375 keytab_pc_lc,
376 keytab_pc_uc,
377 keytab_pc_cl,
378 keytab_pc_ag,
379 keytab_pc_nl,
380 keytab_pc_ct,
381 keytab_pc_up,
382 0x0000, /* Shift bits which stay on with idle keyboard */
383 0x0000, /* Bucky bits which stay on with idle keyboard */
384 112, 0, 31, /* abort keys: F1+A */
385 CAPSMASK|NUMLOCKMASK, /* Shift bits which toggle on down event */
386 exceptions_pc, /* Exceptions */
387 44, 57, 126, /* new abort keys: Shift+Pause */