From WiiBrew
< /dev‎ | usb
Jump to navigation Jump to search


/dev/usb/kbd is the interface to the USB keyboard driver.

Reads, seeks and ioctlvs always fail. Writes are used to send commands. Ioctls are used to receive events.


Writes are used the send commands to the driver. This is for controlling the keyboard LEDs. Writes are always 5 bytes in length.

Available commands:
Write data Function
00 00 00 00 80 Turn off keyboard LEDs.
?? ?? ?? ?? 00 Unknown
?? ?? ?? ?? 00 Unknown
?? ?? ?? ?? 00 Unknown
?? ?? ?? ?? 00 Unknown


Ioctls are used to read keyboard events. All parameters except the output buffer are ignored. The buffer should be 16 bytes in size and will be filled with the event data. Note that the ioctl will block.

Event data format
Offset Length Contents
0 8 Unknown
8 1 (or 2?) Modifiers
10 6 Pressed keys


The modifiers are a bitmask of the following:

Bit no. Hex value Description
1 0x01 Left control
2 0x02 Left shift
3 0x04 Left alt / left meta
4 0x08 Left super / left windows key
Bit no. Hex value Description
5 0x10 Right control
6 0x20 Right shift
7 0x40 Right alt / right meta / alt gr
8 0x80 Right super / right windows key

Key data

The key data is an array of bytes with key codes. These do not seem to match common scancodes, but are more like values in a character table (like ASCII, but not).

Each byte represents a pressed key. When a key is pressed, a new event will arrive with the key added to the array. Once a key is released, a new event will arrive with the key simply removed from the array.

The array is 6 bytes long, so no more than 6 simultaneous key presses can be detected. On top of that, most keyboards will barf on certain combinations. If an error occurs, a new event will arrive with all elements of the array set to 0x01.