Has anyone actually gotten this to work?RDPUser wrote: ↑Sun Apr 08, 2018 7:36 pmI've also found this tutorial https://www.rmedgar.com/blog/using-rpi- ... definition and https://gist.github.com/gbaman/50b6cca61dd1c3f88f41 and I'm sure everything works, so that the Pi is recognized as keyboard. But how do I send keystrokes or mouse input to the PC?
I followed this tutorial:
which seems to have basically the same content as the first URL you quoted (the one at medgar.com).
I started with a Zero W that I had working as an ethernet gadget. As far as I can tell, the only thing I needed to do to make that work is put dtoverlay=dwc2 in config.txt. Following the tutorial above, I put these two lines in /etc/modules
These are the only non-comment lines in the file.
Upon reboot, the directory /sys/kernel/config/usb-gadget now exists (it did not exist before). So, this part is working. Note, incidentally, that the ethernet gadget functionality is still there - still working. Do I need to turn that off somehow?
Next, I created this executable file (note that I changed all references to iStick or whatever to something more neutral - the device is now called "mykeyboard" (as recommend in the URL that you quote)):
Code: Select all
#!/bin/bash cd /sys/kernel/config/usb_gadget/ mkdir -p mykeyboard cd mykeyboard 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 "Tobias Girstmair" > strings/0x409/manufacturer echo "mykeyboard USB Device" > 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 # Add functions here # see gadget configurations below 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
ls: device write protected or busy
(something like that - exact wording may not be right - but it was definitely "ls" that failed - that is the last command in the script)
And there is no file: /dev/hidg0
(I'm not sure where that name comes from, but it is my understanding that that is supposed to be the end result of all this messing about).
I also don't understand what the point of that "ls" command is, but apparently it is critical.