[Feature Request] Add the possibility to map a joystick to absolute mouse position.
When remapping a controller analog stick, I'd like to have it set the absolute mouse position. For instance, when the analog is centered, the mouse stays in place, as the analog goes to the left, the mouse pointer follows until it reaches a certain distance from it's original position. When the analog returns to it's centered position, then the mouse returns to it's original position.
In short, the mouse follows the analog stick.
More specifically, let's say the initial mouse position is at 500,500 Moving the analog all the way to the left would make the mouse travel to 200,500 Returning the analog to it's center, would make the mouse move back to 500,500 Moving the analog all the way to the right, would make the mouse travel to 800,500 So on and so forth.
In the above example, the area that the mouse can travel is set to 600x600. There could be an option to set how large is the area that the mouse can travel.
This would obviously limit the area that the mouse can travel, but it would be used to play games that support mouse flying and such.
I wrote a simple bash script to demonstrate the functionality:
js='/dev/input/js0'
range=360
center_x=640
center_y=360
mult=`echo "1.0 / 32767.0 * $range" | bc -l`
while [ true ]
do
X=`jstest --event $js | grep -m 1 "type 2, time .*, number 0, value .*" | cut -d' ' -f9`
Y=`jstest --event $js | grep -m 1 "type 2, time .*, number 1, value .*" | cut -d' ' -f9`
X=`echo "$X * $mult + $center_x" | bc`
Y=`echo "$Y * $mult + $center_y" | bc`
echo "$X $Y"
xdotool mousemove $X $Y
done
This, of course, is extremely slow and unusable, but serves to demonstrate how it could be implemented.
Alternatively, a way to modify the center coordinate can be implemented, by just adding the mouse relative motion to the stored center variable, allowing the normal use of the mouse while the tool is active.
this automatically wouldn't work for many users who use window managers other than x11
this automatically wouldn't work for many users who use window managers other than x11
The bash code is simply to represent the logic and serves as an example algorithm, it's not supposed to be implemented as is.