11 #include <sys/ioccom.h>
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 _IOWINT('K', 7)
21 #define KDMKTONE _IOWINT('K', 8)
23 /* see console.h for the definitions of the following ioctls */
25 #define KDGETMODE _IOR('K', 9, int)
26 #define KDSETMODE _IOWINT('K', 10)
27 #define KDSBORDER _IOWINT('K', 13)
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 _IOWINT('K', 20)
39 /* enable/disable I/O access */
40 #define KDENABIO _IO('K', 60)
41 #define KDDISABIO _IO('K', 61)
44 #define KIOCSOUND _IOWINT('K', 63)
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)
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 _IOWINT('K', 66)
60 /* set keyboard repeat rate (obsolete, use KDSETREPEAT below) */
61 #define KDSETRAD _IOWINT('K', 67)
63 struct keyboard_info {
64 int kb_index; /* kbdio index# */
65 char kb_name[16]; /* driver name */
66 int kb_unit; /* unit# */
67 int kb_type; /* KB_84, KB_101, KB_OTHER,... */
68 int kb_config; /* device configuration flags */
69 int kb_flags; /* internal flags */
71 typedef struct keyboard_info keyboard_info_t;
73 /* keyboard repeat rate mapping table */
74 static const int kbdelays[] = { 250, 500, 750, 1000 };
75 static const int kbrates[] = { 34, 38, 42, 46, 50,
76 55, 59, 63, 68, 76, 84, 92, 100, 110, 118, 126,
77 136, 152, 168, 184, 200, 220, 236, 252, 272, 304, 336,
78 368, 400, 440, 472, 504 };
80 /* add/remove keyboard to/from mux */
81 #define KBADDKBD _IOW('K', 68, keyboard_info_t) /* add keyboard */
82 #define KBRELKBD _IOW('K', 69, keyboard_info_t) /* release keyboard */
84 /* see console.h for the definition of the following ioctl */
86 #define KDRASTER _IOW('K', 100, scr_size_t)
89 /* get keyboard information */
90 #define KDGKBINFO _IOR('K', 101, keyboard_info_t)
92 /* set/get keyboard repeat rate (new interface) */
93 struct keyboard_repeat {
96 typedef struct keyboard_repeat keyboard_repeat_t;
97 #define KDSETREPEAT _IOW('K', 102, keyboard_repeat_t)
98 #define KDGETREPEAT _IOR('K', 103, keyboard_repeat_t)
100 /* get/set key map/accent map/function key strings */
102 #define NUM_KEYS 256 /* number of keys in table */
103 #define NUM_STATES 8 /* states per key */
104 #define ALTGR_OFFSET 128 /* offset for altlock keys */
106 #define NUM_DEADKEYS 15 /* number of accent keys */
107 #define NUM_ACCENTCHARS 52 /* max number of accent chars */
109 #define NUM_FKEYS 96 /* max number of function keys */
110 #define MAXFK 16 /* max length of a function key str */
112 #ifndef _KEYMAP_DECLARED
113 #define _KEYMAP_DECLARED
116 u_int map[NUM_STATES];
119 #define FLAG_LOCK_O 0
120 #define FLAG_LOCK_C 1
121 #define FLAG_LOCK_N 2
126 struct keyent_t key[NUM_KEYS];
128 typedef struct keymap keymap_t;
130 #ifdef COMPAT_FREEBSD13
132 u_char map[NUM_STATES];
139 struct okeyent_t key[NUM_KEYS];
141 typedef struct okeymap okeymap_t;
142 #endif /* COMPAT_FREEBSD13 */
144 #endif /* !_KEYMAP_DECLARED */
146 /* defines for "special" keys (spcl bit set in keymap) */
147 #define NOP 0x00 /* nothing (dead key) */
148 #define LSH 0x02 /* left shift key */
149 #define RSH 0x03 /* right shift key */
150 #define CLK 0x04 /* caps lock key */
151 #define NLK 0x05 /* num lock key */
152 #define SLK 0x06 /* scroll lock key */
153 #define LALT 0x07 /* left alt key */
154 #define BTAB 0x08 /* backwards tab */
155 #define LCTR 0x09 /* left control key */
156 #define NEXT 0x0a /* switch to next screen */
157 #define F_SCR 0x0b /* switch to first screen */
158 #define L_SCR 0x1a /* switch to last screen */
159 #define F_FN 0x1b /* first function key */
160 #define L_FN 0x7a /* last function key */
161 /* 0x7b-0x7f reserved do not use ! */
162 #define RCTR 0x80 /* right control key */
163 #define RALT 0x81 /* right alt (altgr) key */
164 #define ALK 0x82 /* alt lock key */
165 #define ASH 0x83 /* alt shift key */
166 #define META 0x84 /* meta key */
167 #define RBT 0x85 /* boot machine */
168 #define DBG 0x86 /* call debugger */
169 #define SUSP 0x87 /* suspend power (APM) */
170 #define SPSC 0x88 /* toggle splash/text screen */
172 #define F_ACC DGRA /* first accent key */
173 #define DGRA 0x89 /* grave */
174 #define DACU 0x8a /* acute */
175 #define DCIR 0x8b /* circumflex */
176 #define DTIL 0x8c /* tilde */
177 #define DMAC 0x8d /* macron */
178 #define DBRE 0x8e /* breve */
179 #define DDOT 0x8f /* dot */
180 #define DUML 0x90 /* umlaut/diaresis */
181 #define DDIA 0x90 /* diaresis */
182 #define DSLA 0x91 /* slash */
183 #define DRIN 0x92 /* ring */
184 #define DCED 0x93 /* cedilla */
185 #define DAPO 0x94 /* apostrophe */
186 #define DDAC 0x95 /* double acute */
187 #define DOGO 0x96 /* ogonek */
188 #define DCAR 0x97 /* caron */
189 #define L_ACC DCAR /* last accent key */
191 #define STBY 0x98 /* Go into standby mode (apm) */
192 #define PREV 0x99 /* switch to previous screen */
193 #define PNC 0x9a /* force system panic */
194 #define LSHA 0x9b /* left shift key / alt lock */
195 #define RSHA 0x9c /* right shift key / alt lock */
196 #define LCTRA 0x9d /* left ctrl key / alt lock */
197 #define RCTRA 0x9e /* right ctrl key / alt lock */
198 #define LALTA 0x9f /* left alt key / alt lock */
199 #define RALTA 0xa0 /* right alt key / alt lock */
200 #define HALT 0xa1 /* halt machine */
201 #define PDWN 0xa2 /* halt machine and power down */
202 #define PASTE 0xa3 /* paste from cut-paste buffer */
204 #define F(x) ((x)+F_FN-1)
205 #define S(x) ((x)+F_SCR-1)
206 #define ACC(x) ((x)+F_ACC)
210 u_int map[NUM_ACCENTCHARS][2];
215 struct acc_t acc[NUM_DEADKEYS];
217 typedef struct accentmap accentmap_t;
219 #ifdef COMPAT_FREEBSD13
222 u_char map[NUM_ACCENTCHARS][2];
227 struct oacc_t acc[NUM_DEADKEYS];
229 typedef struct oaccentmap oaccentmap_t;
230 #endif /* COMPAT_FREEBSD13 */
236 typedef struct keyarg keyarg_t;
242 typedef struct fkeytab fkeytab_t;
249 typedef struct fkeyarg fkeyarg_t;
251 #define GETFKEY _IOWR('k', 0, fkeyarg_t)
252 #define SETFKEY _IOWR('k', 1, fkeyarg_t)
253 #ifdef notdef /* see console.h */
254 #define GIO_SCRNMAP _IOR('k', 2, scrmap_t)
255 #define PIO_SCRNMAP _IOW('k', 3, scrmap_t)
257 /* XXX: Should have keymap_t as an argument, but that's too big for ioctl()! */
258 #define GIO_KEYMAP _IO('k', 6)
259 #define PIO_KEYMAP _IO('k', 7)
260 #ifdef COMPAT_FREEBSD13
261 #define OGIO_KEYMAP _IOR('k', 6, okeymap_t)
262 #define OPIO_KEYMAP _IOW('k', 7, okeymap_t)
263 #endif /* COMPAT_FREEBSD13 */
264 /* XXX: Should have accentmap_t as an argument, but that's too big for ioctl()! */
265 #define GIO_DEADKEYMAP _IO('k', 8)
266 #define PIO_DEADKEYMAP _IO('k', 9)
267 #ifdef COMPAT_FREEBSD13
268 #define OGIO_DEADKEYMAP _IOR('k', 8, oaccentmap_t)
269 #define OPIO_DEADKEYMAP _IOW('k', 9, oaccentmap_t)
270 #endif /* COMPAT_FREEBSD13 */
271 #define GIO_KEYMAPENT _IOWR('k', 10, keyarg_t)
272 #define PIO_KEYMAPENT _IOW('k', 11, keyarg_t)
274 /* flags set to the return value in the KD_XLATE mode */
276 #define NOKEY 0x01000000 /* no key pressed marker */
277 #define FKEY 0x02000000 /* function key marker */
278 #define MKEY 0x04000000 /* meta key marker (prepend ESC)*/
279 #define BKEY 0x08000000 /* backtab (ESC [ Z) */
281 #define SPCLKEY 0x80000000 /* special key */
282 #define RELKEY 0x40000000 /* key released */
283 #define ERRKEY 0x20000000 /* error */
286 * The top byte is used to store the flags. This means there are 24
287 * bits left to store the actual character. Because UTF-8 can encode
288 * 2^21 different characters, this is good enough to get Unicode
291 #define KEYCHAR(c) ((c) & 0x00ffffff)
292 #define KEYFLAGS(c) ((c) & ~0x00ffffff)
294 #endif /* !_SYS_KBIO_H_ */