Update hid-setup.sh
This commit is contained in:
+27
-8
@@ -1,7 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
G=/sys/kernel/config/usb_gadget/hidg
|
G=/sys/kernel/config/usb_gadget/hidg
|
||||||
|
|
||||||
mkdir $G
|
# Clean up old gadget if it exists
|
||||||
|
if [ -d $G ]; then
|
||||||
|
echo "" > $G/UDC 2>/dev/null || true
|
||||||
|
rm -rf $G
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $G
|
||||||
cd $G
|
cd $G
|
||||||
|
|
||||||
echo 0x1d6b > idVendor
|
echo 0x1d6b > idVendor
|
||||||
@@ -9,25 +15,38 @@ echo 0x0104 > idProduct
|
|||||||
echo 0x0100 > bcdDevice
|
echo 0x0100 > bcdDevice
|
||||||
echo 0x0200 > bcdUSB
|
echo 0x0200 > bcdUSB
|
||||||
|
|
||||||
mkdir strings/0x409
|
mkdir -p strings/0x409
|
||||||
echo "1234567890" > strings/0x409/serialnumber
|
echo "1234567890" > strings/0x409/serialnumber
|
||||||
echo "Raspberry Pi" > strings/0x409/manufacturer
|
echo "Raspberry Pi" > strings/0x409/manufacturer
|
||||||
echo "Pi Zero HID" > strings/0x409/product
|
echo "Pi Zero HID" > strings/0x409/product
|
||||||
|
|
||||||
mkdir configs/c.1
|
mkdir -p configs/c.1
|
||||||
mkdir functions/hid.keyboard
|
mkdir -p configs/c.1/strings/0x409
|
||||||
|
echo "Config 1" > configs/c.1/strings/0x409/configuration
|
||||||
|
|
||||||
|
# Keyboard
|
||||||
|
mkdir -p functions/hid.keyboard
|
||||||
echo 1 > functions/hid.keyboard/protocol
|
echo 1 > functions/hid.keyboard/protocol
|
||||||
echo 1 > functions/hid.keyboard/subclass
|
echo 1 > functions/hid.keyboard/subclass
|
||||||
echo 8 > functions/hid.keyboard/report_length
|
echo 8 > functions/hid.keyboard/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.keyboard/report_desc
|
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.keyboard/report_desc
|
||||||
|
|
||||||
mkdir functions/hid.mouse
|
# Mouse
|
||||||
|
mkdir -p functions/hid.mouse
|
||||||
echo 2 > functions/hid.mouse/protocol
|
echo 2 > functions/hid.mouse/protocol
|
||||||
echo 1 > functions/hid.mouse/subclass
|
echo 1 > functions/hid.mouse/subclass
|
||||||
echo 4 > functions/hid.mouse/report_length
|
echo 4 > functions/hid.mouse/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.mouse/report_desc
|
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.mouse/report_desc
|
||||||
|
|
||||||
ln -s functions/hid.keyboard configs/c.1/
|
ln -s functions/hid.keyboard configs/c.1/
|
||||||
ln -s functions/hid.mouse configs/c.1/
|
ln -s functions/hid.mouse configs/c.1/
|
||||||
|
|
||||||
ls /sys/class/udc > UDC
|
# Wait for UDC to appear
|
||||||
|
sleep 0.5
|
||||||
|
|
||||||
|
UDC=$(ls /sys/class/udc | head -n 1)
|
||||||
|
echo "$UDC" > UDC
|
||||||
|
|||||||
Reference in New Issue
Block a user