Annotation of researchv9/sys/sundev/kbdvar.h, revision 1.1

1.1     ! root        1: /*     @(#)kbd.h 1.1 86/02/03 SMI      */
        !             2: 
        !             3: /* (C) Copyright 1983 by Sun Microsystems, Inc. */
        !             4: 
        !             5: /*
        !             6:  * Header file for Sun Microsystems keyboard routines
        !             7:  * which is disgustingly similar to ../mon/keyboard.h.
        !             8:  * Since the Sun kernel uses these constants to decode
        !             9:  * at least the keybid passed by the monitor, these files
        !            10:  * must be kept in sync, or merged.
        !            11:  *
        !            12:  * The keyboard is a standard Micro Switch, or otherwise, keyboard,
        !            13:  * with an 8048/8748 on the board.  This has been modified to produce
        !            14:  * up/down keycodes.
        !            15:  *
        !            16:  * On Sun-1 keyboards these keycodes are output on 8 parallel output lines.
        !            17:  * Each keycode is held stable on these lines for a minimum of 2.5 ms in
        !            18:  * order that the main processor can read it during its refresh
        !            19:  * routine, which executes every 2 ms or so.  
        !            20:  *
        !            21:  * On Sun-2 keyboards, the keycodes are transmitted on a serial line
        !            22:  * at 1200 baud.
        !            23:  *
        !            24:  * When no physical keys are depressed, the keyboard transmits a keycode of
        !            25:  * "IDLE" (7F hex), to indicate that.  Thus, when the last key is released,
        !            26:  * a keycode for its release is sent, then an IDLE.  Note that virtual
        !            27:  * keys on the VT100 kbd (eg CAPS LOCK) can be down when the IDLE code
        !            28:  * is received.
        !            29:  *
        !            30:  * The Sun-1 VT100 keyboard will follow each of its IDLE's with a
        !            31:  * keyboard id code, identifying the key layout or other factors
        !            32:  * which host programs might want to automatically determine.
        !            33:  *
        !            34:  * The low 4 bits of the id byte contain the keyboard ID (currently
        !            35:  * 1 for VT100 keyboard); the high order bit is set (to make sure
        !            36:  * there's a transition between the IDLE (7F) and the identification
        !            37:  * byte); the -XXX---- bits contain state information about the keyboard.
        !            38:  * These bits are allocated from opposite ends in case we need to shift
        !            39:  * the boundary.  The only state bit currently defined is 0x40, which is
        !            40:  * the current state of the CAPS LOCK LED.
        !            41:  *
        !            42:  * The Sun-2 keyboard also transmits two other "special" keycodes:
        !            43:  *
        !            44:  *     RESETKEY        upon power-up, when no errors are detected,
        !            45:  *                     this code is sent and followed by the keyboard id,
        !            46:  *                     a byte containing 0x02.
        !            47:  *
        !            48:  *     ERRORKEY        upon power-up, when errors are detected, 
        !            49:  *                     this code is sent and followed by a "cause" byte
        !            50:  *                     giving more details.  There is only one cause byte
        !            51:  *                     defined so far -- checksum error on PROM.
        !            52:  */
        !            53: 
        !            54: /*
        !            55:  * Various special characters that might show up on the port
        !            56:  */
        !            57: /* Both of these are followed by 1 byte of parameters. */
        !            58: #define        RESETKEY        0xFF            /* Keyboard was just reset */
        !            59: #define        ERRORKEY        0x7E            /* Keyboard detected an error */
        !            60: #define        NOTPRESENT      0xFF            /* Keyboard is not plugged in */
        !            61: 
        !            62: #define        IDLEKEY         0x7F            /* Keyboard is idle; no keys down */
        !            63: #define        PRESSED         0x00            /* 0x80 bit off: key was pressed */
        !            64: #define        RELEASED        0x80            /* 0x80 bit on : key was released */
        !            65: 
        !            66: /*
        !            67:  * Keyboard ID codes...transmitted by the various keyboards
        !            68:  * after the IDLEKEY code.  See top of file for more details.
        !            69:  * The value of KB_UNKNOWN above must not match any of these,
        !            70:  * if KBDID is set.
        !            71:  */
        !            72: #define        KB_KLUNK        0x00            /* Micro Switch 103SD32-2 */
        !            73: #define        KB_VT100        0x01            /* Keytronics VT100 compatible */
        !            74: #define        KB_SUN2         0x02            /* Sun-2 custom keyboard */
        !            75: #define        KB_SUN3         0x03            /* Sun-3 custom keyboard */
        !            76: #define        KB_ASCII        0x0F            /* Ascii terminal masquerading as kbd */
        !            77: 
        !            78: /*
        !            79:  * Commands to the Sun-2 keyboard.
        !            80:  */
        !            81: #define        KBD_CMD_RESET   0x01            /* Reset keyboard as if power-up */
        !            82: #define        KBD_CMD_BELL    0x02            /* Turn on the bell */
        !            83: #define        KBD_CMD_NOBELL  0x03            /* Turn off the bell */
        !            84: #define        KBD_CMD_LED1    0x04            /* Turn on LED 1 */
        !            85: #define        KBD_CMD_NOLED1  0x05            /* Turn off LED 1 */
        !            86: #define        KBD_CMD_LED2    0x06            /* Turn on LED 2 */
        !            87: #define        KBD_CMD_NOLED2  0x07            /* Turn off LED 2 */
        !            88: 
        !            89: /*
        !            90:  * Commands to the Sun-3 keyboard.  KBD_CMD_BELL & KBD_CMD_NOBELL work
        !            91:  * as well.
        !            92:  */
        !            93: #define        KBD_CMD_CLICK   0x0A            /* Turn on the click annunciator */
        !            94: #define        KBD_CMD_NOCLICK 0x0B            /* Turn off the click annunciator */
        !            95: 
        !            96: /*
        !            97:  * Software related definitions
        !            98:  */
        !            99: /*
        !           100:  * These are the states that the keyboard scanner can be in.
        !           101:  *
        !           102:  * It starts out in NORMAL state.
        !           103:  */
        !           104: #define        NORMAL          0               /* The usual (ho, hum) */
        !           105: #define        ABORT1          1               /* Got KEYABORT1 */
        !           106: #define        IDLE1           2               /* Got IDLE */
        !           107: #define        IDLE2           3               /* Got id byte, IDLE probably follows */
        !           108: 
        !           109: /*
        !           110:  * These are how you can have your input translated.
        !           111:  * TR_EVENT means that each keystroke is sent as a firm event.
        !           112:  */
        !           113: #define        TR_NONE         0
        !           114: #define        TR_ASCII        1
        !           115: #define        TR_EVENT        2
        !           116: 
        !           117: /*
        !           118:  * These bits can appear in the result of TR_NONE getkey()s.
        !           119:  */
        !           120: #define        STATEOF(key)    ((key) & 0x80)  /* 0 = key down, 0x80 = key up */
        !           121: #define        KEYOF(key)      ((key) & 0x7F)  /* The key number that moved */
        !           122: #define        NOKEY           (-1)            /* The argument was 0, and no key was
        !           123:                                           depressed.  They were all elated. */
        !           124: 
        !           125: /*
        !           126:  * These bits can appear in the result of TR_ASCII getkey()s.
        !           127:  * (NOKEY can also appear if no keypress was queued up.)
        !           128:  */
        !           129: #define        METABIT         0               /* Meta key depressed with key */
        !           130: #define        METAMASK        0x000080
        !           131: #define        SYSTEMBIT       1               /* Upper left key was down w/key */
        !           132: #define        SYSTEMMASK      0x000100
        !           133: /* other "bucky" bits can be defined at will.  See "BUCKYBITS" below. */
        !           134: 
        !           135: /*
        !           136:  * This defines the bit positions used within "shiftmask" to
        !           137:  * indicate the "pressed" (1) or "released" (0) state of shift keys.
        !           138:  * Both the bit numbers, and the aggregate masks, are defined.
        !           139:  *
        !           140:  * The "UPMASK" is a minor kludge.  Since whether the key is going
        !           141:  * up or down determines the translation table (just as the shift
        !           142:  * keys' positions do), we OR it with "shiftmask" to get "tempmask",
        !           143:  * which is the mask which is actually used to determine the 
        !           144:  * translation table to use.  Don't reassign 0x0080 for anything
        !           145:  * else, or we'll have to shift and such to squeeze in UPMASK,
        !           146:  * since it comes in from the hardware as 0x80.
        !           147:  */
        !           148: #ifndef        CAPSLOCK        /* Same as sunwindow/win_input.h */
        !           149: #define        CAPSLOCK        0               /* Caps Lock key */
        !           150: #define        CAPSMASK        0x0001
        !           151: #define        SHIFTLOCK       1               /* Shift Lock key */
        !           152: #define        LEFTSHIFT       2               /* Left-hand shift key */
        !           153: #define        RIGHTSHIFT      3               /* Right-hand shift key */
        !           154: #define        SHIFTMASK       0x000E
        !           155: #define        LEFTCTRL        4               /* Left-hand (or only) control key */
        !           156: #define        RIGHTCTRL       5               /* Right-hand control key */
        !           157: #define        CTRLMASK        0x0030
        !           158: #endif CAPSLOCK
        !           159: /* unused...           0x0040 */
        !           160: #define        UPMASK  0x0080
        !           161: #define        CTLSMASK        0x0100          /* Set if ^S was last keyed of ^S, ^Q;
        !           162:                                           determines which NOSCOLL sends. */
        !           163: #define ALT            6               /* ALT key on Sun-3 keyboard */
        !           164: 
        !           165: /*
        !           166:  * This defines the format of translation tables.
        !           167:  *
        !           168:  * A translation table is 128 bytes of "entries", which are bytes
        !           169:  * (unsigned chars).  The top 4 bits of each entry are decoded by
        !           170:  * a case statement in getkey.c.  If the entry is less than 0x80, it
        !           171:  * is sent out as an ASCII character (possibly with bucky bits
        !           172:  * OR-ed in).  "Special" entries are 0x80 or greater, and
        !           173:  * invoke more complicated actions.
        !           174:  */
        !           175: struct keymap {
        !           176:        unsigned char   keymap[128];    /* maps keycodes to actions */
        !           177: };
        !           178: 
        !           179: /*
        !           180:  * A keyboard is defined by its keymaps and what state it resets at idle.
        !           181:  *
        !           182:  * The masks k_idleshifts and k_idlebuckys are AND-ed with the current
        !           183:  * state of  shiftmask  and  buckybits  when a "keyboard idle" code
        !           184:  * is received.  This ensures that where we "think" the shift & bucky
        !           185:  * keys are, more accurately reflects where they really are, since the
        !           186:  * keyboard knows better than us.  However, some keyboards don't know
        !           187:  * about shift states that should be remembered across idles.  Such
        !           188:  * shifts are described by k_toggleshifts.  k_toggleshifts are used to
        !           189:  * identify such shifts.  A toggle shift state is maintained separately
        !           190:  * from the general shift state.  The toggle shift state is OR-ed
        !           191:  * with the state general shift state when an idle is received.
        !           192:  * k_toggleshifts should not appear in the k_up table.
        !           193:  */
        !           194: struct keyboard {
        !           195:        struct keymap   *k_normal;      /* Unshifted */
        !           196:        struct keymap   *k_shifted;     /* Shifted */
        !           197:        struct keymap   *k_caps;        /* Caps locked */
        !           198:        struct keymap   *k_control;     /* Controlled */
        !           199:        struct keymap   *k_up;          /* Key went up */
        !           200:        int             k_idleshifts;   /* Shifts that keep across idle */
        !           201:        int             k_idlebuckys;   /* Bucky bits that keep across idle */
        !           202:        unsigned char   k_abort1;       /* 1st key of abort sequence */
        !           203:        unsigned char   k_abort2;       /* 2nd key of abort sequence */
        !           204:        int             k_toggleshifts; /* Shifts that toggle on down from kbd
        !           205:                                         * and keep across idle */
        !           206: };
        !           207: 
        !           208: 
        !           209: /*
        !           210:  * The "special" entries' top 4 bits are defined below.  Generally they are
        !           211:  * used with a 4-bit parameter (such as a bit number) in the low 4 bits.
        !           212:  * The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ascii 
        !           213:  * characters.  They are not special cased, but just normal cased.
        !           214:  */
        !           215: 
        !           216: #define        SHIFTKEYS       0x80    /* thru 0x8F.  This key helps to determine the
        !           217:                                   translation table used.  The bit
        !           218:                                   position of its bit in "shiftmask"
        !           219:                                   is added to the entry, eg
        !           220:                                   SHIFTKEYS+LEFTCTRL.  When this entry is
        !           221:                                   invoked, the bit in "shiftmask" is
        !           222:                                   toggled.  Depending which tables you put
        !           223:                                   it in, this works well for hold-down
        !           224:                                   keys or press-on, press-off keys.  */
        !           225: #define        BUCKYBITS       0x90    /* thru 0x9F.  This key determines the state of
        !           226:                                   one of the "bucky" bits above the
        !           227:                                   returned ASCII character.  This is
        !           228:                                   basically a way to pass mode-key-up/down
        !           229:                                   information back to the caller with each
        !           230:                                   "real" key depressed.  The concept, and
        !           231:                                   name "bucky" (derivation unknown) comes
        !           232:                                   from the MIT/SAIL "TV" system...they had
        !           233:                                   TOP, META, CTRL, and a few other bucky
        !           234:                                   bits.  The bit position of its bit in
        !           235:                                   "buckybits", minus 7, is added to the
        !           236:                                   entry; eg bit 0x00000400 is BUCKYBITS+3.
        !           237:                                   The "-7" prevents us from messing up the
        !           238:                                   ASCII char, and gives us 16 useful bucky
        !           239:                                   bits.  When this entry is invoked,
        !           240:                                   the designated bit in "buckybits" is
        !           241:                                   toggled.  Depending which tables you put
        !           242:                                   it in, this works well for hold-down
        !           243:                                   keys or press-on, press-off keys.  */
        !           244: #define        FUNNY           0xA0    /* thru 0xAF.  This key does one of 16 funny
        !           245:                                   things based on the low 4 bits: */
        !           246: #define        NOP             0xA0    /* This key does nothing. */
        !           247: #define        OOPS            0xA1    /* This key exists but is undefined. */
        !           248: #define        HOLE            0xA2    /* This key does not exist on the keyboard.
        !           249:                                   Its position code should never be
        !           250:                                   generated.  This indicates a software/
        !           251:                                   hardware mismatch, or bugs. */
        !           252: #define        NOSCROLL        0xA3    /* This key alternately sends ^S or ^Q */
        !           253: #define        CTRLS           0xA4    /* This sends ^S and lets NOSCROLL know */
        !           254: #define        CTRLQ           0xA5    /* This sends ^Q and lets NOSCROLL know */
        !           255: #define        RESET           0xA6    /* Kbd was just reset */
        !           256: #define        ERROR           0xA7    /* Kbd just detected an internal error */
        !           257: #define        IDLE            0xA8    /* Kbd is idle (no keys down) */
        !           258: /* Combinations 0xA9 to 0xAF are reserved for non-parameterized functions */
        !           259: 
        !           260: #define        STRING          0xB0    /* thru 0xBF.  The low-order 4 bits index
        !           261:                                   a table select a string to be returned,
        !           262:                                   char by char.  Each entry the table is
        !           263:                                   null terminated. */
        !           264: #define        KTAB_STRLEN     10      /* Maximum string length (including null) */
        !           265: /* Definitions for the individual string numbers: */
        !           266: #define        HOMEARROW       0x00
        !           267: #define        UPARROW         0x01
        !           268: #define        DOWNARROW       0x02
        !           269: #define        LEFTARROW       0x03
        !           270: #define        RIGHTARROW      0x04
        !           271: /* string numbers 5 thru F are available to users making custom entries */
        !           272: 
        !           273: /* In the following function key groupings, the low-order 4 bits indicate
        !           274:    the function key number with in the group. */
        !           275: #define        LEFTFUNC        0xC0    /* thru 0xCF.  The "left" group. */
        !           276: #define        RIGHTFUNC       0xD0    /* thru 0xDF.  The "right" group. */
        !           277: #define        TOPFUNC         0xE0    /* thru 0xEF.  The "top" group. */
        !           278: #define        BOTTOMFUNC      0xF0    /* thru 0xFF.  The "bottom" group. */
        !           279: #define LF(n)          (LEFTFUNC+(n)-1)
        !           280: #define RF(n)          (RIGHTFUNC+(n)-1)
        !           281: #define TF(n)          (TOPFUNC+(n)-1)
        !           282: #define BF(n)          (BOTTOMFUNC+(n)-1)
        !           283: /* The actual keyboard positions may not be on the left/right/top/bottom
        !           284:    of the physical keyboard (although they usually are).
        !           285:    What is important is that we have reserved 64 keys for function keys.
        !           286: 
        !           287:    Normally, striking a function key will cause the following escape sequence
        !           288:    to be sent through the character stream:
        !           289:        ESC[0..9z
        !           290:    where ESC is a single escape character and 0..9 indicate some number of
        !           291:    digits needed to encode the function key as a decimal number. */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.