|
New set of report descriptors
1. N key keyboard in 2 reports has f13-f24
2. Joystick with 64 buttons 12 axis 4 hats
3. Dual xbox style gamepads in 2 reports
- #!/bin/bash
- set -x
- # Create gadget
- mkdir /sys/kernel/config/usb_gadget/mykeyboard
- cd /sys/kernel/config/usb_gadget/mykeyboard
- # Add Device Descriptor information
- echo 0x0100 > bcdDevice # Version 1.0.0
- echo 0x0200 > bcdUSB # USB 2.0
- echo 0x00 > bDeviceClass
- echo 0x00 > bDeviceProtocol
- echo 0x00 > bDeviceSubClass
- echo 0x22 > bMaxPacketSize0
- echo 0x6969 > idProduct # Keyboard Joystick Composite Gadget
- echo 0x1d6b > idVendor # Linux Foundation
- # Create English locale
- mkdir strings/0x409
- echo "Languid" > strings/0x409/manufacturer
- echo "keyboard, joystick, dual gamepad"> strings/0x409/product
- echo "0123456789" > strings/0x409/serialnumber
- # Create configuration descriptor
- mkdir configs/c.1
- mkdir configs/c.1/strings/0x409
- echo 0x80 > configs/c.1/bmAttributes
- echo 200 > configs/c.1/MaxPower # 200 mA
- echo 0 > configs/c.1/iConfiguration
- echo "Composite configuration" > configs/c.1/strings/0x409/configuration
- # Create HID endpoints
- # Create keyboard
- keyboard() {
- # Create interface descriptor information
- mkdir functions/hid.usb0
- echo 1 > functions/hid.usb0/protocol
- echo 8 > functions/hid.usb0/report_length # 8-byte reports
- echo 0 > functions/hid.usb0/subclass
- # Write report descriptor, keyboard 2 parts ID:1,2
- echo "05010906a1018501050719e029e71425017501950881021904293b95388102c005010906a10185020507193c29651425017501952a810219672973950d810295098102c0" | xxd -r -ps > functions/hid.usb0/report_desc
- ln -s functions/hid.usb0 configs/c.1
- }
- # Create extreme joystick
- joystick() {
- # Create interface descriptor information
- mkdir functions/hid.usb1
- echo 0 > functions/hid.usb1/protocol
- echo 34 > functions/hid.usb1/report_length # 34-byte reports
- echo 0 > functions/hid.usb1/subclass
- # Write report descriptor, stolen from teensy forum extreme joystick
- # Write 64 bytes to the following endpoint in the same order as listed
- # buttons 64 so 64/8 = 8 bytes
- # axis and sliders 12 for x,y,z,R(x),R(y),R(z),Slider*6 so 12*2 = 24 bytes
- # hats 4 so 4*.5 = 2 bytes
- echo "05010904a1010509142501750195401901294081020b01000100a01427ffff0000751095060b300001000b310001000b320001000b330001000b340001000b350001008102c00b01000100a01427ffff0000751095060b360001000b360001000b360001000b360001000b360001000b360001008102c00b01000100a014250734463b017504950465140b390001000b390001000b390001000b390001008142c0c0" | xxd -r -ps > functions/hid.usb1/report_desc
- ln -s functions/hid.usb1 configs/c.1
- }
- # Create dual gamepad, index by "Report ID"
- gamepad() {
- # Create interface descriptor information
- mkdir functions/hid.usb2
- echo 0 > functions/hid.usb2/protocol
- echo 7 > functions/hid.usb2/report_length # 7-byte report includes Report ID
- echo 0 > functions/hid.usb2/subclass
- # Write report descriptor, stolen from some guys tutorial on
- # doing composite report ID thing, microsoft shows both devices
- # Format..
- # report id, need to include or it won't work
- # buttons
- # buttons
- # X
- # Y
- # Z
- # R(x)
- echo "05010905A101A100850105091901291015002501951075018102050109300931093209331581257F750895048102C0C005010905A101A100850205091901291015002501951075018102050109300931093209331581257F750895048102C0C0" | xxd -r -ps > functions/hid.usb2/report_desc
- ln -s functions/hid.usb2 configs/c.1
- }
- # Link HID function to configuration
- keyboard
- joystick
- gamepad
- # Enable gadget
- ls /sys/class/udc > UDC
Copy code |
|