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