i'm trying to send the coordinates of mouse connected to a raspberry pi to an ESP8266 in the same network. I just wrote this bash script
#!/bin/bash
device='/dev/input/event1'
mouseX="*(REL_X), value*"
mouseY="*(REL_Y), value*"
evtest "$device" | while read line; do
case $line in
($mouseX) X=${line##*value }
curl 'http://192.168.0.4/ricevuto?X='"$X" &
;;
($mouseY) Y=${line##*value }
curl 'http://192.168.0.4/ricevuto?Y='"$Y" &
;;
esac
done
the command "evtest" capture the mouse movements and the script extract the coordinates, curl send the data.
It works, but it's really SLOW! With the "&" at the end of the curls is faster but sometimes the coordinates are messed up... Is there a way to establish a connection and just transmit data without make a request everytime?
Just to explain my final goal: i'm trying to use a mouse, connected to a raspberry pi, on multiple devices: in this case the receiver (esp8266) will be connected to a arduino leonardo that can recreate the mouse movement on an android TV. Thanks for the help or any other simpler solution!