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