Skip to content

Instantly share code, notes, and snippets.

@alexvanyo
Created October 11, 2018 23:02
Show Gist options
  • Save alexvanyo/408870730c5337111ef07b23d48ed742 to your computer and use it in GitHub Desktop.
Save alexvanyo/408870730c5337111ef07b23d48ed742 to your computer and use it in GitHub Desktop.
HID Descriptor for use with HID Synergy
#!/bin/bash
# Snippet from https://github.com/girst/hardpass-sendHID/blob/master/README.md . In which, the following notice was left:
# this is a stripped down version of https://github.com/ckuethe/usbarmory/wiki/USB-Gadgets - I don't claim any rights
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir -p g1
cd g1
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "314159" > strings/0x409/serialnumber
echo "alexvanyo" > strings/0x409/manufacturer
echo "Raspbery Pi Zero W HID" > strings/0x409/product
A_N="mouse"
mkdir -p functions/hid.$A_N
echo 2 > functions/hid.$A_N/protocol
echo 1 > functions/hid.$A_N/subclass
echo 3 > functions/hid.$A_N/report_length
echo -ne \\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x03\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x02\\x81\\x06\\xc0\\xc0 > functions/hid.$A_N/report_desc
B_N="keyboard"
mkdir -p functions/hid.$B_N
echo 1 > functions/hid.$B_N/protocol
echo 1 > functions/hid.$B_N/subclass
echo 8 > functions/hid.$B_N/report_length
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.$B_N/report_desc
C_N="touch"
mkdir -p functions/hid.$C_N
echo 0 > functions/hid.$C_N/protocol
echo 0 > functions/hid.$C_N/subclass
echo 5 > functions/hid.$C_N/report_length
echo -ne \\x05\\x0d\\x09\\x02\\xa1\\x01\\x09\\x20\\xa1\\x00\\x09\\x42\\x09\\x32\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x02\\x81\\x02\\x75\\x01\\x95\\x06\\x81\\x01\\x05\\x01\\x09\\x01\\xa1\\x00\\x09\\x30\\x09\\x31\\x15\\x00\\x26\\xff\\x00\\x35\\x00\\x46\\xff\\x00\\x65\\x00\\x75\\x10\\x95\\x02\\x81\\x02\\xc0\\xc0\\xc0 > functions/hid.$C_N/report_desc
D=1
mkdir -p configs/c.$D/strings/0x409
echo "Config $D: ECM network" > configs/c.$D/strings/0x409/configuration
echo 250 > configs/c.$D/MaxPower
ln -s functions/hid.$A_N configs/c.$D/
ln -s functions/hid.$B_N configs/c.$D/
ln -s functions/hid.$C_N configs/c.$D/
ls /sys/class/udc > UDC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment