14th November 2011

How to use touchpad when screen is rotated?

So you have rotated display ('xrandr --orientation') and now touchpad ('synaptics') can't be used. The problem is that the touchpad maintains its original orientation, making the netbook difficult to use.

Here is a driver to allow the touchpad to calibrate to the screen orientation direction.

Discussed on:
eee user forum
ubuntu forum
Xorg-mailinglist
Ubuntu bug tracker
Ubuntu brainstorm

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

Video: on action with accelerometer (=automatic orientation detection)

News

2. November 2011
Added links.

1. November 2011
For Ubuntu (11.10) Oneiric wget http://cc.oulu.fi/~rantalai/synaptics/oneiric/125_enable_orientation.patch

16. January 2011
Vertical/Horizontal speed works (Maverick and newer). Credits to Nephiel.

23. October 2010
Precompiled binaries for Karmic, Lucid, Maverick (10.10).

28. June 2010
Patch for version 1.2.2. wget http://cc.oulu.fi/~rantalai/synaptics/125_enable_orientation_1.2.2.patch
Credits to 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)

Install patched driver using repository

This works with Karmic (Ubuntu 9.10), Lucid (10.04), Maverick (10.10), Natty (11.04) and Oneiric (11.10).
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.

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

If screen is not rotated from terminal?

If you are using widget or applet (or daemon) to handle rotating, e.g. Jupiter, this might be handy.

Change name of the xrandr to the xrandr.bin and make 'wrapper-script' named xrandr.
sudo mv /usr/bin/xrandr /usr/bin/xrandr.bin
paste text below to the /usr/bin/xrandr and make it executable:
sudo chmod a+x /usr/bin/xrandr
#!/bin/bash
#pass everything to the real xrandr
/usr/bin/xrandr.bin $*

#Check if there are --orientation parameter

counter=0
found=false

for i in $*
 do
 let "counter += 1"

 if [ "$found" = "true" ]
  then
   synclient Orientation=$i
  fi

 if [ "$i" = "--orientation" ]
  then
   found=true
 fi

done

exit 0

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 patches

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/

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 useful.
aapo(dot)rantalainen(at)gmail(dot)com

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