1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983-1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_KBD_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_KBD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SunOS4.0 1.18 */ 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Following #defines are related to the older keyboards which 38*7c478bd9Sstevel@tonic-gate * are no longer supported by kb module. The #defines ane left 39*7c478bd9Sstevel@tonic-gate * for older programs to still compile. 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate #define KB_KLUNK 0x00 /* Micro Switch 103SD32-2 */ 42*7c478bd9Sstevel@tonic-gate #define KB_VT100 0x01 /* Keytronics VT100 compatible */ 43*7c478bd9Sstevel@tonic-gate #define KB_SUN2 0x02 /* Sun-2 custom keyboard */ 44*7c478bd9Sstevel@tonic-gate #define KB_VT220 0x81 /* Emulation VT220 */ 45*7c478bd9Sstevel@tonic-gate #define KB_VT220I 0x82 /* International VT220 Emulation */ 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #define NOTPRESENT 0xFF /* Keyboard is not plugged in */ 48*7c478bd9Sstevel@tonic-gate #define KBD_CMD_LED1 0x04 /* Turn on LED 1 for Sun-2 */ 49*7c478bd9Sstevel@tonic-gate #define KBD_CMD_NOLED1 0x05 /* Turn off LED 1 for Sun-2 */ 50*7c478bd9Sstevel@tonic-gate #define KBD_CMD_LED2 0x06 /* Turn on LED 2 for Sun-2 */ 51*7c478bd9Sstevel@tonic-gate #define KBD_CMD_NOLED2 0x07 /* Turn off LED 2 for Sun-2 */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #define CTLSMASK 0x0100 /* Set if ^S was last keyed of ^S, ^Q */ 54*7c478bd9Sstevel@tonic-gate /* determines which NOSCROLL sends. */ 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate #define NOSCROLL 0x303 /* This key alternately sends ^S or ^Q */ 57*7c478bd9Sstevel@tonic-gate #define CTRLS 0x304 /* This sends ^S and lets NOSCROLL know */ 58*7c478bd9Sstevel@tonic-gate #define CTRLQ 0x305 /* This sends ^Q and lets NOSCROLL know */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate /* 62*7c478bd9Sstevel@tonic-gate * Following are the only keyboard types supported by kb module. 63*7c478bd9Sstevel@tonic-gate * (Type 5, Hobo, US101A are also supported but they report 64*7c478bd9Sstevel@tonic-gate * themselves as Type 4 keyboard with a different layout id.) 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate #define KB_SUN3 3 /* Type 3 Sun keyboard */ 67*7c478bd9Sstevel@tonic-gate #define KB_SUN4 4 /* Type 4 Sun keyboard */ 68*7c478bd9Sstevel@tonic-gate #define KB_USB 6 /* USB keyboard */ 69*7c478bd9Sstevel@tonic-gate #define KB_PC 101 /* Type 101 AT keyboard */ 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate #define KB_ASCII 0x0F /* Ascii terminal masquerading as kbd */ 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate /* 74*7c478bd9Sstevel@tonic-gate * This structure is used to enumerate the supported keyboard types. 75*7c478bd9Sstevel@tonic-gate * The array of these is terminated by an entry with a NULL table entry. 76*7c478bd9Sstevel@tonic-gate * The first entry is used if none match. 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate struct keyboards { 79*7c478bd9Sstevel@tonic-gate int id; /* Keyboard type, per KIOCTYPE */ 80*7c478bd9Sstevel@tonic-gate struct keyboard *table; /* Keyboard table to use. */ 81*7c478bd9Sstevel@tonic-gate }; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * Various special characters that might show up on the port 85*7c478bd9Sstevel@tonic-gate */ 86*7c478bd9Sstevel@tonic-gate #define IDLEKEY 0x7F /* Keyboard is idle; no keys down */ 87*7c478bd9Sstevel@tonic-gate #define ERRORKEY 0x7E /* Keyboard detected an error */ 88*7c478bd9Sstevel@tonic-gate #define RESETKEY 0xFF /* Keyboard was just reset */ 89*7c478bd9Sstevel@tonic-gate #define LAYOUTKEY 0xFE /* Keyboard layout byte follows */ 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate #define PRESSED 0x00 /* 0x80 bit off: key was pressed */ 92*7c478bd9Sstevel@tonic-gate #define RELEASED 0x80 /* 0x80 bit on : key was released */ 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * Commands to the Sun-3 keyboard. 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate #define KBD_CMD_RESET 0x01 /* Reset keyboard as if power-up */ 98*7c478bd9Sstevel@tonic-gate #define KBD_CMD_BELL 0x02 /* Turn on the bell */ 99*7c478bd9Sstevel@tonic-gate #define KBD_CMD_NOBELL 0x03 /* Turn off the bell */ 100*7c478bd9Sstevel@tonic-gate #define KBD_CMD_CLICK 0x0A /* Turn on the click annunciator */ 101*7c478bd9Sstevel@tonic-gate #define KBD_CMD_NOCLICK 0x0B /* Turn off the click annunciator */ 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* 104*7c478bd9Sstevel@tonic-gate * Commands to the Type 4 keyboard, in addition to those above. 105*7c478bd9Sstevel@tonic-gate */ 106*7c478bd9Sstevel@tonic-gate #define KBD_CMD_AUTOTEST 0x0C /* Initiate test sequence */ 107*7c478bd9Sstevel@tonic-gate #define KBD_CMD_SETLED 0x0E /* Set keyboard LED's */ 108*7c478bd9Sstevel@tonic-gate #define KBD_CMD_GETLAYOUT 0x0F /* Request that keyboard indicate */ 109*7c478bd9Sstevel@tonic-gate /* layout */ 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * Type 4 keyboard LED masks (used to set LED's) 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate #define LED_NUM_LOCK 0x1 114*7c478bd9Sstevel@tonic-gate #define LED_COMPOSE 0x2 115*7c478bd9Sstevel@tonic-gate #define LED_SCROLL_LOCK 0x4 116*7c478bd9Sstevel@tonic-gate #define LED_CAPS_LOCK 0x8 117*7c478bd9Sstevel@tonic-gate #define LED_KANA 0x10 /* Valid only on Japanese layout */ 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate /* 120*7c478bd9Sstevel@tonic-gate * Software related definitions 121*7c478bd9Sstevel@tonic-gate */ 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * These are the states that the keyboard scanner can be in. 124*7c478bd9Sstevel@tonic-gate * 125*7c478bd9Sstevel@tonic-gate * It starts out in NORMAL state. 126*7c478bd9Sstevel@tonic-gate */ 127*7c478bd9Sstevel@tonic-gate #define NORMAL 0 /* The usual (ho, hum) */ 128*7c478bd9Sstevel@tonic-gate #define ABORT1 1 /* Got KEYABORT1 */ 129*7c478bd9Sstevel@tonic-gate #define COMPOSE1 2 /* Got COMPOSE */ 130*7c478bd9Sstevel@tonic-gate #define COMPOSE2 3 /* Got COMPOSE plus first key */ 131*7c478bd9Sstevel@tonic-gate #define FLTACCENT 4 /* Got floating accent key */ 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate /* 134*7c478bd9Sstevel@tonic-gate * Size of ASCII set as used in compose handling. 135*7c478bd9Sstevel@tonic-gate */ 136*7c478bd9Sstevel@tonic-gate #define ASCII_SET_SIZE 128 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate /* 139*7c478bd9Sstevel@tonic-gate * These are how you can have your input translated. 140*7c478bd9Sstevel@tonic-gate * TR_EVENT means that each keystroke is sent as a firm event. 141*7c478bd9Sstevel@tonic-gate * TR_UNTRANS_EVENT also sends a firm event for each up / down transition, 142*7c478bd9Sstevel@tonic-gate * but the value is untranslated: the event id is the key station; the 143*7c478bd9Sstevel@tonic-gate * value indicates whether the transition was up or down; the value of the 144*7c478bd9Sstevel@tonic-gate * shift-mask is undefined. 145*7c478bd9Sstevel@tonic-gate */ 146*7c478bd9Sstevel@tonic-gate #define TR_NONE 0 147*7c478bd9Sstevel@tonic-gate #define TR_ASCII 1 148*7c478bd9Sstevel@tonic-gate #define TR_EVENT 2 149*7c478bd9Sstevel@tonic-gate #define TR_UNTRANS_EVENT 3 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate /* 152*7c478bd9Sstevel@tonic-gate * These bits can appear in the result of TR_NONE & TR_UNTRANS_EVENT getkey()s. 153*7c478bd9Sstevel@tonic-gate */ 154*7c478bd9Sstevel@tonic-gate #define BUILDKEY(key, state) (key | state) 155*7c478bd9Sstevel@tonic-gate #define STATEOF(key) ((key) & RELEASED) /* 0 = key down, !=0 = key up */ 156*7c478bd9Sstevel@tonic-gate #define KEYOF(key) ((key) & ~RELEASED) /* The key number that moved */ 157*7c478bd9Sstevel@tonic-gate #define NOKEY (-1) /* The argument was 0, and no key was */ 158*7c478bd9Sstevel@tonic-gate /* depressed. They were all elated. */ 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate /* 161*7c478bd9Sstevel@tonic-gate * "Bucky" bits. These are bits for mode keys. The META bit is ORed into the 162*7c478bd9Sstevel@tonic-gate * result of TR_ASCII getkey()s, and can be ORed into the result of TR_EVENT 163*7c478bd9Sstevel@tonic-gate * getkey()s for backwards compatibility. 164*7c478bd9Sstevel@tonic-gate * (NOKEY can also appear if no keypress was queued up.) 165*7c478bd9Sstevel@tonic-gate */ 166*7c478bd9Sstevel@tonic-gate #define METABIT 0 /* Meta key depressed with key */ 167*7c478bd9Sstevel@tonic-gate #define METAMASK 0x000080 168*7c478bd9Sstevel@tonic-gate #define SYSTEMBIT 1 /* Upper left key was down w/key */ 169*7c478bd9Sstevel@tonic-gate #define SYSTEMMASK 0x000100 170*7c478bd9Sstevel@tonic-gate /* other "bucky" bits can be defined at will. See "BUCKYBITS" below. */ 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate /* 173*7c478bd9Sstevel@tonic-gate * This defines the bit positions used within "shiftmask" to 174*7c478bd9Sstevel@tonic-gate * indicate the "pressed" (1) or "released" (0) state of shift keys. 175*7c478bd9Sstevel@tonic-gate * Both the bit numbers, and the aggregate masks, are defined. 176*7c478bd9Sstevel@tonic-gate * 177*7c478bd9Sstevel@tonic-gate * The "UPMASK" is a minor kludge. Since whether the key is going 178*7c478bd9Sstevel@tonic-gate * up or down determines the translation table (just as the shift 179*7c478bd9Sstevel@tonic-gate * keys' positions do), we OR it with "shiftmask" to get "tempmask", 180*7c478bd9Sstevel@tonic-gate * which is the mask which is actually used to determine the 181*7c478bd9Sstevel@tonic-gate * translation table to use. Don't reassign 0x0080 for anything 182*7c478bd9Sstevel@tonic-gate * else, or we'll have to shift and such to squeeze in UPMASK, 183*7c478bd9Sstevel@tonic-gate * since it comes in from the hardware as 0x80. 184*7c478bd9Sstevel@tonic-gate */ 185*7c478bd9Sstevel@tonic-gate #define CAPSLOCK 0 /* Caps Lock key */ 186*7c478bd9Sstevel@tonic-gate #define CAPSMASK 0x0001 187*7c478bd9Sstevel@tonic-gate #define SHIFTLOCK 1 /* Shift Lock key */ 188*7c478bd9Sstevel@tonic-gate #define LEFTSHIFT 2 /* Left-hand shift key */ 189*7c478bd9Sstevel@tonic-gate #define RIGHTSHIFT 3 /* Right-hand shift key */ 190*7c478bd9Sstevel@tonic-gate #define SHIFTMASK 0x000E 191*7c478bd9Sstevel@tonic-gate #define LEFTCTRL 4 /* Left-hand (or only) control key */ 192*7c478bd9Sstevel@tonic-gate #define RIGHTCTRL 5 /* Right-hand control key */ 193*7c478bd9Sstevel@tonic-gate #define CTRLMASK 0x0030 194*7c478bd9Sstevel@tonic-gate /* META 6 Meta keys */ 195*7c478bd9Sstevel@tonic-gate /* META_SHIFT_MASK 0x0040 reserved */ 196*7c478bd9Sstevel@tonic-gate /* TOP 7 do not use! */ 197*7c478bd9Sstevel@tonic-gate /* TOPMASK 0x0080 UPMASK in keyboard driver */ 198*7c478bd9Sstevel@tonic-gate /* CMD 8 reserved */ 199*7c478bd9Sstevel@tonic-gate /* CMDMASK 0x0100 reserved */ 200*7c478bd9Sstevel@tonic-gate #define ALTGRAPH 9 /* Alt Graph key */ 201*7c478bd9Sstevel@tonic-gate #define ALTGRAPHMASK 0x0200 202*7c478bd9Sstevel@tonic-gate #define ALT 10 /* Left (or only) Alt key */ 203*7c478bd9Sstevel@tonic-gate #define LEFTALT 10 /* Left Alt key */ 204*7c478bd9Sstevel@tonic-gate #define ALTMASK 0x1400 205*7c478bd9Sstevel@tonic-gate #define NUMLOCK 11 /* Num Lock key */ 206*7c478bd9Sstevel@tonic-gate #define NUMLOCKMASK 0x0800 207*7c478bd9Sstevel@tonic-gate #define RIGHTALT 12 /* Right Alt key */ 208*7c478bd9Sstevel@tonic-gate #define UPMASK 0x0080 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate /* 211*7c478bd9Sstevel@tonic-gate * This defines the format of translation tables. 212*7c478bd9Sstevel@tonic-gate * 213*7c478bd9Sstevel@tonic-gate * A translation table is KEYMAP_SIZE "entries", each of which is 2 bytes 214*7c478bd9Sstevel@tonic-gate * (unsigned shorts). The top 8 bits of each entry are decoded by 215*7c478bd9Sstevel@tonic-gate * a case statement in getkey.c. If the entry is less than 0x100, it 216*7c478bd9Sstevel@tonic-gate * is sent out as an EUC character (possibly with bucky bits 217*7c478bd9Sstevel@tonic-gate * OR-ed in). "Special" entries are 0x100 or greater, and 218*7c478bd9Sstevel@tonic-gate * invoke more complicated actions. 219*7c478bd9Sstevel@tonic-gate * 220*7c478bd9Sstevel@tonic-gate * The KEYMAP_SIZE is dependent upon the keyboard type. For example, the 221*7c478bd9Sstevel@tonic-gate * Sun Type 4/5 keyboards have a KEYMAP_SIZE of 128 where a USB keyboard 222*7c478bd9Sstevel@tonic-gate * has a KEYMAP_SIZE of 255. Instead of defining a KEYMAP_SIZE per 223*7c478bd9Sstevel@tonic-gate * keyboard type, a keyboard specific module/driver may supply the value 224*7c478bd9Sstevel@tonic-gate * at run time by defining the KEYMAP_SIZE_VARIABLE and filling in the 225*7c478bd9Sstevel@tonic-gate * keyboard struct appropriately. 226*7c478bd9Sstevel@tonic-gate */ 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate typedef unsigned short keymap_entry_t; 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate #else 233*7c478bd9Sstevel@tonic-gate #define KEYMAP_SIZE 128 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate struct keymap { 236*7c478bd9Sstevel@tonic-gate unsigned short keymap[KEYMAP_SIZE]; /* maps keycodes to actions */ 237*7c478bd9Sstevel@tonic-gate }; 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate #endif 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate /* 242*7c478bd9Sstevel@tonic-gate * This structure is used for "exception" cases for key sequences that 243*7c478bd9Sstevel@tonic-gate * we want to map, that should not be handled by keymap entries (For 244*7c478bd9Sstevel@tonic-gate * example: using Control-Shift-F1 on PC's for the compose key). 245*7c478bd9Sstevel@tonic-gate */ 246*7c478bd9Sstevel@tonic-gate struct exception_map { 247*7c478bd9Sstevel@tonic-gate /* 248*7c478bd9Sstevel@tonic-gate * these are the modifier keys that we "care" about 249*7c478bd9Sstevel@tonic-gate */ 250*7c478bd9Sstevel@tonic-gate unsigned int exc_care; 251*7c478bd9Sstevel@tonic-gate 252*7c478bd9Sstevel@tonic-gate /* 253*7c478bd9Sstevel@tonic-gate * This is the mask of modifier keys that we want to match 254*7c478bd9Sstevel@tonic-gate */ 255*7c478bd9Sstevel@tonic-gate unsigned int exc_mask; 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate /* 258*7c478bd9Sstevel@tonic-gate * This is the key that we want to match. 259*7c478bd9Sstevel@tonic-gate */ 260*7c478bd9Sstevel@tonic-gate int exc_key; 261*7c478bd9Sstevel@tonic-gate 262*7c478bd9Sstevel@tonic-gate /* 263*7c478bd9Sstevel@tonic-gate * This is our translated version of the matching sequence. 264*7c478bd9Sstevel@tonic-gate */ 265*7c478bd9Sstevel@tonic-gate unsigned short exc_entry; 266*7c478bd9Sstevel@tonic-gate }; 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate /* 269*7c478bd9Sstevel@tonic-gate * A keyboard is defined by its keymaps and what state it resets at idle. 270*7c478bd9Sstevel@tonic-gate * 271*7c478bd9Sstevel@tonic-gate * The masks k_idleshifts and k_idlebuckys are AND-ed with the current 272*7c478bd9Sstevel@tonic-gate * state of shiftmask and buckybits when a "keyboard idle" code 273*7c478bd9Sstevel@tonic-gate * is received. This ensures that where we "think" the shift & bucky 274*7c478bd9Sstevel@tonic-gate * keys are, more accurately reflects where they really are, since the 275*7c478bd9Sstevel@tonic-gate * keyboard knows better than us. However, some keyboards don't know 276*7c478bd9Sstevel@tonic-gate * about shift states that should be remembered across idles. Such 277*7c478bd9Sstevel@tonic-gate * shifts are described by k_toggleshifts. k_toggleshifts are used to 278*7c478bd9Sstevel@tonic-gate * identify such shifts. A toggle shift state is maintained separately 279*7c478bd9Sstevel@tonic-gate * from the general shift state. The toggle shift state is OR-ed 280*7c478bd9Sstevel@tonic-gate * with the state general shift state when an idle is received. 281*7c478bd9Sstevel@tonic-gate * k_toggleshifts should not appear in the k_up table. 282*7c478bd9Sstevel@tonic-gate */ 283*7c478bd9Sstevel@tonic-gate struct keyboard { 284*7c478bd9Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE 285*7c478bd9Sstevel@tonic-gate int k_keymap_size; /* Number of entries in keymaps */ 286*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_normal; /* Unshifted */ 287*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_shifted; /* Shifted */ 288*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_caps; /* Caps locked */ 289*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_altgraph; /* Alt Graph down */ 290*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_numlock; /* Num Lock down */ 291*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_control; /* Controlled */ 292*7c478bd9Sstevel@tonic-gate keymap_entry_t *k_up; /* Key went up */ 293*7c478bd9Sstevel@tonic-gate #else 294*7c478bd9Sstevel@tonic-gate struct keymap *k_normal; /* Unshifted */ 295*7c478bd9Sstevel@tonic-gate struct keymap *k_shifted; /* Shifted */ 296*7c478bd9Sstevel@tonic-gate struct keymap *k_caps; /* Caps locked */ 297*7c478bd9Sstevel@tonic-gate struct keymap *k_altgraph; /* Alt Graph down */ 298*7c478bd9Sstevel@tonic-gate struct keymap *k_numlock; /* Num Lock down */ 299*7c478bd9Sstevel@tonic-gate struct keymap *k_control; /* Controlled */ 300*7c478bd9Sstevel@tonic-gate struct keymap *k_up; /* Key went up */ 301*7c478bd9Sstevel@tonic-gate #endif 302*7c478bd9Sstevel@tonic-gate int k_idleshifts; /* Shifts that keep across idle */ 303*7c478bd9Sstevel@tonic-gate int k_idlebuckys; /* Bucky bits that keep across idle */ 304*7c478bd9Sstevel@tonic-gate unsigned char k_abort1; /* 1st key of abort sequence */ 305*7c478bd9Sstevel@tonic-gate unsigned char k_abort1a; /* alternate 1st key */ 306*7c478bd9Sstevel@tonic-gate unsigned char k_abort2; /* 2nd key of abort sequence */ 307*7c478bd9Sstevel@tonic-gate int k_toggleshifts; /* Shifts that toggle on down from */ 308*7c478bd9Sstevel@tonic-gate /* kbd and keep across idle */ 309*7c478bd9Sstevel@tonic-gate struct exception_map *k_except; /* Oddball cases */ 310*7c478bd9Sstevel@tonic-gate }; 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate /* 313*7c478bd9Sstevel@tonic-gate * Define the compose sequence structure. First and second 314*7c478bd9Sstevel@tonic-gate * ASCII chars of 0 indicate the end of the table. 315*7c478bd9Sstevel@tonic-gate */ 316*7c478bd9Sstevel@tonic-gate struct compose_sequence_t { 317*7c478bd9Sstevel@tonic-gate unsigned char first; /* first ASCII char after COMPOSE key */ 318*7c478bd9Sstevel@tonic-gate unsigned char second; /* second ASCII char after COMPOSE key */ 319*7c478bd9Sstevel@tonic-gate unsigned char iso; /* equivalent ISO code */ 320*7c478bd9Sstevel@tonic-gate }; 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate /* 323*7c478bd9Sstevel@tonic-gate * Define the floating accent sequence structure. 324*7c478bd9Sstevel@tonic-gate */ 325*7c478bd9Sstevel@tonic-gate struct fltaccent_sequence_t { 326*7c478bd9Sstevel@tonic-gate unsigned short fa_entry; /* floating accent keymap entry */ 327*7c478bd9Sstevel@tonic-gate unsigned char ascii; /* ASCII char after FA-type key */ 328*7c478bd9Sstevel@tonic-gate unsigned char iso; /* equivalent ISO code */ 329*7c478bd9Sstevel@tonic-gate }; 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate /* 332*7c478bd9Sstevel@tonic-gate * The "special" entries' top 4 bits are defined below. Generally they are 333*7c478bd9Sstevel@tonic-gate * used with a 4-bit parameter (such as a bit number) in the low 4 bits. 334*7c478bd9Sstevel@tonic-gate * The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ascii 335*7c478bd9Sstevel@tonic-gate * characters. They are not special cased, but just normal cased. 336*7c478bd9Sstevel@tonic-gate */ 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate #define SHIFTKEYS 0x100 /* thru 0x10F. This key helps to determine */ 339*7c478bd9Sstevel@tonic-gate /* the translation table used. The bit */ 340*7c478bd9Sstevel@tonic-gate /* position of its bit in "shiftmask" */ 341*7c478bd9Sstevel@tonic-gate /* is added to the entry, eg */ 342*7c478bd9Sstevel@tonic-gate /* SHIFTKEYS+LEFTCTRL. When this entry is */ 343*7c478bd9Sstevel@tonic-gate /* invoked, the bit in "shiftmask" is */ 344*7c478bd9Sstevel@tonic-gate /* toggled. Depending which tables you put */ 345*7c478bd9Sstevel@tonic-gate /* it in, this works well for hold-down */ 346*7c478bd9Sstevel@tonic-gate /* keys or press-on, press-off keys. */ 347*7c478bd9Sstevel@tonic-gate #define BUCKYBITS 0x200 /* thru 0x20F. This key determines the state */ 348*7c478bd9Sstevel@tonic-gate /* of one of the "bucky" bits above the */ 349*7c478bd9Sstevel@tonic-gate /* returned ASCII character. This is */ 350*7c478bd9Sstevel@tonic-gate /* basically a way to pass mode-key-up/down */ 351*7c478bd9Sstevel@tonic-gate /* information back to the caller with each */ 352*7c478bd9Sstevel@tonic-gate /* "real" key depressed. The concept, and */ 353*7c478bd9Sstevel@tonic-gate /* name "bucky" (derivation unknown) comes */ 354*7c478bd9Sstevel@tonic-gate /* from the MIT/SAIL "TV" system...they had */ 355*7c478bd9Sstevel@tonic-gate /* TOP, META, CTRL, and a few other bucky */ 356*7c478bd9Sstevel@tonic-gate /* bits. The bit position of its bit in */ 357*7c478bd9Sstevel@tonic-gate /* "buckybits", minus 7, is added to the */ 358*7c478bd9Sstevel@tonic-gate /* entry; eg bit 0x00000400 is BUCKYBITS+3. */ 359*7c478bd9Sstevel@tonic-gate /* The "-7" prevents us from messing up the */ 360*7c478bd9Sstevel@tonic-gate /* ASCII char, and gives us 16 useful bucky */ 361*7c478bd9Sstevel@tonic-gate /* bits. When this entry is invoked, */ 362*7c478bd9Sstevel@tonic-gate /* the designated bit in "buckybits" is */ 363*7c478bd9Sstevel@tonic-gate /* toggled. Depending which tables you put */ 364*7c478bd9Sstevel@tonic-gate /* it in, this works well for hold-down */ 365*7c478bd9Sstevel@tonic-gate /* keys or press-on, press-off keys. */ 366*7c478bd9Sstevel@tonic-gate #define FUNNY 0x300 /* thru 0x30F. This key does one of 16 funny */ 367*7c478bd9Sstevel@tonic-gate /* things based on the low 4 bits: */ 368*7c478bd9Sstevel@tonic-gate #define NOP 0x300 /* This key does nothing. */ 369*7c478bd9Sstevel@tonic-gate #define OOPS 0x301 /* This key exists but is undefined. */ 370*7c478bd9Sstevel@tonic-gate #define HOLE 0x302 /* This key does not exist on the keyboard. */ 371*7c478bd9Sstevel@tonic-gate /* Its position code should never be */ 372*7c478bd9Sstevel@tonic-gate /* generated. This indicates a software/ */ 373*7c478bd9Sstevel@tonic-gate /* hardware mismatch, or bugs. */ 374*7c478bd9Sstevel@tonic-gate #define RESET 0x306 /* Kbd was just reset */ 375*7c478bd9Sstevel@tonic-gate #define ERROR 0x307 /* Kbd just detected an internal error */ 376*7c478bd9Sstevel@tonic-gate #define IDLE 0x308 /* Kbd is idle (no keys down) */ 377*7c478bd9Sstevel@tonic-gate #define COMPOSE 0x309 /* This key is the Compose key. */ 378*7c478bd9Sstevel@tonic-gate #define NONL 0x30A /* This key not affected by Num Lock */ 379*7c478bd9Sstevel@tonic-gate /* Combinations 0x30B to 0x30F are reserved for non-parameterized functions */ 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate #define FA_CLASS 0x400 /* thru 0x40F. These are for "floating */ 382*7c478bd9Sstevel@tonic-gate /* accent" characters. The low-order 4 bits */ 383*7c478bd9Sstevel@tonic-gate /* select one of those characters. */ 384*7c478bd9Sstevel@tonic-gate /* Definitions for the individual floating accents: */ 385*7c478bd9Sstevel@tonic-gate #define FA_UMLAUT 0x400 /* umlaut accent */ 386*7c478bd9Sstevel@tonic-gate #define FA_CFLEX 0x401 /* circumflex accent */ 387*7c478bd9Sstevel@tonic-gate #define FA_TILDE 0x402 /* tilde accent */ 388*7c478bd9Sstevel@tonic-gate #define FA_CEDILLA 0x403 /* cedilla accent */ 389*7c478bd9Sstevel@tonic-gate #define FA_ACUTE 0x404 /* acute accent */ 390*7c478bd9Sstevel@tonic-gate #define FA_GRAVE 0x405 /* grave accent */ 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate #define STRING 0x500 /* thru 0x50F. The low-order 4 bits index */ 393*7c478bd9Sstevel@tonic-gate /* a table select a string to be returned, */ 394*7c478bd9Sstevel@tonic-gate /* char by char. Each entry the table is */ 395*7c478bd9Sstevel@tonic-gate /* null terminated. */ 396*7c478bd9Sstevel@tonic-gate #define KTAB_STRLEN 10 /* Maximum string length (including null) */ 397*7c478bd9Sstevel@tonic-gate /* Definitions for the individual string numbers: */ 398*7c478bd9Sstevel@tonic-gate #define HOMEARROW 0x00 399*7c478bd9Sstevel@tonic-gate #define UPARROW 0x01 400*7c478bd9Sstevel@tonic-gate #define DOWNARROW 0x02 401*7c478bd9Sstevel@tonic-gate #define LEFTARROW 0x03 402*7c478bd9Sstevel@tonic-gate #define RIGHTARROW 0x04 403*7c478bd9Sstevel@tonic-gate /* string numbers 5 thru F are available to users making custom entries */ 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* 406*7c478bd9Sstevel@tonic-gate * In the following function key groupings, the low-order 4 bits indicate 407*7c478bd9Sstevel@tonic-gate * the function key number within the group, and the next 4 bits indicate 408*7c478bd9Sstevel@tonic-gate * the group. 409*7c478bd9Sstevel@tonic-gate */ 410*7c478bd9Sstevel@tonic-gate #define FUNCKEYS 0x600 411*7c478bd9Sstevel@tonic-gate #define LEFTFUNC 0x600 /* thru 0x60F. The "left" group. */ 412*7c478bd9Sstevel@tonic-gate #define RIGHTFUNC 0x610 /* thru 0x61F. The "right" group. */ 413*7c478bd9Sstevel@tonic-gate #define TOPFUNC 0x620 /* thru 0x62F. The "top" group. */ 414*7c478bd9Sstevel@tonic-gate #define BOTTOMFUNC 0x630 /* thru 0x63F. The "bottom" group. */ 415*7c478bd9Sstevel@tonic-gate #define LF(n) (LEFTFUNC+(n)-1) 416*7c478bd9Sstevel@tonic-gate #define RF(n) (RIGHTFUNC+(n)-1) 417*7c478bd9Sstevel@tonic-gate #define TF(n) (TOPFUNC+(n)-1) 418*7c478bd9Sstevel@tonic-gate #define BF(n) (BOTTOMFUNC+(n)-1) 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate /* 421*7c478bd9Sstevel@tonic-gate * The actual keyboard positions may not be on the left/right/top/bottom 422*7c478bd9Sstevel@tonic-gate * of the physical keyboard (although they usually are). 423*7c478bd9Sstevel@tonic-gate * What is important is that we have reserved 64 keys for function keys. 424*7c478bd9Sstevel@tonic-gate * 425*7c478bd9Sstevel@tonic-gate * Normally, striking a function key will cause the following escape sequence 426*7c478bd9Sstevel@tonic-gate * to be sent through the character stream: 427*7c478bd9Sstevel@tonic-gate * ESC[0..9z 428*7c478bd9Sstevel@tonic-gate * where ESC is a single escape character and 0..9 indicate some number of 429*7c478bd9Sstevel@tonic-gate * digits needed to encode the function key as a decimal number. 430*7c478bd9Sstevel@tonic-gate */ 431*7c478bd9Sstevel@tonic-gate #define PADKEYS 0x700 432*7c478bd9Sstevel@tonic-gate #define PADEQUAL 0x700 /* keypad = */ 433*7c478bd9Sstevel@tonic-gate #define PADSLASH 0x701 /* keypad / */ 434*7c478bd9Sstevel@tonic-gate #define PADSTAR 0x702 /* keypad * */ 435*7c478bd9Sstevel@tonic-gate #define PADMINUS 0x703 /* keypad - */ 436*7c478bd9Sstevel@tonic-gate #define PADSEP 0x704 /* keypad, */ 437*7c478bd9Sstevel@tonic-gate #define PAD7 0x705 /* keypad 7 */ 438*7c478bd9Sstevel@tonic-gate #define PAD8 0x706 /* keypad 8 */ 439*7c478bd9Sstevel@tonic-gate #define PAD9 0x707 /* keypad 9 */ 440*7c478bd9Sstevel@tonic-gate #define PADPLUS 0x708 /* keypad + */ 441*7c478bd9Sstevel@tonic-gate #define PAD4 0x709 /* keypad 4 */ 442*7c478bd9Sstevel@tonic-gate #define PAD5 0x70A /* keypad 5 */ 443*7c478bd9Sstevel@tonic-gate #define PAD6 0x70B /* keypad 6 */ 444*7c478bd9Sstevel@tonic-gate #define PAD1 0x70C /* keypad 1 */ 445*7c478bd9Sstevel@tonic-gate #define PAD2 0x70D /* keypad 2 */ 446*7c478bd9Sstevel@tonic-gate #define PAD3 0x70E /* keypad 3 */ 447*7c478bd9Sstevel@tonic-gate #define PAD0 0x70F /* keypad 0 */ 448*7c478bd9Sstevel@tonic-gate #define PADDOT 0x710 /* keypad . */ 449*7c478bd9Sstevel@tonic-gate #define PADENTER 0x711 /* keypad Enter */ 450*7c478bd9Sstevel@tonic-gate 451*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 452*7c478bd9Sstevel@tonic-gate } 453*7c478bd9Sstevel@tonic-gate #endif 454*7c478bd9Sstevel@tonic-gate 455*7c478bd9Sstevel@tonic-gate #endif /* _SYS_KBD_H */ 456