keyboard.4 revision 423
1.Dd April 7, 1993 2.Dt KEYBOARD 4 3.Os FreeBSD 4.Sh NAME 5.Nm keyboard 6.Nd pc keyboard interface 7.Sh DESCRIPTION 8 9The PC keyboard is use as the console character input device. The keyboard 10is owned by the current virtual console. 11To switch between the virtual consoles use the sequence 12.Ar ALT+Fn 13, which means hold down ALT and press one of the function keys. The 14virtual console with the same number as the function key is then 15selected as the current virtual console, and given exclusive use of 16the keyboard and display. 17 18The console allows entering values that are not physically 19present on the keyboard via a special keysequence. 20To use this facility press and hold down ALT, 21then enter a decimal number from 0-255 via the numerical keypad, then 22release ALT. The entered value is then used as the ASCII value for one 23character. This way it is possible to enter any ASCII value. 24The keyboard is configurable to suit the individual user and the different 25national layout. 26 27The keys on the keyboard can have any of the following functions: 28 29 Normal key - Enter the ASCII value associated with the key. 30 31 Function key - Enter a string of ASCII values. 32 33 Switch Key - Switch virtual console. 34 35 Modifier Key - Change the meaning of another key. 36 37 38The keyboard is seen as a number of keys numbered from 1 to n. This 39number is often referred to as the "scancode" for a given key. The number 40of the key is transmitted as an 8 bit char with bit 7 as 0 when a key is 41pressed, and the number with bit 7 as 1 when released. This makes it 42possible to make the mapping of the keys fully configurable. 43 44The meaning of every key is programmable via the PIO_KEYMAP ioctl call, that 45takes a structure keymap_t as argument. The layout of this structure is as 46follows: 47.Pp 48.Bd -literal -offset indent 49 struct keymap { 50 u_short n_keys; 51 struct key_t { 52 u_char map[NUM_STATES]; 53 u_char spcl; 54 u_char flgs; 55 } key[NUM_KEYS]; 56 }; 57.Ed 58.Pp 59The field n_keys tells the system how many keydefinitions (scancodes) 60follows. Each scancode is then specified in the key_t substructure. 61 62Each scancode can be translated to any of 8 different values, depending 63on the shift, control, and alt state. These eight possibilities is 64represented by the map array, as shown below: 65 66 alt 67 scan cntrl alt alt cntrl 68 code base shift cntrl shift alt shift cntrl shift 69 map[n] 0 1 2 3 4 5 6 7 70 ---- ------------------------------------------------------ 71 0x1E 'a' 'A' 0x01 0x01 'a' 'A' 0x01 0x01 72 73This is the default mapping for the key labelled 'A' wich normally has 74scancode 0x1E. The eight states is as shown, giving the 'A' key its 75normal behavior. 76The spcl field is used to give the key "special" treatment, and is 77interpreted as follows. 78Each bit correspond to one of the states above. If the bit is 0 the 79key emits the number defined in the corresponding map[] entry. 80If the bit is 1 the key is "special". This means it does not emit 81anything, instead it changes the "state". That means it is a shift, 82control, alt, lock, switch-screen, function-key or no-op key. 83The bitmap is backwards ie. 7 for base, 6 for shift etc. 84 85The flgs field defines if the key should react on caps-lock (1), 86num-lock (2), both (3) or ignore both (0). 87 88The mapkbd utility is used to load such a description into/outof 89the kernel at runtime. This make it possible to change the key 90assignments at runtime, or more important to get (GIO_KEYMAP ioctl) 91the exact key meanings from the kernel (fx. used by the X server). 92 93The function keys can be programmed using the PIO_STRMAP ioctl call. 94 95This ioctl takes a argument of the type fkeyarg_t: 96.Bd -literal -offset indent 97 struct fkeyarg { 98 u_short keynum; 99 char keydef[MAXFK]; 100 char flen; 101 }; 102.Ed 103.Pp 104The field keynum defines which function key that is programmed. 105The array keydef should contain the new string to be used (MAXFK long), 106and the length should be entered in flen. 107 108The GIO_STRMAP ioctl call works in a semilar manner, execpt it returns 109the current setting of keynum. 110 111The function keys are numbered like this: 112.Bd -literal -offset indent 113 F1-F12 key 1 - 12 114 Shift F1-F12 key 13 - 24 115 Ctrl F1-F12 key 25 - 36 116 Ctrl+shift F1-F12 key 37 - 48 117 118 Home key 49 119 Up arrow key 50 120 Page Up key 51 121 (keypad) - key 52 122 Left arrow key 53 123 (keypad) 5 key 54 124 Right arrow key 55 125 (keypad) + key 56 126 End key 57 127 Down arrow key 58 128 Page down key 59 129 Insert key 60 130.Ed 131.Pp 132.Sh AUTHOR 133 S_ren Schmidt 134 Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk) 135