Skip to content

v1nc/Raspberry-Zero-Mouse-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Raspberry-Zero-Mouse-Simulation

Simulate mouse and keyboard via Raspberry Pi OTG

There are many tutorials how to simulate keyboard input with the Raspberry Pi zero, but no good how to simulate mouse movement. Here is a reliable way.

  1. Preparation:
echo "dwc2" >> /etc/modules
echo "libcomposite" >> /etc/modules
echo "dtoverlay=dwc2" >> /boot/config.txt
  1. Copy HID file:
cp usb-hid /usr/bin/
  1. Add /usr/bin/usb-hid to rc.local
  2. Reboot
  3. Clone https://github.com/aagallag/hid_gadget_test
  4. make
  5. chmod +x hid-gadget-test
  6. Use hid-gadget-test to use the mouse:
# move mouse (100,100)
echo ' 100 100' | ./hid-gadget-test/dev/hidg0 mouse > /dev/null
# move mouse (100,100) and hold button b1
echo '--hold --b1 100 100' | ./hid-gadget-test /dev/hidg0 mouse > /dev/null

If you get something error like Cannot send after transport endpoint shutdown, the Raspberry Pi is not properly connected to your device or was not recognized. Reconnect your cables!

About

Simulate mouse and keyboard via Raspberry Pi OTG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages