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