The device can be opened and closed even without a keyboard connected. Performing an ioctl on the device in this state will simply block forever.
Writes are used the send commands to the driver. This is for controlling the keyboard LEDs. Writes are always 5 bytes in length.
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 is blocking.
Message type is one of the following:
You will always be properly notified of available keyboards. This means that when the device is opened ''after'' the keyboard is connected, a keyboard connect event is still received as the very first message.
The modifiers are a bitmask of the following:
The key data is an array of bytes with key codes. The codes are probably passed directly from the keyboard as they correspond to the table in the USB HID Usage Tables Chapter 10 (Keyboard/Keypad Page), available [http://www.usb.org/developers/hidpage/ here].