| WSKBD(9) | Kernel Developer's Manual | WSKBD(9) |
wskbd,
wskbd_input, wskbd_rawinput,
wskbd_cnattach,
wskbd_cndetach,
wskbddevprint — wscons
keyboard support
#include
<dev/wscons/wsconsio.h>
#include
<dev/wscons/wskbdvar.h>
#include
<dev/wscons/wsksymdef.h>
#include
<dev/wscons/wsksymvar.h>
void
wskbd_input(struct
device *kbddev, u_int
type, int
value);
void
wskbd_rawinput(struct
device *kbddev, u_char
*buf, int len);
void
wskbd_cnattach(const
struct wskbd_consops *consops,
void *conscookie,
const struct wskbd_mapdata
*mapdata);
void
wskbd_cndetach(void);
int
wskbddevprint(void
*aux, const char
*pnp);
The wskbd module is a component of the
wscons(9) framework to provide
machine-independent keyboard support. Most of the support is provided by the
wskbd(4) device driver, which
must be a child of the hardware device driver.
Keyboard drivers providing support for wscons keyboards will make use of the following data types:
int (*enable)(void *, int); void (*set_leds)(void *, int); int (*ioctl)(void *v, u_long cmd, void *data, int flag, struct lwp *l);
The enable member defines the function to be called to enable keypress passing to wscons. The set_leds member defined the function to be called to set the LEDs on the keyboard. The ioctl member defines the function to be called to perform keyboard-specific ioctl calls.
There is a void * cookie provided by the keyboard driver associated with these functions, which is passed to them when they are invoked.
void (*getc)(void *, u_int *, int *); void (*pollc)(void *, int); void (*bell)(void *, u_int, u_int, u_int);
There is a void * cookie provided by the keyboard driver associated with these functions, which is passed to them when they are invoked.
kbd_t name; /* name of this map */ kbd_t base; /* map this one is based on */ int map_size; /* size of map */ const keysym_t *map; /* the map itself */
const struct wscons_keydesc *keydesc;
kbd_t layout;
int console; const struct wskbd_mapdata *keymap; const struct wskbd_accessops *accessops; void *accesscookie;
Keymaps are a dense stream of keysym_t. A declaration has the following fields:
pos [cmd] normal [shift] [altgr] [shift-altgr]
The fields have the following meanings:
If the keysym after pos is not KS_Cmd_XXX, then cmd is empty. The shift, altgr and shift-altgr fields are determined from previous fields if they are not specified. Therefore, there are four valid keysym declarations:
pos [cmd] normal
pos [cmd] normal shift
pos [cmd] normal shift altgr
pos [cmd] normal shift altgr shift-altgr
wskbd_input(kbddev,
type, value)wskbd_rawinput(kbddev,
buf, len)wskbd_cnattach(consops,
conscookie, mapdata)wskbd_cndetach()wskbddevprint(aux,
pnp)config_found().
(see autoconf(9)).Keyboard drivers which want to use the wskbd module must be a
parent to the wskbd(4) device
and provide an attachment interface. To attach the
wskbd(4) device, the keyboard
driver must allocate and populate a
wskbddev_attach_args structure with the supported
operations and callbacks and call config_found() to
perform the attach (see
autoconf(9)). The
keymap member points to the
wskbd_mapdata
structure which describes the keycode mapping operations. The
accessops member points to the
wskbd_accessops
structure which describes the keyboard access operations. The
console member is a boolean to indicate to wscons
whether this keyboard will be used for console input.
If the keyboard belongs to the system console, it must register
the wskbd_consops structure specifying the console
operations via wskbd_cnattach() at console attach
time.
When a keypress arrives from the keyboard, the
keyboard driver must perform any necessary character decoding to wscons
events and pass the events to wscons via
wskbd_input().
If the kernel is compiled with the option
WSDISPLAY_COMPAT_RAWKBD, then the keyboard driver must
also pass the raw keyboard data to wscons via
wskbd_rawinput().
The wscons framework calls back into the hardware
driver by invoking the functions that are specified in the
accessops
structure. The
enable()
and
set_leds()
functions are relatively simple and self-explanatory. The
ioctl()
function is called by the wscons interface to perform keyboard-specific
ioctl operations (see
ioctl(2)). The argument
cmd to the ioctl() function
specifies the specific command to perform using the data
data. Valid commands are listed in
sys/dev/wscons/wsconsio.h.
The wscons subsystem is implemented within the directory
sys/dev/wscons. The wskbd
module itself is implement within the files
sys/dev/wscons/wskbd.c and
sys/dev/wscons/wskbdutil.c.
ioctl(2) operations are listed
in sys/dev/wscons/wsconsio.h.
ioctl(2), autoconf(9), driver(9), intro(9), wsdisplay(9), wsmouse(9)
| April 6, 2025 | NetBSD 11.0 |