VKBD(4)
πΈ VKBD(4) β the virtual AT keyboard interface πΈ
okay so bestie, we're talking about vkbd today, and it's a kernel interfaces manual situation, so buckle up π
β¨ NAME β¨
vkbd β the virtual AT keyboard interface πΉ
π¦ SYNOPSIS π¦
device vkbd
π DESCRIPTION π
okay so the vkbd interface is literally a software loopback mechanism, and the vibe is basically "virtual AT keyboard analog of the pty(4)" β like, vkbd does for virtual AT keyboards what the pty(4) driver does for terminals, no cap π«Ά
The vkbd driver, same as pty(4), gives you two interfaces: a keyboard interface like the usual facility it's simulating (a virtual AT keyboard in the vkbd case, or a terminal for pty(4)), plus a character-special device "control" interface. two-for-one, iconic π
The virtual AT keyboards are named vkbd0, vkbd1, etc., one for each control device that has been opened. so cute, they're numbered π
The vkbd interface permits opens on the special control device /dev/vkbdctl. When this device is opened, vkbd will return a handle for the lowest unused vkbdctl device (use devname(3) to figure out which one, iykyk).
Each virtual AT keyboard supports the usual keyboard interface ioctl(2)s, so it can be used with kbdcontrol(1) like any other keyboard, fr fr. 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 (non-existent π) hardware had just received it. ghost keyboard behavior, we love to see it π
π the control device deets π
The virtual AT keyboard control device, normally /dev/vkbdctlβ¨Nβ©, is exclusive-open β meaning it literally cannot be opened if it's already open, no sharing besties π β and it's restricted to the super-user. A read(2) call will return the virtual AT keyboard status structure (defined in <dev/vkbd/vkbd_var.h>) if one is available; if not, it'll either block until one is, or return EWOULDBLOCK, depending on whether non-blocking I/O has been enabled. choose your adventure β¨
A write(2) call passes AT scan codes to be "received" from the virtual AT keyboard. Each AT scan code must be passed as unsigned int. Even though AT scan codes must be passed as unsigned ints, the size of the buffer passed to write(2) still should be in bytes, i.e.:
static unsigned int codes[] =
{
/* Make Break */
0x1e, 0x9e
};
int
main(void)
{
int fd, len;
fd = open("/dev/vkbdctl0", O_RDWR);
if (fd < 0)
err(1, "open");
/* Note sizeof(codes) - not 2! */
len = write(fd, codes, sizeof(codes));
if (len < 0)
err(1, "write");
close(fd);
return (0);
}
write will block if there's not enough space in the input queue. patience, babe π§
The control device also supports select(2) for read and write. multitasking queen π
On the last close of the control device, the virtual AT keyboard is removed. and all queued scan codes are thrown away β gone, deleted, into the void ποΈ
π SEE ALSO π
kbdcontrol(1), atkbdc(4), psm(4), syscons(4), vt(4)
β HISTORY β
The vkbd module was implemented in FreeBSD 6.0. vintage, we stan a legacy icon π
π AUTHORS π
Maksim Yevmenkin <m_evmenkin@yahoo.com> β thank you king π«Ά
π₯ CAVEATS π₯
okay this is the part where you pay attention, bestie π
The vkbd interface is a software loopback mechanism, and, thus, ddb(4) will not work with it. nope. not happening π
Current implementation of the syscons(4) driver can accept input from only one keyboard, even if it's virtual. So it is not possible to have both a wired and virtual keyboard active at the same time. sad but true π
It is, however, in principal possible to obtain AT scan codes from different sources and write them into the same virtual keyboard. The virtual keyboard state synchronization is the user's responsibility though β that's on you, bestie, no cap πΈ
anyway that's the whole page, mwah π β signed off from the Debian edition, dated August 12, 2004, slay π¦β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms