The thinkpad laptops have an internal accelerometer that could be easy used as joystick or included in script using sys filesystem.
We are going to download the sources and module assistant to take care of the installation.
apt-get install tp-smapi-source module-assistant
Module assistant will download kernel headers and any utilities needed to compile.
m-a a-i tp-smapi
We are going to load one by one in verbose.
modprobe -v thinkpad_ec
modprobe -v hdaps
Start the command and move your laptop. It will show you X and Y coordinates belonging to axis 0 and 1
while true; do cat /sys/devices/platform/hdaps/position ; sleep 1; done