]> git.lizzy.rs Git - plan9front.git/blob - sys/man/8/kbdfs
kbdfs: allow to escape ctlr-alt-del with shift for vmx and vnc.
[plan9front.git] / sys / man / 8 / kbdfs
1 .TH KBDFS 8
2 .SH NAME
3 kbdfs, console \- keyboard and console filesystem
4 .SH SYNOPSIS
5 .B aux/kbdfs
6 [
7 .B -Dd
8 ] [
9 .B -s
10 .I srv
11 ] [
12 .B -m
13 .I mntpnt
14 ] [
15 .I consfile
16 ]
17 .nf
18
19 .B mount -b /srv/cons /dev
20 .B /dev/cons
21 .B /dev/consctl
22 .B /dev/kbd
23 .B /dev/kbdin
24 .B /dev/kbin
25 .B /dev/kbmap
26 .fi
27 .PP
28 .B console
29 [
30 .I cmd
31 .I args...
32 ]
33 .SH DESCRIPTION
34 .PP
35 Started on 
36 .IR boot (8),
37 .IR kbdfs
38 translates raw keyboard scancodes from 
39 .B /dev/scancode
40 (see
41 .IR kbd (3))
42 and its
43 .BR kbin
44 and
45 .BR kbdin
46 file and optionally reads console input from
47 .I consfile
48 to provide initial keyboard and console input.
49 .PP
50 It serves a one-level directory containing the files
51 .BR cons,
52 .BR consctl,
53 .BR kbd,
54 .BR kbdin,
55 .BR kbin
56 and
57 .BR kbmap.
58 .PP
59 The
60 .B -D
61 flag enables a debug trace of
62 .I 9p
63 messages and
64 .B -d
65 prevents 
66 .IR kbdfs
67 from making its memory private.
68 .PP
69 The
70 .B -s
71 option causes
72 .IR kbdfs
73 to post its channel on
74 .B /srv/\fIsrv\fP.
75 On system startup,
76 .IR boot (8)
77 sets this to
78 .B cons.
79 With the
80 .B -m
81 option,
82 .IR kbdfs
83 mounts itself on
84 .I mntpnt
85 (see
86 .IR bind (2)),
87 otherwise on
88 .B /dev
89 (the default).
90 .PP
91 The
92 .B console
93 command executes
94 .I cmd
95 (defaults to the system shell)
96 under its own
97 .I kbdfs
98 instance providing a serial console if
99 .B $console
100 environment variable is set.
101 .SS Console
102 .PP
103 Reading the
104 .BR cons
105 file returns characters typed on the console.  Normally, characters
106 are buffered to enable erase and kill processing.  
107 A control-U, 
108 .LR ^U ,
109 typed at the keyboard
110 .I erases
111 the current input line (removes all
112 characters from the buffer of characters not yet read via cons), and a
113 backspace
114 .I erases
115 the previous non-kill, non-erase character from the
116 input buffer.
117 The combination control-W,
118 .LR ^W ,
119 deletes the input last word.
120 Killing and erasing only delete characters back to, but
121 not including, the last newline.  Characters typed at the keyboard
122 actually produce 16-bit runes (see
123 .IR utf (6)),
124 but the runes are translated into the variable-length
125 .SM UTF
126 encoding (see
127 .IR utf (6))
128 before putting them into the buffer. A
129 .IR read (2)
130 of a length greater than zero causes the process to wait until a newline
131 or a
132 .LR ^D
133 ends the buffer, and then returns as much of the buffer as the
134 argument to read allows, but only up to one complete line.  A
135 terminating
136 .LR ^D
137 is not put into the buffer.  If part of the line remains, the next
138 read will return bytes from that remainder and not part of any new
139 line that has been typed since.
140 .PP
141 If the string
142 .B rawon
143 has been written to the
144 .BR consctl
145 file and the file
146 is still open,
147 .BR cons
148 is in
149 .IR "raw mode" :
150 characters are not echoed as they are typed,
151 backspace,
152 .L ^U,
153 .L ^W
154 and
155 .L ^D
156 are not treated specially, and characters are
157 available to read as soon as they are typed.  Ordinary mode is
158 reentered when
159 .B rawoff
160 is written to
161 .BR consctl
162 or this file is closed.
163 .PP
164 A write (see 
165 .IR read (2))
166 to
167 .BR cons
168 causes the characters to be printed on the console screen.
169 .PP
170 When a
171 .I consfile
172 is passed to
173 .IR kbdfs (8)
174 as its last argument, it reads and processes the
175 characters from that file and forwards them to the
176 .BR cons
177 file with the same text processing applied as on keyboard input.
178 This is used to provide a serial console when
179 .B $console
180 environment variable is set. (see
181 .IR plan9.ini (8)).
182 .PP
183 Holding
184 .LR Ctrl
185 +
186 .LR Alt
187 and then pressing the
188 .LR Del
189 key will
190 trigger a reboot of the terminal.
191 To forward this sequence downstream,
192 .LR Shift
193 +
194 .LR Ctrl
195 +
196 .LR Alt
197 and then pressing
198 .LR Del
199 will cause to send a
200 .LR Shift
201 up before the
202 .LR Del
203 key.
204 This is usefull for programs like
205 .IR vnc (1)
206 and
207 .IR vmx (1).
208 .SS Keyboard
209 A read on the
210 .BR kbd
211 file returns the character
212 .B k,
213 .B K
214 or
215 .B c
216 followed by a null terminated, variable-length,
217 .SM UTF
218 encoded string. The
219 .B k
220 message is sent when a key is pressed down
221 and
222 .B K
223 when a key is released. The following string contains all the keycodes
224 of the keys that are currently pressed down in unshifted form. 
225 This includes all keys that have a keyboard mapping and modifier keys.
226 The string following the
227 .B c
228 message contains the single character that would have been returned
229 on the
230 .BR cons
231 file instead. The
232 .B c
233 message will be resent at the keyboard repeat rate.
234 A single
235 .IR read (2)
236 can return multiple concatenated messages at once (delimited by the null byte)
237 or block when there are no messages queued. Opening the
238 .BR kbd
239 file disables input processing on the
240 .BR cons
241 file until it is closed again.
242 .PP
243 .B K,
244 .B k
245 and
246 .B c
247 messages can be written to
248 .BR kbdin
249 and will forwarded to the reader of
250 .BR cons
251 or
252 .BR kbd.
253 Writing a
254 .B r
255 or
256 .B R
257 message followed by a
258 .SM UTF
259 encoded rune will simulate the press or
260 release of that particular rune.
261 .PP
262 Raw scancodes can be written to the
263 .BR kbin
264 file for external keyboard input (used for USB keyboards).
265 .SS "Keyboard map"
266 Scancodes are mapped to Unicode characters with a number of
267 translation tables. These tables can be accessed with the
268 .BR kbmap
269 file.
270 .PP
271 Reads return the current contents of the map.
272 Each entry is one line containing three 11 character numeric fields,
273 each followed by a space:
274 a table number, an index into the table (scan code), and the decimal value
275 of the corresponding Unicode character (0 if none).
276 The table numbers are platform dependent; they typically distinguish
277 between unshifted and shifted keys.
278 The scan code values are hardware dependent and can vary
279 from keyboard to keyboard.
280 .PP
281 Writes to the file change the map.
282 Lines written to the file must contain three space-separated fields,
283 representing the table number, scan code index, and Unicode character.
284 Values are taken to be decimal unless they start with
285 .B 0x
286 (hexadecimal) or
287 .B 0
288 (octal).
289 The Unicode character can also be represented as
290 .BI ' x
291 where
292 .I x
293 gives the UTF-8 representation of the character
294 (see
295 .IR utf (6)),
296 or as 
297 .BI ^ X
298 to represent a control character.
299 .SH "SEE ALSO"
300 .IR cons (3),
301 .IR keyboard (6),
302 .IR utf (6),
303 .IR kbd (3),
304 .IR plan9.ini (8)
305 .SH FILES
306 .B /sys/lib/kbmap/*
307 .SH SOURCE
308 .B /sys/src/cmd/aux/kbdfs
309 .br
310 .B /rc/bin/console
311 .SH HISTORY
312 .I Kbdfs
313 first appeared in 9front (May, 2011).