/dev/usb/kbd
This is an old revision of this page, as edited by Kosinus (talk | contribs) at 15:27, 23 March 2008. It may differ significantly from the current revision. |
This article is a stub. You can help WiiBrew by expanding it. |
Contents
Description
/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.
Write
Writes are used the send commands to the driver. This is for controlling the keyboard LEDs. Writes are always 5 bytes in length.
Write data | Function |
---|---|
00 00 00 00 80 | Turn off keyboard LEDs. |
?? ?? ?? ?? 00 | Unknown |
?? ?? ?? ?? 00 | Unknown |
?? ?? ?? ?? 00 | Unknown |
?? ?? ?? ?? 00 | Unknown |
Ioctl
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.
Offset | Length | Contents |
---|---|---|
8 | 1 or 2? | Modifiers |
10 | 6 | Pressed keys |
Modifiers
The modifiers are a bitmask of the following:
Bit no. | Hex value | Description | Bit no. | Hex value | Description |
---|---|---|---|---|---|
1 | 0x01 | Left control | 5 | 0x10 | Right control |
2 | 0x02 | Left shift | 6 | 0x20 | Right shift |
3 | 0x04 | Left alt / left meta | 7 | 0x40 | Right alt / right meta / alt gr |
4 | 0x08 | Left super / left windows key | 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.