Skip to content

Instantly share code, notes, and snippets.

@neeasade
Created May 18, 2015 05:14
Show Gist options
  • Save neeasade/2ba46c19ded209cc9f52 to your computer and use it in GitHub Desktop.
Save neeasade/2ba46c19ded209cc9f52 to your computer and use it in GitHub Desktop.
cParse.sh - xboxdrv script
#!/bin/sh
# cParse.sh
# a script to parse input from xboxdrv
# Usage : xboxdrv | cParse.sh
# makes cursor align with left joystick around a centerpoint
# depends on xdotool to do the cursor moving
# define a 'center' x,y
cX=400
cY=400
# range(radius of circle in pixels)
range=200
# only process every nth input (lag varies, xboxdrv has a lot of output)
countn=40
count=0
while read -r line ; do
if (( count % countn )); then
count=0
readX=$(echo $line | grep -oE "X1:......" | cut -c 4-)
readY=$(echo $line | grep -oE "Y1:......" | cut -c 4-)
if [[ ! -z $readX ]]; then
if [[ ! -z $readY ]]; then
curX=$(expr $cX \+ $(expr \( $range \* $readX \) / 32700))
curY=$(expr $cY \- $(expr \( $range \* $readY \) / 32700))
xdotool mousemove $curX $curY
fi
fi
else
count=$(expr $count + 1)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment