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