Creating a USB gadget device that exposes a HID keyboard can involve some cryptic settings, especially for developers who just want to send keyboard events without diving into the USB spec. An example of this configuration can be found in Xebow's hid_gadget.ex file:
# 6-key-rollover descriptor:
# 05 01 09 06 A1 01 05 07 19 E0 29 E7 15 00 25 01
# 75 01 95 08 81 02 81 01 19 00 29 FF 15 00 25 FF
# 75 08 95 06 81 00 05 08 19 01 29 05 15 00 25 01
# 75 01 95 05 91 02 95 03 91 01 C0
# n-key-rollover descriptor:
# 05 01 09 06 A1 01 75 01 95 08 15 00 25 01 05 07
# 19 E0 29 E7 81 02 75 01 95 05 05 08 19 01 29 05
# 91 02 75 03 95 01 91 03 75 01 95 F8 15 00 25 01
# 05 07 19 00 29 F7 81 02 C0
hid_settings = %{
"protocol" => "1",
"report_length" => "8",
"subclass" => "1",
"report_desc" =>
<<0x05, 0x01, 0x09, 0x06, 0xA1, 0x01, 0x05, 0x07, 0x19, 0xE0, 0x29, 0xE7, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x81, 0x01, 0x19, 0x00, 0x29, 0xFF,
0x15, 0x00, 0x25, 0xFF, 0x75, 0x08, 0x95, 0x06, 0x81, 0x00, 0x05, 0x08, 0x19, 0x01,
0x29, 0x05, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x05, 0x91, 0x02, 0x95, 0x03,
0x91, 0x01, 0xC0>>
}
AFK could encapsulate USB configuration into one or more helpers, like:
hid_settings = AFK.USB.create_hid_settings(rollover_type: :six_key)
Creating a USB gadget device that exposes a HID keyboard can involve some cryptic settings, especially for developers who just want to send keyboard events without diving into the USB spec. An example of this configuration can be found in Xebow's
hid_gadget.exfile:AFK could encapsulate USB configuration into one or more helpers, like: