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