9 Nov 2013

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

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

News

Changelog

Solution (Ubuntu related)

Install patched driver using repository

Works with Ubuntu 9.10 - Ubuntu 13.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 could crash/reboot your X).
wget http://cc.oulu.fi/~rantalai/synaptics/125_enable_orientation.patch
patch -p1 < 125_enable_orientation.patch
./autogen.sh
make

#synclient (tool): backup and take new in use:
cp /usr/bin/synclient original_synclient
sudo cp tools/synclient /usr/bin

#driver: backup, remove, take new in use
cp /usr/lib/xorg/modules/input/synaptics_drv.so original_synaptics_drv.so
sudo rm /usr/lib/xorg/modules/input/synaptics_drv.so && 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).