28. June 2010

How to use synaptics touchpad when screen is rotated with xrandr --orientation?

Do you use laptop rotated with xrandr --orientation? Then you may noticed that touchpad do not work rigth.
"Running 'xrandr -o right' in a terminal will rotate the screen so that it's portrait-format and a lot easier when reading long articles. The slight problem though is that using the touchpad with the laptop turned 90 degrees is next to impossible, as ones brain can't work out which way to move ones fingers in order to get the desired result".
Look:
eee user forum
ubuntu forum


Click if you use hardy or even older Ubuntu.
Click if you use jaunty (9.04)

News

28. June 2010
Patch for version 1.2.2. wget http://cc.oulu.fi/~rantalai/synaptics/125_enable_orientation_1.2.2.patch
Credits for Daniel Bartlett.

9. April 2010
Fixed: Examples how to use synclient (Thanks to George Zarubin pointing this).

6. April 2010
Added dep-building.
Added PPA-repository (precompiled drivers for Karmic)

11. November 2009
This introduction and patch is for Ubuntu 9.10 (Karmic) and synaptics-1.1.2 (it is the version on Karmic).
Credits for this updated patch goes to Qfeng Chen. Thanks.


Solution (Ubuntu related)

Using repository

This is for Karmic (Ubuntu 9.10) and Lucid (10.04).
Add my PersonalPackageArchive, update catalogs, and install new package:
sudo add-apt-repository ppa:aapo-rantalainen/ppa-aaporantalainen
sudo apt-get update
sudo apt-get install xserver-xorg-input-synaptics
And when you next time boot X, new driver will be in use.

Compiling from sources

We change two files, driver and synclient:

Driver file is synaptics_drv.so and is located /usr/lib/xorg/modules/input/.
Synclient is application to change parameters of synaptics. When you compile it, it will be in tools/synclient. In system you can find it from /usr/bin

Dependencies for compiling

You need build-essentials to compile (almost) anything. If you do not have it, install it now. And automake is also needed. Additional you need dependency packages.
sudo apt-get install build-essential automake
sudo apt-get build-dep xserver-xorg-input-synaptics 
And then get the sources of driver.
mkdir patched_synaptics
cd patched_synaptics
apt-get source xserver-xorg-input-synaptics 
cd xserver-xorg-input-synaptics-*


You have two ways to do this. First is more automatic and it will make same driver what you are using in Ubuntu, added with this patch. Second takes vanilla upstream and only adds this patch.

A) Make modifications to Ubuntu's driver

wget http://cc.oulu.fi/~rantalai/synaptics/125_enable_orientation.patch
cp 125_enable_orientation.patch debian/patches
echo "125_enable_orientation.patch" >> debian/patches/series
fakeroot dpkg-buildpackage -b
cd ..
sudo dpkg -i xserver-xorg-input-synaptics*.deb 

And when you next time boot X, new driver will be in use.

B) Compile without Ubuntu's pathces

Last command will crash/reboot your X.
wget http://cc.oulu.fi/~rantalai/synaptics/125_enable_orientation.patch
patch -p1 < 125_enable_orientation.patch
./autogen.sh
make
#backup:
cp /usr/lib/xorg/modules/input/synaptics_drv.so original_synaptics_drv.so
cp /usr/bin/synclient original_synclient
sudo cp tools/synclient /usr/bin
sudo cp src/.libs/synaptics_drv.so /usr/lib/xorg/modules/input/

Usage

Commandline syntax is: (This will change axis like screen is rotated to left.)
synclient Orientation=1

I think easiest way is to make scripts that orient the screen and change axis in the same time. Then you can make shortcuts and what ever you want.
At least, with this list you can check synclient Orientation parameter meanings.

synclient Orientation=0 ; xrandr --orientation normal
synclient Orientation=1 ; xrandr --orientation left
synclient Orientation=2 ; xrandr --orientation inverted
synclient Orientation=3 ; xrandr --orientation right
Or (e.g.)
synclient Orientation=3 && xrandr -o 3

Troubleshooting

Even something went wrong with driver, X will still start and mouse pointer moves. But axis do not swap, tapping/scrolling etc not work.
First check your Xorg.log
cat /var/log/Xorg.0.log | grep -i "synaptics"
It says very clear is driver loaded or not.


Feedback

All testing and comments are very usefull.
aapo(dot)rantalainen(at)gmail(dot)com

This text can be used in any way (public domain).