1 .\" $NetBSD: wskbd.9,v 1.13 2007/03/07 00:41:18 dogcow Exp $
3 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Gregory McGarry.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
40 .Nd wscons keyboard support
42 .In dev/wscons/wsconsio.h
43 .In dev/wscons/wskbdvar.h
44 .In dev/wscons/wsksymdef.h
45 .In dev/wscons/wsksymvar.h
47 .Fn wskbd_input "struct device *kbddev" "u_int type" "int value"
49 .Fn wskbd_rawinput "struct device *kbddev" "u_char *buf" "int len"
51 .Fn wskbd_cnattach "const struct wskbd_consops *consops" "void *conscookie" \
52 "const struct wskbd_mapdata *mapdata"
56 .Fn wskbddevprint "void *aux" "const char *pnp"
60 module is a component of the
62 framework to provide machine-independent keyboard support.
63 Most of the support is provided by the
65 device driver, which must be a child of the hardware device driver.
67 Keyboard drivers providing support for wscons keyboards will make use
68 of the following data types:
69 .Bl -tag -width compact
71 An opaque type describing keyboard properties.
73 The wscons keyboard-independent symbolic representation of the keypress.
74 .It Fa struct wskbd_accessops
75 A structure used to specify the keyboard access functions.
76 All keyboards must provide this structure and pass it to the
79 It has the following members:
81 int (*enable)(void *, int);
82 void (*set_leds)(void *, int);
83 int (*ioctl)(void *v, u_long cmd, void *data,
84 int flag, struct lwp *l);
89 member defines the function to be called to enable keypress passing to
93 member defined the function to be called to set the LEDs on the
97 member defines the function to be called to perform keyboard-specific
102 cookie provided by the keyboard driver associated with these
103 functions, which is passed to them when they are invoked.
104 .It Fa struct wskbd_consops
105 A structure used to specify the keyboard console operations.
106 All keyboards which can operate as a console must provide this structure
110 If the keyboard cannot be a console, it is not
111 necessary to specify this structure.
112 It has the following members:
114 void (*getc)(void *, u_int *, int *);
115 void (*pollc)(void *, int);
116 void (*bell)(void *, u_int, u_int, u_int);
121 cookie provided by the keyboard driver associated with these
122 functions, which is passed to them when they are invoked.
123 .It Fa struct wscons_keydesc
124 A structure used to describe a keyboard mapping table to convert
125 keyboard-specific keycodes to wscons keysyms.
129 kbd_t name; /* name of this map */
130 kbd_t base; /* map this one is based on */
131 int map_size; /* size of map */
132 const keysym_t *map; /* the map itself */
134 .It Fa struct wskbd_mapdata
135 A structure used to describe the keyboard layout and operation to
136 interpret the keyboard layout.
137 it contains the following members:
139 const struct wscons_keydesc *keydesc;
142 .It Fa struct wskbddev_attach_args
143 A structure used to attach the
146 It has the following members:
149 const struct wskbd_mapdata *keymap;
150 const struct wskbd_accessops *accessops;
155 Keymaps are a dense stream of
157 A declaration has the following fields:
166 The fields have the following meanings:
168 .Bl -tag -offset indent -width SHIFT-ALTGR -compact
172 and starts the description of key
175 If the command modifier (KS_Cmd_XXX) is active, the optional command
179 The keysym if no modifiers are active.
181 The keysym if the shift modifier is active.
183 The keysym if the alt-gr modifier is active.
185 The keysym if the shift-alt-gr modifier is active.
190 is not KS_Cmd_XXX, then
198 fields are determined from previous fields if they are not specified.
199 Therefore, there are four valid keysym declarations:
211 .Ar normal Ar shift Ar altgr
215 .Ar normal Ar shift Ar altgr Ar shift-altgr
217 .Bl -tag -width compact
218 .It Fn wskbd_input "kbddev" "type" "value"
219 Pass the keypress of value
223 to wscons keyboard driver.
227 .Bl -tag -width compact
228 .It WSCONS_EVENT_KEY_UP
230 .It WSCONS_EVENT_KEY_DOWN
233 .It Fn wskbd_rawinput "kbddev" "buf" "len"
234 Pass the raw keypress in the buffer
236 to the wscons keyboard driver.
240 This function should only be called if the kernel option
241 .Em WSDISPLAY_COMPAT_RAWKBD
243 .It Fn wskbd_cnattach "consops" "conscookie" "mapdata"
244 Attach this keyboard as the console input by specifying the console
247 and the keyboard mapping table information in
249 The functions specified in
253 as the first argument.
254 .It Fn wskbd_cndetach ""
255 Detach this keyboard as the console input.
256 .It Fn wskbddevprint "aux" "pnp"
257 The default wskbd printing routine used by
262 .Sh AUTOCONFIGURATION
263 Keyboard drivers which want to use the wskbd module must be a
266 device and provide an attachment interface.
269 device, the keyboard driver must allocate and populate a
270 .Fa wskbddev_attach_args
271 structure with the supported operations and callbacks and call
273 to perform the attach (see
279 structure which describes the keycode mapping operations.
284 structure which describes the keyboard access operations.
287 member is a boolean to indicate to wscons whether this keyboard will
288 be used for console input.
290 If the keyboard belongs to the system console, it must register the
292 structure specifying the console operations via
294 at console attach time.
296 When a keypress arrives from the keyboard, the keyboard driver must
297 perform any necessary character decoding to wscons events and pass the
300 If the kernel is compiled with the option
301 .Em WSDISPLAY_COMPAT_RAWKBD ,
302 then the keyboard driver must also pass the raw keyboard data to
306 The wscons framework calls back into the hardware driver by invoking
307 the functions that are specified in the
314 functions are relatively simple and self-explanatory.
317 function is called by the wscons interface to perform
318 keyboard-specific ioctl operations (see
324 function specifies the specific command to perform using the data
326 Valid commands are listed in
327 .Pa sys/dev/wscons/wsconsio.h .
329 This section describes places within the
331 source tree where actual code implementing or using the
332 machine-independent wscons subsystem can be found.
333 All pathnames are relative to
336 The wscons subsystem is implemented within the directory
340 module itself is implement within the files
341 .Pa sys/dev/wscons/wskbd.c
343 .Pa sys/dev/wscons/wskbdutil.c .
345 operations are listed in
346 .Pa sys/dev/wscons/wsconsio.h .