Last active
February 24, 2023 22:41
-
-
Save mtlynch/906534da530482e9afcf1e1309b3dbbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set TinyPilot to jiggle the mouse every 3 seconds. | |
# Author: Michael Lynch | |
# https://tinypilotkvm.com | |
# License: MIT License | |
set -e | |
set -u | |
# Change the value below to any you want | |
readonly TIME_BETWEEN_JIGGLES="3s" | |
i=0 | |
while true | |
do | |
echo "$(date --iso-8601=seconds):" "Moving mouse cursor" | |
if (( $i % 2 )); then | |
echo -ne "\0\x03\x16\x58\x4c\0\0" > /dev/hidg1 | |
else | |
echo -ne "\0\xbc\x1b\xdd\x2a\0\0" > /dev/hidg1 | |
fi | |
i=$((i+1)) | |
sleep "${TIME_BETWEEN_JIGGLES}" | |
done |
@domdorn - Sure, they're USB HID messages. You can see how they're generated here:
They correspond to the USB HID descriptor we use for TinyPilot, which you can see here:
This blog post has a good explanation about USB HID messages. It's about keystrokes, but a lot of the concepts apply to the mouse movement messages as well:
https://www.rmedgar.com/blog/using-rpi-zero-as-keyboard-send-reports/
And if you want to get really down into the technical details, here's the full spec:
https://www.usb.org/document-library/device-class-definition-hid-111
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is there a documentation somewhere what these hex values mean? I'd like to understand them to make my own scripts for tinypilot mouse movement.