added hid config script

This commit is contained in:
Rudis Muiznieks 2022-03-06 13:54:24 -06:00
parent a3aae0a949
commit 2c1aef1343
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
2 changed files with 29 additions and 0 deletions

View File

@ -23,3 +23,5 @@ The lamest things are than my Pi Zero is the model with no built-in storage, so
- [Turn Your Raspberry Pi Zero into a USB Keyboard (HID)](https://randomnerdtutorials.com/raspberry-pi-zero-usb-keyboard-hid/)
- [USB Keyboard Emulation with the Raspberry Pi Zero](https://www.makerhacks.com/usb-keyboard-emulation-with-the-raspberry-pi-zero/)
- [Getting started with gpiozero](https://dronebotworkshop.com/raspberry-pi-gpio/)
![Rasberry Pi Zero Pinout Diagram](https://tutorials-raspberrypi.de/wp-content/uploads/Raspbery-Pi-GPIO-Pin-Belegung.png)

27
raspi_config/hid_usb Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
cd /sys/kernel/config/usb_gadget
mkdir -p usb_hid
cd usb_hid
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 "fedcba9876543210" > strings/0x409/serialnumber
echo "Rudis Muiznieks" > strings/0x409/manufacturer
echo "Button Buddy" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
# functions
mkdir -p functions/hid.usb0
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/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.usb0/report_desc
ln -s functions/hid.usb0 configs/c.1
# end functions
ls /sys/class/udc > UDC