xref: /onnv-gate/usr/src/uts/common/sys/kbd.h (revision 3505:280762f431b6)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3505Sqz150045  * Common Development and Distribution License (the "License").
6*3505Sqz150045  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*3505Sqz150045  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*3505Sqz150045  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_KBD_H
270Sstevel@tonic-gate #define	_SYS_KBD_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS4.0 1.18 */
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * Following #defines are related to the older keyboards which
370Sstevel@tonic-gate  * are no longer supported by kb module.  The #defines ane left
380Sstevel@tonic-gate  * for older programs to still compile.
390Sstevel@tonic-gate  */
400Sstevel@tonic-gate #define	KB_KLUNK	0x00		/* Micro Switch 103SD32-2 */
410Sstevel@tonic-gate #define	KB_VT100	0x01		/* Keytronics VT100 compatible */
420Sstevel@tonic-gate #define	KB_SUN2		0x02		/* Sun-2 custom keyboard */
430Sstevel@tonic-gate #define	KB_VT220	0x81		/* Emulation VT220 */
440Sstevel@tonic-gate #define	KB_VT220I	0x82		/* International VT220 Emulation */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #define	NOTPRESENT	0xFF		/* Keyboard is not plugged in */
470Sstevel@tonic-gate #define	KBD_CMD_LED1	0x04		/* Turn on LED 1 for Sun-2 */
480Sstevel@tonic-gate #define	KBD_CMD_NOLED1	0x05		/* Turn off LED 1 for Sun-2 */
490Sstevel@tonic-gate #define	KBD_CMD_LED2	0x06		/* Turn on LED 2 for Sun-2 */
500Sstevel@tonic-gate #define	KBD_CMD_NOLED2	0x07		/* Turn off LED 2 for Sun-2 */
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #define	CTLSMASK	0x0100		/* Set if ^S was last keyed of ^S, ^Q */
530Sstevel@tonic-gate 					/* determines which NOSCROLL sends. */
540Sstevel@tonic-gate 
550Sstevel@tonic-gate #define	NOSCROLL	0x303	/* This key alternately sends ^S or ^Q */
560Sstevel@tonic-gate #define	CTRLS		0x304	/* This sends ^S and lets NOSCROLL know */
570Sstevel@tonic-gate #define	CTRLQ		0x305	/* This sends ^Q and lets NOSCROLL know */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate  * Following are the only keyboard types supported by kb module.
620Sstevel@tonic-gate  * (Type 5, Hobo, US101A are also supported but they report
630Sstevel@tonic-gate  * themselves as Type 4 keyboard with a different layout id.)
640Sstevel@tonic-gate  */
650Sstevel@tonic-gate #define	KB_SUN3		3		/* Type 3 Sun keyboard */
660Sstevel@tonic-gate #define	KB_SUN4		4		/* Type 4 Sun keyboard */
670Sstevel@tonic-gate #define	KB_USB		6		/* USB keyboard */
680Sstevel@tonic-gate #define	KB_PC		101		/* Type 101 AT keyboard */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #define	KB_ASCII	0x0F		/* Ascii terminal masquerading as kbd */
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * This structure is used to enumerate the supported keyboard types.
740Sstevel@tonic-gate  * The array of these is terminated by an entry with a NULL table entry.
750Sstevel@tonic-gate  * The first entry is used if none match.
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate struct keyboards {
780Sstevel@tonic-gate 	int		id;	/* Keyboard type, per KIOCTYPE */
790Sstevel@tonic-gate 	struct keyboard	*table;	/* Keyboard table to use. */
800Sstevel@tonic-gate };
810Sstevel@tonic-gate 
820Sstevel@tonic-gate /*
830Sstevel@tonic-gate  * Various special characters that might show up on the port
840Sstevel@tonic-gate  */
850Sstevel@tonic-gate #define	IDLEKEY		0x7F		/* Keyboard is idle; no keys down */
860Sstevel@tonic-gate #define	ERRORKEY	0x7E		/* Keyboard detected an error */
870Sstevel@tonic-gate #define	RESETKEY	0xFF		/* Keyboard was just reset */
880Sstevel@tonic-gate #define	LAYOUTKEY	0xFE		/* Keyboard layout byte follows */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate #define	PRESSED		0x00		/* 0x80 bit off: key was pressed */
910Sstevel@tonic-gate #define	RELEASED	0x80		/* 0x80 bit on : key was released */
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /*
940Sstevel@tonic-gate  * Commands to the Sun-3 keyboard.
950Sstevel@tonic-gate  */
960Sstevel@tonic-gate #define	KBD_CMD_RESET		0x01	/* Reset keyboard as if power-up */
970Sstevel@tonic-gate #define	KBD_CMD_BELL		0x02	/* Turn on the bell */
980Sstevel@tonic-gate #define	KBD_CMD_NOBELL		0x03	/* Turn off the bell */
990Sstevel@tonic-gate #define	KBD_CMD_CLICK		0x0A	/* Turn on the click annunciator */
1000Sstevel@tonic-gate #define	KBD_CMD_NOCLICK		0x0B	/* Turn off the click annunciator */
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * Commands to the Type 4 keyboard, in addition to those above.
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate #define	KBD_CMD_AUTOTEST	0x0C	/* Initiate test sequence */
1060Sstevel@tonic-gate #define	KBD_CMD_SETLED		0x0E	/* Set keyboard LED's */
1070Sstevel@tonic-gate #define	KBD_CMD_GETLAYOUT	0x0F	/* Request that keyboard indicate */
1080Sstevel@tonic-gate 					/* layout */
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * Type 4 keyboard LED masks (used to set LED's)
1110Sstevel@tonic-gate  */
1120Sstevel@tonic-gate #define	LED_NUM_LOCK	0x1
1130Sstevel@tonic-gate #define	LED_COMPOSE	0x2
1140Sstevel@tonic-gate #define	LED_SCROLL_LOCK 0x4
1150Sstevel@tonic-gate #define	LED_CAPS_LOCK	0x8
1160Sstevel@tonic-gate #define	LED_KANA	0x10		/* Valid only on Japanese layout */
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate  * Software related definitions
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate /*
1220Sstevel@tonic-gate  * These are the states that the keyboard scanner can be in.
1230Sstevel@tonic-gate  *
1240Sstevel@tonic-gate  * It starts out in NORMAL state.
1250Sstevel@tonic-gate  */
1260Sstevel@tonic-gate #define	NORMAL		0		/* The usual (ho, hum) */
1270Sstevel@tonic-gate #define	ABORT1		1		/* Got KEYABORT1 */
1280Sstevel@tonic-gate #define	COMPOSE1	2		/* Got COMPOSE */
1290Sstevel@tonic-gate #define	COMPOSE2	3		/* Got COMPOSE plus first key */
1300Sstevel@tonic-gate #define	FLTACCENT	4		/* Got floating accent key */
131*3505Sqz150045 #define	NEWABORT1	5		/* Got NEW KEYABORT1 */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Size of ASCII set as used in compose handling.
1350Sstevel@tonic-gate  */
1360Sstevel@tonic-gate #define	ASCII_SET_SIZE	128
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * These are how you can have your input translated.
1400Sstevel@tonic-gate  * TR_EVENT means that each keystroke is sent as a firm event.
1410Sstevel@tonic-gate  * TR_UNTRANS_EVENT also sends a firm event for each up / down transition,
1420Sstevel@tonic-gate  * but the value is untranslated: the event id is the key station; the
1430Sstevel@tonic-gate  * value indicates whether the transition was up or down; the value of the
1440Sstevel@tonic-gate  * shift-mask is undefined.
1450Sstevel@tonic-gate  */
1460Sstevel@tonic-gate #define	TR_NONE		  0
1470Sstevel@tonic-gate #define	TR_ASCII	  1
1480Sstevel@tonic-gate #define	TR_EVENT	  2
1490Sstevel@tonic-gate #define	TR_UNTRANS_EVENT  3
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /*
1520Sstevel@tonic-gate  * These bits can appear in the result of TR_NONE & TR_UNTRANS_EVENT getkey()s.
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate #define	BUILDKEY(key, state)	(key | state)
1550Sstevel@tonic-gate #define	STATEOF(key)	((key) & RELEASED)	/* 0 = key down, !=0 = key up */
1560Sstevel@tonic-gate #define	KEYOF(key)	((key) & ~RELEASED)	/* The key number that moved */
1570Sstevel@tonic-gate #define	NOKEY		(-1)		/* The argument was 0, and no key was */
1580Sstevel@tonic-gate 					/* depressed.  They were all elated. */
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate /*
1610Sstevel@tonic-gate  * "Bucky" bits.  These are bits for mode keys.	 The META bit is ORed into the
1620Sstevel@tonic-gate  * result of TR_ASCII getkey()s, and can be ORed into the result of TR_EVENT
1630Sstevel@tonic-gate  * getkey()s for backwards compatibility.
1640Sstevel@tonic-gate  * (NOKEY can also appear if no keypress was queued up.)
1650Sstevel@tonic-gate  */
1660Sstevel@tonic-gate #define	METABIT		0		/* Meta key depressed with key */
1670Sstevel@tonic-gate #define	METAMASK	0x000080
1680Sstevel@tonic-gate #define	SYSTEMBIT	1		/* Upper left key was down w/key */
1690Sstevel@tonic-gate #define	SYSTEMMASK	0x000100
1700Sstevel@tonic-gate /* other "bucky" bits can be defined at will.  See "BUCKYBITS" below. */
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate /*
1730Sstevel@tonic-gate  * This defines the bit positions used within "shiftmask" to
1740Sstevel@tonic-gate  * indicate the "pressed" (1) or "released" (0) state of shift keys.
1750Sstevel@tonic-gate  * Both the bit numbers, and the aggregate masks, are defined.
1760Sstevel@tonic-gate  *
1770Sstevel@tonic-gate  * The "UPMASK" is a minor kludge.  Since whether the key is going
1780Sstevel@tonic-gate  * up or down determines the translation table (just as the shift
1790Sstevel@tonic-gate  * keys' positions do), we OR it with "shiftmask" to get "tempmask",
1800Sstevel@tonic-gate  * which is the mask which is actually used to determine the
1810Sstevel@tonic-gate  * translation table to use.  Don't reassign 0x0080 for anything
1820Sstevel@tonic-gate  * else, or we'll have to shift and such to squeeze in UPMASK,
1830Sstevel@tonic-gate  * since it comes in from the hardware as 0x80.
1840Sstevel@tonic-gate  */
1850Sstevel@tonic-gate #define	CAPSLOCK	0		/* Caps Lock key */
1860Sstevel@tonic-gate #define	CAPSMASK	0x0001
1870Sstevel@tonic-gate #define	SHIFTLOCK	1		/* Shift Lock key */
1880Sstevel@tonic-gate #define	LEFTSHIFT	2		/* Left-hand shift key */
1890Sstevel@tonic-gate #define	RIGHTSHIFT	3		/* Right-hand shift key */
1900Sstevel@tonic-gate #define	SHIFTMASK	0x000E
1910Sstevel@tonic-gate #define	LEFTCTRL	4		/* Left-hand (or only) control key */
1920Sstevel@tonic-gate #define	RIGHTCTRL	5		/* Right-hand control key */
1930Sstevel@tonic-gate #define	CTRLMASK	0x0030
1940Sstevel@tonic-gate /*	META		6		Meta keys */
1950Sstevel@tonic-gate /*	META_SHIFT_MASK 0x0040		reserved */
1960Sstevel@tonic-gate /*	TOP		7		do not use! */
1970Sstevel@tonic-gate /*	TOPMASK		0x0080		UPMASK in keyboard driver */
1980Sstevel@tonic-gate /*	CMD		8		reserved */
1990Sstevel@tonic-gate /*	CMDMASK		0x0100		reserved */
2000Sstevel@tonic-gate #define	ALTGRAPH	9		/* Alt Graph key */
2010Sstevel@tonic-gate #define	ALTGRAPHMASK	0x0200
2020Sstevel@tonic-gate #define	ALT		10		/* Left (or only) Alt key */
2030Sstevel@tonic-gate #define	LEFTALT		10		/* Left Alt key */
2040Sstevel@tonic-gate #define	ALTMASK		0x1400
2050Sstevel@tonic-gate #define	NUMLOCK		11		/* Num Lock key */
2060Sstevel@tonic-gate #define	NUMLOCKMASK	0x0800
2070Sstevel@tonic-gate #define	RIGHTALT	12		/* Right Alt key */
2080Sstevel@tonic-gate #define	UPMASK		0x0080
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate /*
2110Sstevel@tonic-gate  * This defines the format of translation tables.
2120Sstevel@tonic-gate  *
2130Sstevel@tonic-gate  * A translation table is KEYMAP_SIZE "entries", each of which is 2 bytes
2140Sstevel@tonic-gate  * (unsigned shorts).  The top 8 bits of each entry are decoded by
2150Sstevel@tonic-gate  * a case statement in getkey.c.  If the entry is less than 0x100, it
2160Sstevel@tonic-gate  * is sent out as an EUC character (possibly with bucky bits
2170Sstevel@tonic-gate  * OR-ed in).  "Special" entries are 0x100 or greater, and
2180Sstevel@tonic-gate  * invoke more complicated actions.
2190Sstevel@tonic-gate  *
2200Sstevel@tonic-gate  * The KEYMAP_SIZE is dependent upon the keyboard type.  For example, the
2210Sstevel@tonic-gate  * Sun Type 4/5 keyboards have a KEYMAP_SIZE of 128 where a USB keyboard
2220Sstevel@tonic-gate  * has a KEYMAP_SIZE of 255.  Instead of defining a KEYMAP_SIZE per
2230Sstevel@tonic-gate  * keyboard type, a keyboard specific module/driver may supply the value
2240Sstevel@tonic-gate  * at run time by defining the KEYMAP_SIZE_VARIABLE and filling in the
2250Sstevel@tonic-gate  * keyboard struct appropriately.
2260Sstevel@tonic-gate  */
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate typedef unsigned short keymap_entry_t;
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #else
2330Sstevel@tonic-gate #define	KEYMAP_SIZE	128
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate struct keymap {
2360Sstevel@tonic-gate 	unsigned short	keymap[KEYMAP_SIZE];	/* maps keycodes to actions */
2370Sstevel@tonic-gate };
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate #endif
2400Sstevel@tonic-gate 
2410Sstevel@tonic-gate /*
2420Sstevel@tonic-gate  * This structure is used for "exception" cases for key sequences that
2430Sstevel@tonic-gate  * we want to map, that should not be handled by keymap entries (For
2440Sstevel@tonic-gate  * example: using Control-Shift-F1 on PC's for the compose key).
2450Sstevel@tonic-gate  */
2460Sstevel@tonic-gate struct exception_map {
2470Sstevel@tonic-gate 	/*
2480Sstevel@tonic-gate 	 * these are the modifier keys that we "care" about
2490Sstevel@tonic-gate 	 */
2500Sstevel@tonic-gate 	unsigned int exc_care;
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate 	/*
2530Sstevel@tonic-gate 	 * This is the mask of modifier keys that we want to match
2540Sstevel@tonic-gate 	 */
2550Sstevel@tonic-gate 	unsigned int exc_mask;
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate 	/*
2580Sstevel@tonic-gate 	 * This is the key that we want to match.
2590Sstevel@tonic-gate 	 */
2600Sstevel@tonic-gate 	int exc_key;
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate 	/*
2630Sstevel@tonic-gate 	 * This is our translated version of the matching sequence.
2640Sstevel@tonic-gate 	 */
2650Sstevel@tonic-gate 	unsigned short exc_entry;
2660Sstevel@tonic-gate };
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate /*
2690Sstevel@tonic-gate  * A keyboard is defined by its keymaps and what state it resets at idle.
2700Sstevel@tonic-gate  *
2710Sstevel@tonic-gate  * The masks k_idleshifts and k_idlebuckys are AND-ed with the current
2720Sstevel@tonic-gate  * state of  shiftmask	and  buckybits	when a "keyboard idle" code
2730Sstevel@tonic-gate  * is received.	 This ensures that where we "think" the shift & bucky
2740Sstevel@tonic-gate  * keys are, more accurately reflects where they really are, since the
2750Sstevel@tonic-gate  * keyboard knows better than us.  However, some keyboards don't know
2760Sstevel@tonic-gate  * about shift states that should be remembered across idles.  Such
2770Sstevel@tonic-gate  * shifts are described by k_toggleshifts.  k_toggleshifts are used to
2780Sstevel@tonic-gate  * identify such shifts.  A toggle shift state is maintained separately
2790Sstevel@tonic-gate  * from the general shift state.  The toggle shift state is OR-ed
2800Sstevel@tonic-gate  * with the state general shift state when an idle is received.
2810Sstevel@tonic-gate  * k_toggleshifts should not appear in the k_up table.
2820Sstevel@tonic-gate  */
2830Sstevel@tonic-gate struct keyboard {
2840Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE
2850Sstevel@tonic-gate 	int		k_keymap_size;	/* Number of entries in keymaps */
2860Sstevel@tonic-gate 	keymap_entry_t	*k_normal;	/* Unshifted */
2870Sstevel@tonic-gate 	keymap_entry_t	*k_shifted;	/* Shifted */
2880Sstevel@tonic-gate 	keymap_entry_t	*k_caps;	/* Caps locked */
2890Sstevel@tonic-gate 	keymap_entry_t	*k_altgraph;	/* Alt Graph down */
2900Sstevel@tonic-gate 	keymap_entry_t	*k_numlock;	/* Num Lock down */
2910Sstevel@tonic-gate 	keymap_entry_t	*k_control;	/* Controlled */
2920Sstevel@tonic-gate 	keymap_entry_t	*k_up;		/* Key went up */
2930Sstevel@tonic-gate #else
2940Sstevel@tonic-gate 	struct keymap	*k_normal;	/* Unshifted */
2950Sstevel@tonic-gate 	struct keymap	*k_shifted;	/* Shifted */
2960Sstevel@tonic-gate 	struct keymap	*k_caps;	/* Caps locked */
2970Sstevel@tonic-gate 	struct keymap	*k_altgraph;	/* Alt Graph down */
2980Sstevel@tonic-gate 	struct keymap	*k_numlock;	/* Num Lock down */
2990Sstevel@tonic-gate 	struct keymap	*k_control;	/* Controlled */
3000Sstevel@tonic-gate 	struct keymap	*k_up;		/* Key went up */
3010Sstevel@tonic-gate #endif
3020Sstevel@tonic-gate 	int		k_idleshifts;	/* Shifts that keep across idle */
3030Sstevel@tonic-gate 	int		k_idlebuckys;	/* Bucky bits that keep across idle */
3040Sstevel@tonic-gate 	unsigned char	k_abort1;	/* 1st key of abort sequence */
3050Sstevel@tonic-gate 	unsigned char	k_abort1a;	/* alternate 1st key */
3060Sstevel@tonic-gate 	unsigned char	k_abort2;	/* 2nd key of abort sequence */
3070Sstevel@tonic-gate 	int		k_toggleshifts; /* Shifts that toggle on down from */
3080Sstevel@tonic-gate 					/* kbd and keep across idle */
3090Sstevel@tonic-gate 	struct exception_map *k_except;	/* Oddball cases */
310*3505Sqz150045 	unsigned char	k_newabort1;	/* 1st key of new abort sequence */
311*3505Sqz150045 	unsigned char	k_newabort1a;	/* alternate 1st key */
312*3505Sqz150045 	unsigned char	k_newabort2;	/* 2nd key of new abort sequence */
3130Sstevel@tonic-gate };
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate /*
3160Sstevel@tonic-gate  * Define the compose sequence structure.  First and second
3170Sstevel@tonic-gate  * ASCII chars of 0 indicate the end of the table.
3180Sstevel@tonic-gate  */
3190Sstevel@tonic-gate struct compose_sequence_t {
3200Sstevel@tonic-gate 	unsigned char	first;	/* first ASCII char after COMPOSE key */
3210Sstevel@tonic-gate 	unsigned char	second; /* second ASCII char after COMPOSE key */
3220Sstevel@tonic-gate 	unsigned char	iso;	/* equivalent ISO code */
3230Sstevel@tonic-gate };
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate /*
3260Sstevel@tonic-gate  * Define the floating accent sequence structure.
3270Sstevel@tonic-gate  */
3280Sstevel@tonic-gate struct fltaccent_sequence_t {
3290Sstevel@tonic-gate 	unsigned short	fa_entry;	/* floating accent keymap entry */
3300Sstevel@tonic-gate 	unsigned char	ascii;		/* ASCII char after FA-type key */
3310Sstevel@tonic-gate 	unsigned char	iso;		/* equivalent ISO code */
3320Sstevel@tonic-gate };
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate /*
3350Sstevel@tonic-gate  * The "special" entries' top 4 bits are defined below.	 Generally they are
3360Sstevel@tonic-gate  * used with a 4-bit parameter (such as a bit number) in the low 4 bits.
3370Sstevel@tonic-gate  * The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ascii
3380Sstevel@tonic-gate  * characters.	They are not special cased, but just normal cased.
3390Sstevel@tonic-gate  */
3400Sstevel@tonic-gate 
3410Sstevel@tonic-gate #define	SHIFTKEYS	0x100	/* thru 0x10F.	This key helps to determine */
3420Sstevel@tonic-gate 				/* the translation table used.	The bit */
3430Sstevel@tonic-gate 				/* position of its bit in "shiftmask" */
3440Sstevel@tonic-gate 				/* is added to the entry, eg */
3450Sstevel@tonic-gate 				/* SHIFTKEYS+LEFTCTRL.	When this entry is */
3460Sstevel@tonic-gate 				/* invoked, the bit in "shiftmask" is */
3470Sstevel@tonic-gate 				/* toggled.  Depending which tables you put */
3480Sstevel@tonic-gate 				/* it in, this works well for hold-down */
3490Sstevel@tonic-gate 				/* keys or press-on, press-off keys.  */
3500Sstevel@tonic-gate #define	BUCKYBITS	0x200	/* thru 0x20F.	This key determines the state */
3510Sstevel@tonic-gate 				/* of one of the "bucky" bits above the */
3520Sstevel@tonic-gate 				/* returned ASCII character.  This is */
3530Sstevel@tonic-gate 				/* basically a way to pass mode-key-up/down */
3540Sstevel@tonic-gate 				/* information back to the caller with each */
3550Sstevel@tonic-gate 				/* "real" key depressed.  The concept, and */
3560Sstevel@tonic-gate 				/* name "bucky" (derivation unknown) comes */
3570Sstevel@tonic-gate 				/* from the MIT/SAIL "TV" system...they had */
3580Sstevel@tonic-gate 				/* TOP, META, CTRL, and a few other bucky */
3590Sstevel@tonic-gate 				/* bits.  The bit position of its bit in */
3600Sstevel@tonic-gate 				/* "buckybits", minus 7, is added to the */
3610Sstevel@tonic-gate 				/* entry; eg bit 0x00000400 is BUCKYBITS+3. */
3620Sstevel@tonic-gate 				/* The "-7" prevents us from messing up the */
3630Sstevel@tonic-gate 				/* ASCII char, and gives us 16 useful bucky */
3640Sstevel@tonic-gate 				/* bits.  When this entry is invoked, */
3650Sstevel@tonic-gate 				/* the designated bit in "buckybits" is */
3660Sstevel@tonic-gate 				/* toggled.  Depending which tables you put */
3670Sstevel@tonic-gate 				/* it in, this works well for hold-down */
3680Sstevel@tonic-gate 				/* keys or press-on, press-off keys.  */
3690Sstevel@tonic-gate #define	FUNNY		0x300	/* thru 0x30F.	This key does one of 16 funny */
3700Sstevel@tonic-gate 				/* things based on the low 4 bits: */
3710Sstevel@tonic-gate #define	NOP		0x300	/* This key does nothing. */
3720Sstevel@tonic-gate #define	OOPS		0x301	/* This key exists but is undefined. */
3730Sstevel@tonic-gate #define	HOLE		0x302	/* This key does not exist on the keyboard. */
3740Sstevel@tonic-gate 				/* Its position code should never be */
3750Sstevel@tonic-gate 				/* generated.  This indicates a software/ */
3760Sstevel@tonic-gate 				/* hardware mismatch, or bugs. */
3770Sstevel@tonic-gate #define	RESET		0x306	/* Kbd was just reset */
3780Sstevel@tonic-gate #define	ERROR		0x307	/* Kbd just detected an internal error */
3790Sstevel@tonic-gate #define	IDLE		0x308	/* Kbd is idle (no keys down) */
3800Sstevel@tonic-gate #define	COMPOSE		0x309	/* This key is the Compose key. */
3810Sstevel@tonic-gate #define	NONL		0x30A	/* This key not affected by Num Lock */
3820Sstevel@tonic-gate /* Combinations 0x30B to 0x30F are reserved for non-parameterized functions */
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #define	FA_CLASS	0x400	/* thru 0x40F.	These are for "floating */
3850Sstevel@tonic-gate 				/* accent" characters.	The low-order 4 bits */
3860Sstevel@tonic-gate 				/* select one of those characters. */
3870Sstevel@tonic-gate /* Definitions for the individual floating accents: */
3880Sstevel@tonic-gate #define	FA_UMLAUT	0x400	/* umlaut accent */
3890Sstevel@tonic-gate #define	FA_CFLEX	0x401	/* circumflex accent */
3900Sstevel@tonic-gate #define	FA_TILDE	0x402	/* tilde accent */
3910Sstevel@tonic-gate #define	FA_CEDILLA	0x403	/* cedilla accent */
3920Sstevel@tonic-gate #define	FA_ACUTE	0x404	/* acute accent */
3930Sstevel@tonic-gate #define	FA_GRAVE	0x405	/* grave accent */
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate #define	STRING		0x500	/* thru 0x50F.	The low-order 4 bits index */
3960Sstevel@tonic-gate 				/* a table select a string to be returned, */
3970Sstevel@tonic-gate 				/* char by char.  Each entry the table is */
3980Sstevel@tonic-gate 				/* null terminated. */
3990Sstevel@tonic-gate #define	KTAB_STRLEN	10	/* Maximum string length (including null) */
4000Sstevel@tonic-gate /* Definitions for the individual string numbers: */
4010Sstevel@tonic-gate #define	HOMEARROW	0x00
4020Sstevel@tonic-gate #define	UPARROW		0x01
4030Sstevel@tonic-gate #define	DOWNARROW	0x02
4040Sstevel@tonic-gate #define	LEFTARROW	0x03
4050Sstevel@tonic-gate #define	RIGHTARROW	0x04
4060Sstevel@tonic-gate /* string numbers 5 thru F are available to users making custom entries */
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate /*
4090Sstevel@tonic-gate  * In the following function key groupings, the low-order 4 bits indicate
4100Sstevel@tonic-gate  * the function key number within the group, and the next 4 bits indicate
4110Sstevel@tonic-gate  * the group.
4120Sstevel@tonic-gate  */
4130Sstevel@tonic-gate #define	FUNCKEYS	0x600
4140Sstevel@tonic-gate #define	LEFTFUNC	0x600	/* thru 0x60F.	The "left" group. */
4150Sstevel@tonic-gate #define	RIGHTFUNC	0x610	/* thru 0x61F.	The "right" group. */
4160Sstevel@tonic-gate #define	TOPFUNC		0x620	/* thru 0x62F.	The "top" group. */
4170Sstevel@tonic-gate #define	BOTTOMFUNC	0x630	/* thru 0x63F.	The "bottom" group. */
4180Sstevel@tonic-gate #define	LF(n)		(LEFTFUNC+(n)-1)
4190Sstevel@tonic-gate #define	RF(n)		(RIGHTFUNC+(n)-1)
4200Sstevel@tonic-gate #define	TF(n)		(TOPFUNC+(n)-1)
4210Sstevel@tonic-gate #define	BF(n)		(BOTTOMFUNC+(n)-1)
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate /*
4240Sstevel@tonic-gate  * The actual keyboard positions may not be on the left/right/top/bottom
4250Sstevel@tonic-gate  * of the physical keyboard (although they usually are).
4260Sstevel@tonic-gate  * What is important is that we have reserved 64 keys for function keys.
4270Sstevel@tonic-gate  *
4280Sstevel@tonic-gate  * Normally, striking a function key will cause the following escape sequence
4290Sstevel@tonic-gate  * to be sent through the character stream:
4300Sstevel@tonic-gate  *	ESC[0..9z
4310Sstevel@tonic-gate  * where ESC is a single escape character and 0..9 indicate some number of
4320Sstevel@tonic-gate  * digits needed to encode the function key as a decimal number.
4330Sstevel@tonic-gate  */
4340Sstevel@tonic-gate #define	PADKEYS		0x700
4350Sstevel@tonic-gate #define	PADEQUAL	0x700		/* keypad = */
4360Sstevel@tonic-gate #define	PADSLASH	0x701		/* keypad / */
4370Sstevel@tonic-gate #define	PADSTAR		0x702		/* keypad * */
4380Sstevel@tonic-gate #define	PADMINUS	0x703		/* keypad - */
4390Sstevel@tonic-gate #define	PADSEP		0x704		/* keypad,  */
4400Sstevel@tonic-gate #define	PAD7		0x705		/* keypad 7 */
4410Sstevel@tonic-gate #define	PAD8		0x706		/* keypad 8 */
4420Sstevel@tonic-gate #define	PAD9		0x707		/* keypad 9 */
4430Sstevel@tonic-gate #define	PADPLUS		0x708		/* keypad + */
4440Sstevel@tonic-gate #define	PAD4		0x709		/* keypad 4 */
4450Sstevel@tonic-gate #define	PAD5		0x70A		/* keypad 5 */
4460Sstevel@tonic-gate #define	PAD6		0x70B		/* keypad 6 */
4470Sstevel@tonic-gate #define	PAD1		0x70C		/* keypad 1 */
4480Sstevel@tonic-gate #define	PAD2		0x70D		/* keypad 2 */
4490Sstevel@tonic-gate #define	PAD3		0x70E		/* keypad 3 */
4500Sstevel@tonic-gate #define	PAD0		0x70F		/* keypad 0 */
4510Sstevel@tonic-gate #define	PADDOT		0x710		/* keypad . */
4520Sstevel@tonic-gate #define	PADENTER	0x711		/* keypad Enter */
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate #ifdef	__cplusplus
4550Sstevel@tonic-gate }
4560Sstevel@tonic-gate #endif
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate #endif	/* _SYS_KBD_H */
459