xref: /dragonfly/sys/sys/kbio.h (revision 984263bc)
1 /*-
2  * $FreeBSD: src/sys/sys/kbio.h,v 1.5.2.1 2000/10/29 16:59:32 dwmalone Exp $
3  */
4 
5 #ifndef	_SYS_KBIO_H_
6 #define	_SYS_KBIO_H_
7 
8 #ifndef _KERNEL
9 #include <sys/types.h>
10 #endif
11 #include <sys/ioccom.h>
12 
13 /* get/set keyboard I/O mode */
14 #define K_RAW		0		/* keyboard returns scancodes	*/
15 #define K_XLATE		1		/* keyboard returns ascii 	*/
16 #define K_CODE		2		/* keyboard returns keycodes 	*/
17 #define KDGKBMODE 	_IOR('K', 6, int)
18 #define KDSKBMODE 	_IO('K', 7 /*, int */)
19 
20 /* make tone */
21 #define KDMKTONE	_IO('K', 8 /*, int */)
22 
23 /* see console.h for the definitions of the following ioctls */
24 #if notdef
25 #define KDGETMODE	_IOR('K', 9, int)
26 #define KDSETMODE	_IO('K', 10 /*, int */)
27 #define KDSBORDER	_IO('K', 13 /*, int */)
28 #endif
29 
30 /* get/set keyboard lock state */
31 #define CLKED		1		/* Caps locked			*/
32 #define NLKED		2		/* Num locked			*/
33 #define SLKED		4		/* Scroll locked		*/
34 #define ALKED		8		/* AltGr locked			*/
35 #define LOCK_MASK	(CLKED | NLKED | SLKED | ALKED)
36 #define KDGKBSTATE	_IOR('K', 19, int)
37 #define KDSKBSTATE	_IO('K', 20 /*, int */)
38 
39 /* enable/disable I/O access */
40 #define KDENABIO	_IO('K', 60)
41 #define KDDISABIO	_IO('K', 61)
42 
43 /* make sound */
44 #define KIOCSOUND	_IO('K', 63 /*, int */)
45 
46 /* get keyboard model */
47 #define KB_OTHER	0		/* keyboard not known 		*/
48 #define KB_84		1		/* 'old' 84 key AT-keyboard	*/
49 #define KB_101		2		/* MF-101 or MF-102 keyboard	*/
50 #define KDGKBTYPE	_IOR('K', 64, int)
51 
52 /* get/set keyboard LED state */
53 #define LED_CAP		1		/* Caps lock LED 		*/
54 #define LED_NUM		2		/* Num lock LED 		*/
55 #define LED_SCR		4		/* Scroll lock LED 		*/
56 #define LED_MASK	(LED_CAP | LED_NUM | LED_SCR)
57 #define KDGETLED	_IOR('K', 65, int)
58 #define KDSETLED	_IO('K', 66 /*, int */)
59 
60 /* set keyboard repeat rate (obsolete, use KDSETREPEAT below) */
61 #define KDSETRAD	_IO('K', 67 /*, int */)
62 
63 /* see console.h for the definition of the following ioctl */
64 #if notdef
65 #define KDRASTER	_IOW('K', 100, scr_size_t)
66 #endif
67 
68 /* get keyboard information */
69 struct keyboard_info {
70 	int		kb_index;	/* kbdio index#			*/
71 	char		kb_name[16];	/* driver name			*/
72 	int		kb_unit;	/* unit#			*/
73 	int		kb_type;	/* KB_84, KB_101, KB_OTHER,...	*/
74 	int		kb_config;	/* device configuration flags	*/
75 	int		kb_flags;	/* internal flags		*/
76 };
77 typedef struct keyboard_info keyboard_info_t;
78 #define KDGKBINFO	_IOR('K', 101, keyboard_info_t)
79 
80 /* set/get keyboard repeat rate (new interface) */
81 struct keyboard_repeat {
82 	int		kb_repeat[2];
83 };
84 typedef struct keyboard_repeat keyboard_repeat_t;
85 #define KDSETREPEAT	_IOW('K', 102, keyboard_repeat_t)
86 #define KDGETREPEAT	_IOR('K', 103, keyboard_repeat_t)
87 
88 /* get/set key map/accent map/function key strings */
89 
90 #define NUM_KEYS	256		/* number of keys in table	*/
91 #define NUM_STATES	8		/* states per key		*/
92 #define ALTGR_OFFSET	128		/* offset for altlock keys	*/
93 
94 #define NUM_DEADKEYS	15		/* number of accent keys	*/
95 #define NUM_ACCENTCHARS	52		/* max number of accent chars	*/
96 
97 #define NUM_FKEYS	96		/* max number of function keys	*/
98 #define MAXFK		16		/* max length of a function key str */
99 
100 #ifndef _KEYMAP_DECLARED
101 #define	_KEYMAP_DECLARED
102 
103 struct keyent_t {
104 	u_char		map[NUM_STATES];
105 	u_char		spcl;
106 	u_char		flgs;
107 #define	FLAG_LOCK_O	0
108 #define	FLAG_LOCK_C	1
109 #define FLAG_LOCK_N	2
110 };
111 
112 struct keymap {
113 	u_short		n_keys;
114 	struct keyent_t	key[NUM_KEYS];
115 };
116 typedef struct keymap keymap_t;
117 
118 #endif /* !_KEYMAP_DECLARED */
119 
120 /* defines for "special" keys (spcl bit set in keymap) */
121 #define NOP		0x00		/* nothing (dead key)		*/
122 #define LSH		0x02		/* left shift key		*/
123 #define RSH		0x03		/* right shift key		*/
124 #define CLK		0x04		/* caps lock key		*/
125 #define NLK		0x05		/* num lock key			*/
126 #define SLK		0x06		/* scroll lock key		*/
127 #define LALT		0x07		/* left alt key			*/
128 #define BTAB		0x08		/* backwards tab		*/
129 #define LCTR		0x09		/* left control key		*/
130 #define NEXT		0x0a		/* switch to next screen 	*/
131 #define F_SCR		0x0b		/* switch to first screen 	*/
132 #define L_SCR		0x1a		/* switch to last screen 	*/
133 #define F_FN		0x1b		/* first function key 		*/
134 #define L_FN		0x7a		/* last function key 		*/
135 /*			0x7b-0x7f	   reserved do not use !	*/
136 #define RCTR		0x80		/* right control key		*/
137 #define RALT		0x81		/* right alt (altgr) key	*/
138 #define ALK		0x82		/* alt lock key			*/
139 #define ASH		0x83		/* alt shift key		*/
140 #define META		0x84		/* meta key			*/
141 #define RBT		0x85		/* boot machine			*/
142 #define DBG		0x86		/* call debugger		*/
143 #define SUSP		0x87		/* suspend power (APM)		*/
144 #define SPSC		0x88		/* toggle splash/text screen	*/
145 
146 #define F_ACC		DGRA		/* first accent key		*/
147 #define DGRA		0x89		/* grave			*/
148 #define DACU		0x8a		/* acute			*/
149 #define DCIR		0x8b		/* circumflex			*/
150 #define DTIL		0x8c		/* tilde			*/
151 #define DMAC		0x8d		/* macron			*/
152 #define DBRE		0x8e		/* breve			*/
153 #define DDOT		0x8f		/* dot				*/
154 #define DUML		0x90		/* umlaut/diaresis		*/
155 #define DDIA		0x90		/* diaresis			*/
156 #define DSLA		0x91		/* slash			*/
157 #define DRIN		0x92		/* ring				*/
158 #define DCED		0x93		/* cedilla			*/
159 #define DAPO		0x94		/* apostrophe			*/
160 #define DDAC		0x95		/* double acute			*/
161 #define DOGO		0x96		/* ogonek			*/
162 #define DCAR		0x97		/* caron			*/
163 #define L_ACC		DCAR		/* last accent key		*/
164 
165 #define STBY		0x98		/* Go into standby mode (apm)   */
166 #define PREV		0x99		/* switch to previous screen 	*/
167 #define PNC		0x9a		/* force system panic */
168 #define LSHA		0x9b		/* left shift key / alt lock	*/
169 #define RSHA		0x9c		/* right shift key / alt lock	*/
170 #define LCTRA		0x9d		/* left ctrl key / alt lock	*/
171 #define RCTRA		0x9e		/* right ctrl key / alt lock	*/
172 #define LALTA		0x9f		/* left alt key / alt lock	*/
173 #define RALTA		0xa0		/* right alt key / alt lock	*/
174 #define HALT		0xa1		/* halt machine */
175 #define PDWN		0xa2		/* halt machine and power down */
176 
177 #define F(x)		((x)+F_FN-1)
178 #define	S(x)		((x)+F_SCR-1)
179 #define ACC(x)		((x)+F_ACC)
180 
181 struct acc_t {
182 	u_char		accchar;
183 	u_char		map[NUM_ACCENTCHARS][2];
184 };
185 
186 struct accentmap {
187 	u_short		n_accs;
188 	struct acc_t	acc[NUM_DEADKEYS];
189 };
190 typedef struct accentmap accentmap_t;
191 
192 struct keyarg {
193 	u_short		keynum;
194 	struct keyent_t	key;
195 };
196 typedef struct keyarg keyarg_t;
197 
198 struct fkeytab {
199 	u_char		str[MAXFK];
200 	u_char		len;
201 };
202 typedef struct fkeytab fkeytab_t;
203 
204 struct fkeyarg {
205 	u_short		keynum;
206 	char		keydef[MAXFK];
207 	char		flen;
208 };
209 typedef struct fkeyarg	fkeyarg_t;
210 
211 #define GETFKEY		_IOWR('k', 0, fkeyarg_t)
212 #define SETFKEY		_IOWR('k', 1, fkeyarg_t)
213 #if notdef		/* see console.h */
214 #define GIO_SCRNMAP	_IOR('k', 2, scrmap_t)
215 #define PIO_SCRNMAP	_IOW('k', 3, scrmap_t)
216 #endif
217 #define GIO_KEYMAP 	_IOR('k', 6, keymap_t)
218 #define PIO_KEYMAP 	_IOW('k', 7, keymap_t)
219 #define GIO_DEADKEYMAP 	_IOR('k', 8, accentmap_t)
220 #define PIO_DEADKEYMAP 	_IOW('k', 9, accentmap_t)
221 #define GIO_KEYMAPENT 	_IOWR('k', 10, keyarg_t)
222 #define PIO_KEYMAPENT 	_IOW('k', 11, keyarg_t)
223 
224 /* flags set to the return value in the KD_XLATE mode */
225 
226 #define NOKEY		0x100		/* no key pressed marker 	*/
227 #define FKEY		0x200		/* function key marker 		*/
228 #define MKEY		0x400		/* meta key marker (prepend ESC)*/
229 #define BKEY		0x800		/* backtab (ESC [ Z)		*/
230 
231 #define SPCLKEY		0x8000		/* special key			*/
232 #define RELKEY		0x4000		/* key released			*/
233 #define ERRKEY		0x2000		/* error			*/
234 
235 #define KEYCHAR(c)	((c) & 0x00ff)
236 #define KEYFLAGS(c)	((c) & ~0x00ff)
237 
238 #endif /* !_SYS_KBIO_H_ */
239