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