xref: /titanic_52/usr/src/uts/common/sys/kbd.h (revision e4603304e8bd084dd25a0dbafdd438ac250d5f56)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*e4603304Sqz150045  * Common Development and Distribution License (the "License").
6*e4603304Sqz150045  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*e4603304Sqz150045  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*e4603304Sqz150045  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_KBD_H
277c478bd9Sstevel@tonic-gate #define	_SYS_KBD_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS4.0 1.18 */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * Following #defines are related to the older keyboards which
377c478bd9Sstevel@tonic-gate  * are no longer supported by kb module.  The #defines ane left
387c478bd9Sstevel@tonic-gate  * for older programs to still compile.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate #define	KB_KLUNK	0x00		/* Micro Switch 103SD32-2 */
417c478bd9Sstevel@tonic-gate #define	KB_VT100	0x01		/* Keytronics VT100 compatible */
427c478bd9Sstevel@tonic-gate #define	KB_SUN2		0x02		/* Sun-2 custom keyboard */
437c478bd9Sstevel@tonic-gate #define	KB_VT220	0x81		/* Emulation VT220 */
447c478bd9Sstevel@tonic-gate #define	KB_VT220I	0x82		/* International VT220 Emulation */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	NOTPRESENT	0xFF		/* Keyboard is not plugged in */
477c478bd9Sstevel@tonic-gate #define	KBD_CMD_LED1	0x04		/* Turn on LED 1 for Sun-2 */
487c478bd9Sstevel@tonic-gate #define	KBD_CMD_NOLED1	0x05		/* Turn off LED 1 for Sun-2 */
497c478bd9Sstevel@tonic-gate #define	KBD_CMD_LED2	0x06		/* Turn on LED 2 for Sun-2 */
507c478bd9Sstevel@tonic-gate #define	KBD_CMD_NOLED2	0x07		/* Turn off LED 2 for Sun-2 */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #define	CTLSMASK	0x0100		/* Set if ^S was last keyed of ^S, ^Q */
537c478bd9Sstevel@tonic-gate 					/* determines which NOSCROLL sends. */
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate #define	NOSCROLL	0x303	/* This key alternately sends ^S or ^Q */
567c478bd9Sstevel@tonic-gate #define	CTRLS		0x304	/* This sends ^S and lets NOSCROLL know */
577c478bd9Sstevel@tonic-gate #define	CTRLQ		0x305	/* This sends ^Q and lets NOSCROLL know */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * Following are the only keyboard types supported by kb module.
627c478bd9Sstevel@tonic-gate  * (Type 5, Hobo, US101A are also supported but they report
637c478bd9Sstevel@tonic-gate  * themselves as Type 4 keyboard with a different layout id.)
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate #define	KB_SUN3		3		/* Type 3 Sun keyboard */
667c478bd9Sstevel@tonic-gate #define	KB_SUN4		4		/* Type 4 Sun keyboard */
677c478bd9Sstevel@tonic-gate #define	KB_USB		6		/* USB keyboard */
687c478bd9Sstevel@tonic-gate #define	KB_PC		101		/* Type 101 AT keyboard */
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #define	KB_ASCII	0x0F		/* Ascii terminal masquerading as kbd */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * This structure is used to enumerate the supported keyboard types.
747c478bd9Sstevel@tonic-gate  * The array of these is terminated by an entry with a NULL table entry.
757c478bd9Sstevel@tonic-gate  * The first entry is used if none match.
767c478bd9Sstevel@tonic-gate  */
777c478bd9Sstevel@tonic-gate struct keyboards {
787c478bd9Sstevel@tonic-gate 	int		id;	/* Keyboard type, per KIOCTYPE */
797c478bd9Sstevel@tonic-gate 	struct keyboard	*table;	/* Keyboard table to use. */
807c478bd9Sstevel@tonic-gate };
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Various special characters that might show up on the port
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate #define	IDLEKEY		0x7F		/* Keyboard is idle; no keys down */
867c478bd9Sstevel@tonic-gate #define	ERRORKEY	0x7E		/* Keyboard detected an error */
877c478bd9Sstevel@tonic-gate #define	RESETKEY	0xFF		/* Keyboard was just reset */
887c478bd9Sstevel@tonic-gate #define	LAYOUTKEY	0xFE		/* Keyboard layout byte follows */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	PRESSED		0x00		/* 0x80 bit off: key was pressed */
917c478bd9Sstevel@tonic-gate #define	RELEASED	0x80		/* 0x80 bit on : key was released */
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Commands to the Sun-3 keyboard.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate #define	KBD_CMD_RESET		0x01	/* Reset keyboard as if power-up */
977c478bd9Sstevel@tonic-gate #define	KBD_CMD_BELL		0x02	/* Turn on the bell */
987c478bd9Sstevel@tonic-gate #define	KBD_CMD_NOBELL		0x03	/* Turn off the bell */
997c478bd9Sstevel@tonic-gate #define	KBD_CMD_CLICK		0x0A	/* Turn on the click annunciator */
1007c478bd9Sstevel@tonic-gate #define	KBD_CMD_NOCLICK		0x0B	/* Turn off the click annunciator */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Commands to the Type 4 keyboard, in addition to those above.
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate #define	KBD_CMD_AUTOTEST	0x0C	/* Initiate test sequence */
1067c478bd9Sstevel@tonic-gate #define	KBD_CMD_SETLED		0x0E	/* Set keyboard LED's */
1077c478bd9Sstevel@tonic-gate #define	KBD_CMD_GETLAYOUT	0x0F	/* Request that keyboard indicate */
1087c478bd9Sstevel@tonic-gate 					/* layout */
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * Type 4 keyboard LED masks (used to set LED's)
1117c478bd9Sstevel@tonic-gate  */
1127c478bd9Sstevel@tonic-gate #define	LED_NUM_LOCK	0x1
1137c478bd9Sstevel@tonic-gate #define	LED_COMPOSE	0x2
1147c478bd9Sstevel@tonic-gate #define	LED_SCROLL_LOCK 0x4
1157c478bd9Sstevel@tonic-gate #define	LED_CAPS_LOCK	0x8
1167c478bd9Sstevel@tonic-gate #define	LED_KANA	0x10		/* Valid only on Japanese layout */
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate  * Software related definitions
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * These are the states that the keyboard scanner can be in.
1237c478bd9Sstevel@tonic-gate  *
1247c478bd9Sstevel@tonic-gate  * It starts out in NORMAL state.
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate #define	NORMAL		0		/* The usual (ho, hum) */
1277c478bd9Sstevel@tonic-gate #define	ABORT1		1		/* Got KEYABORT1 */
1287c478bd9Sstevel@tonic-gate #define	COMPOSE1	2		/* Got COMPOSE */
1297c478bd9Sstevel@tonic-gate #define	COMPOSE2	3		/* Got COMPOSE plus first key */
1307c478bd9Sstevel@tonic-gate #define	FLTACCENT	4		/* Got floating accent key */
131*e4603304Sqz150045 #define	NEWABORT1	5		/* Got NEW KEYABORT1 */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * Size of ASCII set as used in compose handling.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate #define	ASCII_SET_SIZE	128
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * These are how you can have your input translated.
1407c478bd9Sstevel@tonic-gate  * TR_EVENT means that each keystroke is sent as a firm event.
1417c478bd9Sstevel@tonic-gate  * TR_UNTRANS_EVENT also sends a firm event for each up / down transition,
1427c478bd9Sstevel@tonic-gate  * but the value is untranslated: the event id is the key station; the
1437c478bd9Sstevel@tonic-gate  * value indicates whether the transition was up or down; the value of the
1447c478bd9Sstevel@tonic-gate  * shift-mask is undefined.
1457c478bd9Sstevel@tonic-gate  */
1467c478bd9Sstevel@tonic-gate #define	TR_NONE		  0
1477c478bd9Sstevel@tonic-gate #define	TR_ASCII	  1
1487c478bd9Sstevel@tonic-gate #define	TR_EVENT	  2
1497c478bd9Sstevel@tonic-gate #define	TR_UNTRANS_EVENT  3
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * These bits can appear in the result of TR_NONE & TR_UNTRANS_EVENT getkey()s.
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate #define	BUILDKEY(key, state)	(key | state)
1557c478bd9Sstevel@tonic-gate #define	STATEOF(key)	((key) & RELEASED)	/* 0 = key down, !=0 = key up */
1567c478bd9Sstevel@tonic-gate #define	KEYOF(key)	((key) & ~RELEASED)	/* The key number that moved */
1577c478bd9Sstevel@tonic-gate #define	NOKEY		(-1)		/* The argument was 0, and no key was */
1587c478bd9Sstevel@tonic-gate 					/* depressed.  They were all elated. */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1617c478bd9Sstevel@tonic-gate  * "Bucky" bits.  These are bits for mode keys.	 The META bit is ORed into the
1627c478bd9Sstevel@tonic-gate  * result of TR_ASCII getkey()s, and can be ORed into the result of TR_EVENT
1637c478bd9Sstevel@tonic-gate  * getkey()s for backwards compatibility.
1647c478bd9Sstevel@tonic-gate  * (NOKEY can also appear if no keypress was queued up.)
1657c478bd9Sstevel@tonic-gate  */
1667c478bd9Sstevel@tonic-gate #define	METABIT		0		/* Meta key depressed with key */
1677c478bd9Sstevel@tonic-gate #define	METAMASK	0x000080
1687c478bd9Sstevel@tonic-gate #define	SYSTEMBIT	1		/* Upper left key was down w/key */
1697c478bd9Sstevel@tonic-gate #define	SYSTEMMASK	0x000100
1707c478bd9Sstevel@tonic-gate /* other "bucky" bits can be defined at will.  See "BUCKYBITS" below. */
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate /*
1737c478bd9Sstevel@tonic-gate  * This defines the bit positions used within "shiftmask" to
1747c478bd9Sstevel@tonic-gate  * indicate the "pressed" (1) or "released" (0) state of shift keys.
1757c478bd9Sstevel@tonic-gate  * Both the bit numbers, and the aggregate masks, are defined.
1767c478bd9Sstevel@tonic-gate  *
1777c478bd9Sstevel@tonic-gate  * The "UPMASK" is a minor kludge.  Since whether the key is going
1787c478bd9Sstevel@tonic-gate  * up or down determines the translation table (just as the shift
1797c478bd9Sstevel@tonic-gate  * keys' positions do), we OR it with "shiftmask" to get "tempmask",
1807c478bd9Sstevel@tonic-gate  * which is the mask which is actually used to determine the
1817c478bd9Sstevel@tonic-gate  * translation table to use.  Don't reassign 0x0080 for anything
1827c478bd9Sstevel@tonic-gate  * else, or we'll have to shift and such to squeeze in UPMASK,
1837c478bd9Sstevel@tonic-gate  * since it comes in from the hardware as 0x80.
1847c478bd9Sstevel@tonic-gate  */
1857c478bd9Sstevel@tonic-gate #define	CAPSLOCK	0		/* Caps Lock key */
1867c478bd9Sstevel@tonic-gate #define	CAPSMASK	0x0001
1877c478bd9Sstevel@tonic-gate #define	SHIFTLOCK	1		/* Shift Lock key */
1887c478bd9Sstevel@tonic-gate #define	LEFTSHIFT	2		/* Left-hand shift key */
1897c478bd9Sstevel@tonic-gate #define	RIGHTSHIFT	3		/* Right-hand shift key */
1907c478bd9Sstevel@tonic-gate #define	SHIFTMASK	0x000E
1917c478bd9Sstevel@tonic-gate #define	LEFTCTRL	4		/* Left-hand (or only) control key */
1927c478bd9Sstevel@tonic-gate #define	RIGHTCTRL	5		/* Right-hand control key */
1937c478bd9Sstevel@tonic-gate #define	CTRLMASK	0x0030
1947c478bd9Sstevel@tonic-gate /*	META		6		Meta keys */
1957c478bd9Sstevel@tonic-gate /*	META_SHIFT_MASK 0x0040		reserved */
1967c478bd9Sstevel@tonic-gate /*	TOP		7		do not use! */
1977c478bd9Sstevel@tonic-gate /*	TOPMASK		0x0080		UPMASK in keyboard driver */
1987c478bd9Sstevel@tonic-gate /*	CMD		8		reserved */
1997c478bd9Sstevel@tonic-gate /*	CMDMASK		0x0100		reserved */
2007c478bd9Sstevel@tonic-gate #define	ALTGRAPH	9		/* Alt Graph key */
2017c478bd9Sstevel@tonic-gate #define	ALTGRAPHMASK	0x0200
2027c478bd9Sstevel@tonic-gate #define	ALT		10		/* Left (or only) Alt key */
2037c478bd9Sstevel@tonic-gate #define	LEFTALT		10		/* Left Alt key */
2047c478bd9Sstevel@tonic-gate #define	ALTMASK		0x1400
2057c478bd9Sstevel@tonic-gate #define	NUMLOCK		11		/* Num Lock key */
2067c478bd9Sstevel@tonic-gate #define	NUMLOCKMASK	0x0800
2077c478bd9Sstevel@tonic-gate #define	RIGHTALT	12		/* Right Alt key */
2087c478bd9Sstevel@tonic-gate #define	UPMASK		0x0080
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate /*
2117c478bd9Sstevel@tonic-gate  * This defines the format of translation tables.
2127c478bd9Sstevel@tonic-gate  *
2137c478bd9Sstevel@tonic-gate  * A translation table is KEYMAP_SIZE "entries", each of which is 2 bytes
2147c478bd9Sstevel@tonic-gate  * (unsigned shorts).  The top 8 bits of each entry are decoded by
2157c478bd9Sstevel@tonic-gate  * a case statement in getkey.c.  If the entry is less than 0x100, it
2167c478bd9Sstevel@tonic-gate  * is sent out as an EUC character (possibly with bucky bits
2177c478bd9Sstevel@tonic-gate  * OR-ed in).  "Special" entries are 0x100 or greater, and
2187c478bd9Sstevel@tonic-gate  * invoke more complicated actions.
2197c478bd9Sstevel@tonic-gate  *
2207c478bd9Sstevel@tonic-gate  * The KEYMAP_SIZE is dependent upon the keyboard type.  For example, the
2217c478bd9Sstevel@tonic-gate  * Sun Type 4/5 keyboards have a KEYMAP_SIZE of 128 where a USB keyboard
2227c478bd9Sstevel@tonic-gate  * has a KEYMAP_SIZE of 255.  Instead of defining a KEYMAP_SIZE per
2237c478bd9Sstevel@tonic-gate  * keyboard type, a keyboard specific module/driver may supply the value
2247c478bd9Sstevel@tonic-gate  * at run time by defining the KEYMAP_SIZE_VARIABLE and filling in the
2257c478bd9Sstevel@tonic-gate  * keyboard struct appropriately.
2267c478bd9Sstevel@tonic-gate  */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate typedef unsigned short keymap_entry_t;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate #else
2337c478bd9Sstevel@tonic-gate #define	KEYMAP_SIZE	128
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate struct keymap {
2367c478bd9Sstevel@tonic-gate 	unsigned short	keymap[KEYMAP_SIZE];	/* maps keycodes to actions */
2377c478bd9Sstevel@tonic-gate };
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #endif
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate /*
2427c478bd9Sstevel@tonic-gate  * This structure is used for "exception" cases for key sequences that
2437c478bd9Sstevel@tonic-gate  * we want to map, that should not be handled by keymap entries (For
2447c478bd9Sstevel@tonic-gate  * example: using Control-Shift-F1 on PC's for the compose key).
2457c478bd9Sstevel@tonic-gate  */
2467c478bd9Sstevel@tonic-gate struct exception_map {
2477c478bd9Sstevel@tonic-gate 	/*
2487c478bd9Sstevel@tonic-gate 	 * these are the modifier keys that we "care" about
2497c478bd9Sstevel@tonic-gate 	 */
2507c478bd9Sstevel@tonic-gate 	unsigned int exc_care;
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate 	/*
2537c478bd9Sstevel@tonic-gate 	 * This is the mask of modifier keys that we want to match
2547c478bd9Sstevel@tonic-gate 	 */
2557c478bd9Sstevel@tonic-gate 	unsigned int exc_mask;
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	/*
2587c478bd9Sstevel@tonic-gate 	 * This is the key that we want to match.
2597c478bd9Sstevel@tonic-gate 	 */
2607c478bd9Sstevel@tonic-gate 	int exc_key;
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	/*
2637c478bd9Sstevel@tonic-gate 	 * This is our translated version of the matching sequence.
2647c478bd9Sstevel@tonic-gate 	 */
2657c478bd9Sstevel@tonic-gate 	unsigned short exc_entry;
2667c478bd9Sstevel@tonic-gate };
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate /*
2697c478bd9Sstevel@tonic-gate  * A keyboard is defined by its keymaps and what state it resets at idle.
2707c478bd9Sstevel@tonic-gate  *
2717c478bd9Sstevel@tonic-gate  * The masks k_idleshifts and k_idlebuckys are AND-ed with the current
2727c478bd9Sstevel@tonic-gate  * state of  shiftmask	and  buckybits	when a "keyboard idle" code
2737c478bd9Sstevel@tonic-gate  * is received.	 This ensures that where we "think" the shift & bucky
2747c478bd9Sstevel@tonic-gate  * keys are, more accurately reflects where they really are, since the
2757c478bd9Sstevel@tonic-gate  * keyboard knows better than us.  However, some keyboards don't know
2767c478bd9Sstevel@tonic-gate  * about shift states that should be remembered across idles.  Such
2777c478bd9Sstevel@tonic-gate  * shifts are described by k_toggleshifts.  k_toggleshifts are used to
2787c478bd9Sstevel@tonic-gate  * identify such shifts.  A toggle shift state is maintained separately
2797c478bd9Sstevel@tonic-gate  * from the general shift state.  The toggle shift state is OR-ed
2807c478bd9Sstevel@tonic-gate  * with the state general shift state when an idle is received.
2817c478bd9Sstevel@tonic-gate  * k_toggleshifts should not appear in the k_up table.
2827c478bd9Sstevel@tonic-gate  */
2837c478bd9Sstevel@tonic-gate struct keyboard {
2847c478bd9Sstevel@tonic-gate #ifdef KEYMAP_SIZE_VARIABLE
2857c478bd9Sstevel@tonic-gate 	int		k_keymap_size;	/* Number of entries in keymaps */
2867c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_normal;	/* Unshifted */
2877c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_shifted;	/* Shifted */
2887c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_caps;	/* Caps locked */
2897c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_altgraph;	/* Alt Graph down */
2907c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_numlock;	/* Num Lock down */
2917c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_control;	/* Controlled */
2927c478bd9Sstevel@tonic-gate 	keymap_entry_t	*k_up;		/* Key went up */
2937c478bd9Sstevel@tonic-gate #else
2947c478bd9Sstevel@tonic-gate 	struct keymap	*k_normal;	/* Unshifted */
2957c478bd9Sstevel@tonic-gate 	struct keymap	*k_shifted;	/* Shifted */
2967c478bd9Sstevel@tonic-gate 	struct keymap	*k_caps;	/* Caps locked */
2977c478bd9Sstevel@tonic-gate 	struct keymap	*k_altgraph;	/* Alt Graph down */
2987c478bd9Sstevel@tonic-gate 	struct keymap	*k_numlock;	/* Num Lock down */
2997c478bd9Sstevel@tonic-gate 	struct keymap	*k_control;	/* Controlled */
3007c478bd9Sstevel@tonic-gate 	struct keymap	*k_up;		/* Key went up */
3017c478bd9Sstevel@tonic-gate #endif
3027c478bd9Sstevel@tonic-gate 	int		k_idleshifts;	/* Shifts that keep across idle */
3037c478bd9Sstevel@tonic-gate 	int		k_idlebuckys;	/* Bucky bits that keep across idle */
3047c478bd9Sstevel@tonic-gate 	unsigned char	k_abort1;	/* 1st key of abort sequence */
3057c478bd9Sstevel@tonic-gate 	unsigned char	k_abort1a;	/* alternate 1st key */
3067c478bd9Sstevel@tonic-gate 	unsigned char	k_abort2;	/* 2nd key of abort sequence */
3077c478bd9Sstevel@tonic-gate 	int		k_toggleshifts; /* Shifts that toggle on down from */
3087c478bd9Sstevel@tonic-gate 					/* kbd and keep across idle */
3097c478bd9Sstevel@tonic-gate 	struct exception_map *k_except;	/* Oddball cases */
310*e4603304Sqz150045 	unsigned char	k_newabort1;	/* 1st key of new abort sequence */
311*e4603304Sqz150045 	unsigned char	k_newabort1a;	/* alternate 1st key */
312*e4603304Sqz150045 	unsigned char	k_newabort2;	/* 2nd key of new abort sequence */
3137c478bd9Sstevel@tonic-gate };
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate  * Define the compose sequence structure.  First and second
3177c478bd9Sstevel@tonic-gate  * ASCII chars of 0 indicate the end of the table.
3187c478bd9Sstevel@tonic-gate  */
3197c478bd9Sstevel@tonic-gate struct compose_sequence_t {
3207c478bd9Sstevel@tonic-gate 	unsigned char	first;	/* first ASCII char after COMPOSE key */
3217c478bd9Sstevel@tonic-gate 	unsigned char	second; /* second ASCII char after COMPOSE key */
3227c478bd9Sstevel@tonic-gate 	unsigned char	iso;	/* equivalent ISO code */
3237c478bd9Sstevel@tonic-gate };
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate /*
3267c478bd9Sstevel@tonic-gate  * Define the floating accent sequence structure.
3277c478bd9Sstevel@tonic-gate  */
3287c478bd9Sstevel@tonic-gate struct fltaccent_sequence_t {
3297c478bd9Sstevel@tonic-gate 	unsigned short	fa_entry;	/* floating accent keymap entry */
3307c478bd9Sstevel@tonic-gate 	unsigned char	ascii;		/* ASCII char after FA-type key */
3317c478bd9Sstevel@tonic-gate 	unsigned char	iso;		/* equivalent ISO code */
3327c478bd9Sstevel@tonic-gate };
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate /*
3357c478bd9Sstevel@tonic-gate  * The "special" entries' top 4 bits are defined below.	 Generally they are
3367c478bd9Sstevel@tonic-gate  * used with a 4-bit parameter (such as a bit number) in the low 4 bits.
3377c478bd9Sstevel@tonic-gate  * The bytes whose top 4 bits are 0x0 thru 0x7 happen to be ascii
3387c478bd9Sstevel@tonic-gate  * characters.	They are not special cased, but just normal cased.
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate #define	SHIFTKEYS	0x100	/* thru 0x10F.	This key helps to determine */
3427c478bd9Sstevel@tonic-gate 				/* the translation table used.	The bit */
3437c478bd9Sstevel@tonic-gate 				/* position of its bit in "shiftmask" */
3447c478bd9Sstevel@tonic-gate 				/* is added to the entry, eg */
3457c478bd9Sstevel@tonic-gate 				/* SHIFTKEYS+LEFTCTRL.	When this entry is */
3467c478bd9Sstevel@tonic-gate 				/* invoked, the bit in "shiftmask" is */
3477c478bd9Sstevel@tonic-gate 				/* toggled.  Depending which tables you put */
3487c478bd9Sstevel@tonic-gate 				/* it in, this works well for hold-down */
3497c478bd9Sstevel@tonic-gate 				/* keys or press-on, press-off keys.  */
3507c478bd9Sstevel@tonic-gate #define	BUCKYBITS	0x200	/* thru 0x20F.	This key determines the state */
3517c478bd9Sstevel@tonic-gate 				/* of one of the "bucky" bits above the */
3527c478bd9Sstevel@tonic-gate 				/* returned ASCII character.  This is */
3537c478bd9Sstevel@tonic-gate 				/* basically a way to pass mode-key-up/down */
3547c478bd9Sstevel@tonic-gate 				/* information back to the caller with each */
3557c478bd9Sstevel@tonic-gate 				/* "real" key depressed.  The concept, and */
3567c478bd9Sstevel@tonic-gate 				/* name "bucky" (derivation unknown) comes */
3577c478bd9Sstevel@tonic-gate 				/* from the MIT/SAIL "TV" system...they had */
3587c478bd9Sstevel@tonic-gate 				/* TOP, META, CTRL, and a few other bucky */
3597c478bd9Sstevel@tonic-gate 				/* bits.  The bit position of its bit in */
3607c478bd9Sstevel@tonic-gate 				/* "buckybits", minus 7, is added to the */
3617c478bd9Sstevel@tonic-gate 				/* entry; eg bit 0x00000400 is BUCKYBITS+3. */
3627c478bd9Sstevel@tonic-gate 				/* The "-7" prevents us from messing up the */
3637c478bd9Sstevel@tonic-gate 				/* ASCII char, and gives us 16 useful bucky */
3647c478bd9Sstevel@tonic-gate 				/* bits.  When this entry is invoked, */
3657c478bd9Sstevel@tonic-gate 				/* the designated bit in "buckybits" is */
3667c478bd9Sstevel@tonic-gate 				/* toggled.  Depending which tables you put */
3677c478bd9Sstevel@tonic-gate 				/* it in, this works well for hold-down */
3687c478bd9Sstevel@tonic-gate 				/* keys or press-on, press-off keys.  */
3697c478bd9Sstevel@tonic-gate #define	FUNNY		0x300	/* thru 0x30F.	This key does one of 16 funny */
3707c478bd9Sstevel@tonic-gate 				/* things based on the low 4 bits: */
3717c478bd9Sstevel@tonic-gate #define	NOP		0x300	/* This key does nothing. */
3727c478bd9Sstevel@tonic-gate #define	OOPS		0x301	/* This key exists but is undefined. */
3737c478bd9Sstevel@tonic-gate #define	HOLE		0x302	/* This key does not exist on the keyboard. */
3747c478bd9Sstevel@tonic-gate 				/* Its position code should never be */
3757c478bd9Sstevel@tonic-gate 				/* generated.  This indicates a software/ */
3767c478bd9Sstevel@tonic-gate 				/* hardware mismatch, or bugs. */
3777c478bd9Sstevel@tonic-gate #define	RESET		0x306	/* Kbd was just reset */
3787c478bd9Sstevel@tonic-gate #define	ERROR		0x307	/* Kbd just detected an internal error */
3797c478bd9Sstevel@tonic-gate #define	IDLE		0x308	/* Kbd is idle (no keys down) */
3807c478bd9Sstevel@tonic-gate #define	COMPOSE		0x309	/* This key is the Compose key. */
3817c478bd9Sstevel@tonic-gate #define	NONL		0x30A	/* This key not affected by Num Lock */
3827c478bd9Sstevel@tonic-gate /* Combinations 0x30B to 0x30F are reserved for non-parameterized functions */
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate #define	FA_CLASS	0x400	/* thru 0x40F.	These are for "floating */
3857c478bd9Sstevel@tonic-gate 				/* accent" characters.	The low-order 4 bits */
3867c478bd9Sstevel@tonic-gate 				/* select one of those characters. */
3877c478bd9Sstevel@tonic-gate /* Definitions for the individual floating accents: */
3887c478bd9Sstevel@tonic-gate #define	FA_UMLAUT	0x400	/* umlaut accent */
3897c478bd9Sstevel@tonic-gate #define	FA_CFLEX	0x401	/* circumflex accent */
3907c478bd9Sstevel@tonic-gate #define	FA_TILDE	0x402	/* tilde accent */
3917c478bd9Sstevel@tonic-gate #define	FA_CEDILLA	0x403	/* cedilla accent */
3927c478bd9Sstevel@tonic-gate #define	FA_ACUTE	0x404	/* acute accent */
3937c478bd9Sstevel@tonic-gate #define	FA_GRAVE	0x405	/* grave accent */
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate #define	STRING		0x500	/* thru 0x50F.	The low-order 4 bits index */
3967c478bd9Sstevel@tonic-gate 				/* a table select a string to be returned, */
3977c478bd9Sstevel@tonic-gate 				/* char by char.  Each entry the table is */
3987c478bd9Sstevel@tonic-gate 				/* null terminated. */
3997c478bd9Sstevel@tonic-gate #define	KTAB_STRLEN	10	/* Maximum string length (including null) */
4007c478bd9Sstevel@tonic-gate /* Definitions for the individual string numbers: */
4017c478bd9Sstevel@tonic-gate #define	HOMEARROW	0x00
4027c478bd9Sstevel@tonic-gate #define	UPARROW		0x01
4037c478bd9Sstevel@tonic-gate #define	DOWNARROW	0x02
4047c478bd9Sstevel@tonic-gate #define	LEFTARROW	0x03
4057c478bd9Sstevel@tonic-gate #define	RIGHTARROW	0x04
4067c478bd9Sstevel@tonic-gate /* string numbers 5 thru F are available to users making custom entries */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * In the following function key groupings, the low-order 4 bits indicate
4107c478bd9Sstevel@tonic-gate  * the function key number within the group, and the next 4 bits indicate
4117c478bd9Sstevel@tonic-gate  * the group.
4127c478bd9Sstevel@tonic-gate  */
4137c478bd9Sstevel@tonic-gate #define	FUNCKEYS	0x600
4147c478bd9Sstevel@tonic-gate #define	LEFTFUNC	0x600	/* thru 0x60F.	The "left" group. */
4157c478bd9Sstevel@tonic-gate #define	RIGHTFUNC	0x610	/* thru 0x61F.	The "right" group. */
4167c478bd9Sstevel@tonic-gate #define	TOPFUNC		0x620	/* thru 0x62F.	The "top" group. */
4177c478bd9Sstevel@tonic-gate #define	BOTTOMFUNC	0x630	/* thru 0x63F.	The "bottom" group. */
4187c478bd9Sstevel@tonic-gate #define	LF(n)		(LEFTFUNC+(n)-1)
4197c478bd9Sstevel@tonic-gate #define	RF(n)		(RIGHTFUNC+(n)-1)
4207c478bd9Sstevel@tonic-gate #define	TF(n)		(TOPFUNC+(n)-1)
4217c478bd9Sstevel@tonic-gate #define	BF(n)		(BOTTOMFUNC+(n)-1)
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate /*
4247c478bd9Sstevel@tonic-gate  * The actual keyboard positions may not be on the left/right/top/bottom
4257c478bd9Sstevel@tonic-gate  * of the physical keyboard (although they usually are).
4267c478bd9Sstevel@tonic-gate  * What is important is that we have reserved 64 keys for function keys.
4277c478bd9Sstevel@tonic-gate  *
4287c478bd9Sstevel@tonic-gate  * Normally, striking a function key will cause the following escape sequence
4297c478bd9Sstevel@tonic-gate  * to be sent through the character stream:
4307c478bd9Sstevel@tonic-gate  *	ESC[0..9z
4317c478bd9Sstevel@tonic-gate  * where ESC is a single escape character and 0..9 indicate some number of
4327c478bd9Sstevel@tonic-gate  * digits needed to encode the function key as a decimal number.
4337c478bd9Sstevel@tonic-gate  */
4347c478bd9Sstevel@tonic-gate #define	PADKEYS		0x700
4357c478bd9Sstevel@tonic-gate #define	PADEQUAL	0x700		/* keypad = */
4367c478bd9Sstevel@tonic-gate #define	PADSLASH	0x701		/* keypad / */
4377c478bd9Sstevel@tonic-gate #define	PADSTAR		0x702		/* keypad * */
4387c478bd9Sstevel@tonic-gate #define	PADMINUS	0x703		/* keypad - */
4397c478bd9Sstevel@tonic-gate #define	PADSEP		0x704		/* keypad,  */
4407c478bd9Sstevel@tonic-gate #define	PAD7		0x705		/* keypad 7 */
4417c478bd9Sstevel@tonic-gate #define	PAD8		0x706		/* keypad 8 */
4427c478bd9Sstevel@tonic-gate #define	PAD9		0x707		/* keypad 9 */
4437c478bd9Sstevel@tonic-gate #define	PADPLUS		0x708		/* keypad + */
4447c478bd9Sstevel@tonic-gate #define	PAD4		0x709		/* keypad 4 */
4457c478bd9Sstevel@tonic-gate #define	PAD5		0x70A		/* keypad 5 */
4467c478bd9Sstevel@tonic-gate #define	PAD6		0x70B		/* keypad 6 */
4477c478bd9Sstevel@tonic-gate #define	PAD1		0x70C		/* keypad 1 */
4487c478bd9Sstevel@tonic-gate #define	PAD2		0x70D		/* keypad 2 */
4497c478bd9Sstevel@tonic-gate #define	PAD3		0x70E		/* keypad 3 */
4507c478bd9Sstevel@tonic-gate #define	PAD0		0x70F		/* keypad 0 */
4517c478bd9Sstevel@tonic-gate #define	PADDOT		0x710		/* keypad . */
4527c478bd9Sstevel@tonic-gate #define	PADENTER	0x711		/* keypad Enter */
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4557c478bd9Sstevel@tonic-gate }
4567c478bd9Sstevel@tonic-gate #endif
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate #endif	/* _SYS_KBD_H */
459