interface is a software loopback mechanism that can be loosely
described as the virtual AT keyboard analog of the
does for virtual AT keyboards what the
driver does for terminals.
driver, like the
driver, provides two interfaces: a keyboard interface like the usual
facility it is simulating (a virtual AT keyboard in the case of
or a terminal for
and a character-special device
The virtual AT keyboards are named
etc., one for each control device that has been opened.
interface permits opens on the special control device
When this device is opened,
will return a handle for the lowest unused
to determine which).
Each virtual AT keyboard supports the usual keyboard interface
ioctl 2 s,
and thus can be used with
like any other keyboard.
The control device supports exactly the same
ioctl 2 s
as the virtual AT keyboard device.
Writing AT scan codes to the control device generates an input on
the virtual AT keyboard, as if the
hardware had just received it.
The virtual AT keyboard control device, normally
(it cannot be opened if it is already open)
and is restricted to the super-user.
call will return the virtual AT keyboard status structure
.In dev/vkbd/vkbd_var.h )
if one is available;
if not, it will either block until one is or return
depending on whether non-blocking I/O has been enabled.
call passes AT scan codes to be
from the virtual AT keyboard.
Each AT scan code must be passed as
.Vt unsigned int .
Although AT scan codes must be passes as
.Vt unsigned int Ns s ,
the size of the buffer passed to
still should be in bytes, i.e.,
static unsigned int codes =
/* Make Break */
int fd, len;
fd = open("/dev/vkbdctl0", O_RDWR);
if (fd < 0)
/* Note sizeof(codes) - not 2! */
len = write(fd, codes, sizeof(codes));
if (len < 0)
Write will block if there is not enough space in the input queue.
The control device also supports
for read and write.
On the last close of the control device, the virtual AT keyboard is removed.
All queued scan codes are thrown away.