UKBD(4)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– UKBD(4) β€” USB keyboard driver, but make it fashion πŸ’–

Okay so bestie, welcome to the UKBD(4) page from the Kernel Interfaces Manual! This is literally all about the USB keyboard driver, and I'm gonna walk you through it so you can slay your kernel config. No cap, it's giving essential info. πŸ’…


✨ NAME ✨

ukbd β€” the USB keyboard driver, and honestly? It's the reason your cute mechanical keyboard works on FreeBSD. Periodt. πŸ’…


🌸 SYNOPSIS 🌸

Okay so if you wanna compile this driver into your kernel (which is a whole vibe), you gotta put these lines in your kernel configuration file:

device ukbd
device hid
device usb

Or, if you're more of a "load it as a module at boot time" kinda girlie, put this line in loader.conf(5):

ukbd_load="YES"

See? Easy. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

The ukbd driver is literally the plug-and-play queen for keyboards that attach to the USB port. But here's the tea: you also need usb(4) and one of uhci(4) or ohci(4) configured in the kernel as well. Don't skip that part, bestie, or it's not gonna work. 😭


πŸŽ€ CONFIGURATION πŸŽ€

Okay so by default, the keyboard subsystem does not create the appropriate devices yet. I know, tragic. So make sure you reconfigure your kernel with this option in the kernel config file:

options KBD_INSTALL_CDEV

Now, if both an AT keyboard and USB keyboards are used at the same time, the AT keyboard will appear as kbd0 in /dev. The USB keyboards will be kbd1, kbd2, etc. You can see some info about the keyboard with this iconic command:

kbdcontrol -i < /dev/kbd1

Or load a keymap with:

kbdcontrol -l keymaps/pt.iso < /dev/kbd1

See kbdcontrol(1) for more possible options β€” it's lowkey a whole thing.

You can swap console keyboards by using this command:

kbdcontrol -k /dev/kbd1

From this point on, the first USB keyboard will be the keyboard used by the console. Slay. πŸ’…

Now, if you wanna use a USB keyboard as your default and never use an AT keyboard at all (main character energy), you'll have to remove the device atkbd line from the kernel configuration file. Because of the device initialization order, the USB keyboard will be detected after the console driver initializes itself, so you have to explicitly tell the console driver to use the existence of the USB keyboard. You can do this in one of two ways.

Option 1: Run this command as part of system initialization:

kbdcontrol -k /dev/kbd0 < /dev/ttyv0 > /dev/null

(Note that since the USB keyboard is the only keyboard, it's accessed as /dev/kbd0.) Or option 2: tell the console driver to periodically look for a keyboard by setting a flag in the kernel configuration file:

device sc0 at isa? flags 0x100

With the above flag, the console driver will try to detect any keyboard in the system if it didn't detect one while it was initialized at boot time. Iconic problem-solving, fr fr. πŸ”₯


🌈 DRIVER CONFIGURATION 🌈

Here are the driver config options, and yes they're all important:

  • ```c options KBD_INSTALL_CDEV
This makes the keyboards available through a character device in `/dev`. Basic but essential. ✨

- ```c
options UKBD_DFLT_KEYMAP
makeoptions UKBD_DFLT_KEYMAP=fr.iso

The above lines will put the French ISO keymap in the ukbd driver. You can specify any keymap in /usr/share/syscons/keymaps or /usr/share/vt/keymaps (depending on the console driver being used) with this option. So you can have a French keyboard if you're feeling fancy. πŸ‡«πŸ‡·

  • ```c options KBD_DISABLE_KEYMAP_LOADING
Do **not** allow the user to change the keymap. That's a no-no. 🚫

- ```c
options KBD_DELAY1=200

Set the keyboard initial key repeat delay. Numbers are exact, don't @ me.

  • ```c options KBD_DELAY2=15
Set the keyboard key repeat delay. Again, exact numbers.

> **Note bestie:** these options also affect the AT keyboard driver, `atkbd(4)`. So don't think you can escape them.

---

# ⭐ SYSCTL VARIABLES ⭐

These variables are available as both `sysctl(8)` variables *and* `loader(8)` tunables:

- **`hw.usb.ukbd.debug`** β€” Debug output level, where `0` is debugging disabled and larger values increase debug message verbosity. Default is `0`. So if you're debugging, crank it up, but otherwise leave it alone. πŸ™ˆ

---

# πŸ“ FILES πŸ“

- **`/dev/kbd*`** β€” blocking device nodes. That's it. That's the file. πŸ’…

---

# πŸ‘‘ EXAMPLES πŸ‘‘

device ukbd


Add the `ukbd` driver to the kernel. That's the example. You're welcome. 😌

---

# 🧚 SEE ALSO 🧚

`kbdcontrol(1)`, `ohci(4)`, `syscons(4)`, `uhci(4)`, `usb(4)`, `vt(4)`, `config(8)` β€” go read these if you wanna be a true Unix girlie. Iykyk. πŸ’–

---

# πŸ’œ AUTHORS πŸ’œ

The `ukbd` driver was written by **Lennart Augustsson** `<augustss@cs.chalmers.se>` for NetBSD and was substantially rewritten for FreeBSD by **Kazutaka YOKOTA** `<yokota@zodiac.mech.utsunomiya-u.ac.jp>`. Legends, honestly. πŸ‘‘

This manual page was written by **Nick Hibma** `<n_hibma@FreeBSD.org>` with a large amount of input from **Kazutaka YOKOTA** `<yokota@zodiac.mech.utsunomiya-u.ac.jp>`. So much collaboration, we love to see it. 🫢

---

And that's the tea, bestie! This page is from **Debian**, dated **April 24, 2018**, and it's the **UKBD(4)** man page. Stay slay! πŸ’–βœ¨
πŸ“¦ where this page comes from