Created
May 18, 2015 05:14
-
-
Save neeasade/2ba46c19ded209cc9f52 to your computer and use it in GitHub Desktop.
cParse.sh - xboxdrv script
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/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