Add an ffs(5) manual page.
[dragonfly.git] / share / man / man4 / keyboard.4
1 .\"
2 .\" $FreeBSD: src/share/man/man4/keyboard.4,v 1.19.2.5 2001/08/17 13:08:38 ru Exp $
3 .\" $DragonFly: src/share/man/man4/keyboard.4,v 1.5 2008/05/02 02:05:05 swildner Exp $
4 .\"
5 .Dd January 8, 1995
6 .Dt KEYBOARD 4
7 .Os
8 .Sh NAME
9 .Nm keyboard
10 .Nd pc keyboard interface
11 .Sh DESCRIPTION
12 The PC keyboard is used as the console character input device.
13 The keyboard
14 is owned by the current virtual console.
15 To switch between the virtual consoles use the sequence
16 .Ar ALT+Fn ,
17 which means hold down ALT and press one of the function keys.
18 The
19 virtual console with the same number as the function key is then
20 selected as the current virtual console and given exclusive use of
21 the keyboard and display.
22 .Pp
23 The console allows entering values that are not physically
24 present on the keyboard via a special keysequence.
25 To use this facility press and hold down ALT,
26 then enter a decimal number from 0-255 via the numerical keypad, then
27 release ALT.
28 The entered value is then used as the ASCII value for one
29 character.
30 This way it is possible to enter any ASCII value, not present
31 on the keyboard.
32 The console driver also includes a history function.
33 It is activated by
34 pressing the scroll-lock key.
35 This holds the display, and enables the cursor
36 arrows for scrolling up and down through the last scrolled out lines.
37 .Pp
38 The keyboard is configurable to suit the individual user and the different
39 national layout.
40 .Pp
41 The keys on the keyboard can have any of the following functions:
42 .Pp
43 .Bl -tag -width "Modifier Key" -compact
44 .It "Normal key"
45 Enter the ASCII value associated with the key.
46 .It "Function key"
47 Enter a string of ASCII values.
48 .It "Switch Key"
49 Switch virtual console.
50 .It "Modifier Key"
51 Change the meaning of another key.
52 .El
53 .Pp
54 The keyboard is seen as a number of keys numbered from 1 to n. This
55 number is often referred to as the "scancode" for a given key.
56 The number
57 of the key is transmitted as an 8 bit char with bit 7 as 0 when a key is
58 pressed, and the number with bit 7 as 1 when released.
59 This makes it
60 possible to make the mapping of the keys fully configurable.
61 .Pp
62 The meaning of every key is programmable via the
63 .Dv PIO_KEYMAP
64 ioctl call, that
65 takes a structure keymap_t as argument.
66 The layout of this structure is as
67 follows:
68 .Bd -literal -offset indent
69                 struct keymap {
70                         u_short n_keys;
71                         struct key_t {
72                                 u_char map[NUM_STATES];
73                                 u_char spcl;
74                                 u_char flgs;
75                         } key[NUM_KEYS];
76                 };
77 .Ed
78 .Pp
79 The field n_keys tells the system how many keydefinitions (scancodes)
80 follows.
81 Each scancode is then specified in the key_t substructure.
82 .Pp
83 Each scancode can be translated to any of 8 different values, depending
84 on the shift, control, and alt state.
85 These eight possibilities are
86 represented by the map array, as shown below:
87 .Bd -literal
88                                                             alt
89  scan                          cntrl          alt    alt   cntrl
90  code     base   shift  cntrl  shift   alt   shift  cntrl  shift
91  map[n]      0       1      2      3     4       5      6      7
92  ----     ------------------------------------------------------
93  0x1E      'a'     'A'   0x01   0x01    'a'    'A'   0x01   0x01
94 .Ed
95 .Pp
96 This is the default mapping for the key labelled 'A' which normally has
97 scancode 0x1E. The eight states are as shown, giving the 'A' key its
98 normal behavior.
99 The spcl field is used to give the key "special" treatment, and is
100 interpreted as follows.
101 Each bit corresponds to one of the states above.
102 If the bit is 0 the
103 key emits the number defined in the corresponding map[] entry.
104 If the bit is 1 the key is "special". This means it does not emit
105 anything; instead it changes the "state". That means it is a shift,
106 control, alt, lock, switch-screen, function-key or no-op key.
107 The bitmap is backwards ie. 7 for base, 6 for shift etc.
108 .Pp
109 The flgs field defines if the key should react on caps-lock (1),
110 num-lock (2), both (3) or ignore both (0).
111 .Pp
112 The
113 .Xr kbdcontrol 1
114 utility is used to load such a description into/outof
115 the kernel at runtime.
116 This makes it possible to change the key
117 assignments at runtime, or more important to get
118 .Dv ( GIO_KEYMAP
119 ioctl)
120 the exact key meanings from the kernel (fx. used by the X server).
121 .Pp
122 The function keys can be programmed using the
123 .Dv SETFKEY
124 ioctl call.
125 .Pp
126 This ioctl takes an argument of the type fkeyarg_t:
127 .Bd -literal -offset indent
128                 struct fkeyarg {
129                         u_short keynum;
130                         char    keydef[MAXFK];
131                         char    flen;
132                 };
133 .Ed
134 .Pp
135 The field keynum defines which function key that is programmed.
136 The array keydef should contain the new string to be used (MAXFK long),
137 and the length should be entered in flen.
138 .Pp
139 The
140 .Dv GETFKEY
141 ioctl call works in a similar manner, except it returns
142 the current setting of keynum.
143 .Pp
144 The function keys are numbered like this:
145 .Bd -literal -offset indent
146         F1-F12                  key 1 - 12
147         Shift F1-F12            key 13 - 24
148         Ctrl F1-F12             key 25 - 36
149         Ctrl+shift F1-F12       key 37 - 48
150
151         Home                    key 49
152         Up arrow                key 50
153         Page Up                 key 51
154         (keypad) -              key 52
155         Left arrow              key 53
156         (keypad) 5              key 54
157         Right arrow             key 55
158         (keypad) +              key 56
159         End                     key 57
160         Down arrow              key 58
161         Page down               key 59
162         Insert                  key 60
163         Delete                  key 61
164
165         Right window            key 62
166         Left window             key 63
167         Menu                    key 64
168 .Ed
169 .Pp
170 The
171 .Xr kbdcontrol 1
172 utility also allows changing these values at runtime.
173 .Sh AUTHORS
174 .An S\(/oren Schmidt Aq sos@FreeBSD.org