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