/dev/usb/kbd: Difference between revisions
Useful info arrives! |
m Slightly prettify both the page and the formatting |
||
| Line 13: | Line 13: | ||
|+ Available commands: | |+ Available commands: | ||
|- | |- | ||
! Write data | ! Write data !! Function | ||
! Function | |||
|- | |- | ||
| 00 00 00 00 80 | | 00 00 00 00 80 || Turn off keyboard LEDs. | ||
| Turn off keyboard LEDs. | |||
|- | |- | ||
| ?? ?? ?? ?? 00 | | ?? ?? ?? ?? 00 || Unknown | ||
| Unknown | |||
|- | |- | ||
| ?? ?? ?? ?? 00 | | ?? ?? ?? ?? 00 || Unknown | ||
| Unknown | |||
|- | |- | ||
| ?? ?? ?? ?? 00 | | ?? ?? ?? ?? 00 || Unknown | ||
| Unknown | |||
|- | |- | ||
| ?? ?? ?? ?? 00 | | ?? ?? ?? ?? 00 || Unknown | ||
| Unknown | |||
|} | |} | ||
| Line 39: | Line 33: | ||
|+ Event data format | |+ Event data format | ||
|- | |- | ||
! Offset | ! Offset !! Length !! Contents | ||
! Length | |||
! Contents | |||
|- | |- | ||
| 8 | | 0 || 8 || Unknown | ||
| | |||
|- | |- | ||
| 10 | | 8 || 1 (or 2?) || [[#Modifiers|Modifiers]] | ||
| 6 | |- | ||
| [[#Key data|Pressed keys]] | | 10 || 6 || [[#Key data|Pressed keys]] | ||
|} | |} | ||
| Line 55: | Line 45: | ||
The modifiers are a bitmask of the following: | The modifiers are a bitmask of the following: | ||
{| border="1" | {| border="1" style="text-align: center; float: left; border: padding: 4px;" | ||
| | |- | ||
! 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 | |||
|} | |||
{| border="1" style="text-align: center; float: left; border: padding: 4px;" | |||
|- | |- | ||
! Bit no. | ! Bit no. !! Hex value !! Description | ||
! Hex value | |||
! | |||
! Description | |||
|- | |- | ||
| | | 5 || 0x10 || Right control | ||
| | |||
| | |||
| | |||
| Right control | |||
|- | |- | ||
| | | 6 || 0x20 || Right shift | ||
| | |||
| | |||
| | |||
| Right shift | |||
|- | |- | ||
| | | 7 || 0x40 || Right alt / right meta / alt gr | ||
| | |||
| | |||
| | |||
| Right alt / right meta / alt gr | |||
|- | |- | ||
| | | 8 || 0x80 || Right super / right windows key | ||
| | |||
| | |||
| | |||
| Right super / right windows key | |||
|} | |} | ||
<div style="clear:both;"></div> | |||
===Key data=== | ===Key data=== | ||
Revision as of 15:34, 23 March 2008
| This article is a stub. You can help WiiBrew by expanding it. |
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 |
|---|---|---|
| 0 | 8 | Unknown |
| 8 | 1 (or 2?) | Modifiers |
| 10 | 6 | Pressed keys |
Modifiers
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.