I got a new laptop in January 2008, an HP 2150p. It has a great feature: hard disk protection when the laptop falls. Well, by itself I don't think it's a great feature at all, I'd rather stay very careful and never let the laptop fall at all. However, what this meant is that it contains an accelerometer. Since I discovered this, I've wanted to have a great feature, the same one which is available on the expensive phones (like the iPhone) and in some photo cameras (like my Canon A530), the screen automatically rotates when you physically rotate the device. It's especially useful when reading articles or books: you open the file, rotate the computer and suddenly one page = one screen.
Before going further, let's recap why an accelerometer is useful for this. An accelerometer measures the acceleration, so shouldn't it detect something only when it moves, and not when it is standing rotated or not? Well, all the trick is that we can assume the user is on earth (or a planet more generally), and that the user keeps his fits on the ground. The beauty of the accelerometer is that it detect all the accelerations, including G, the gravity! So, assuming that you are on earth and that you are not taking off in a rocket plane, the main acceleration vector indicates the direction of the ground... so convenient!
Getting the functionality working in Linux was not so hard. Mainly because Yan Burman had already tackled the main problem of writing a driver for the accelerometer. However, the real fun is to have it as a default feature for anyone using Linux. Having the ad-hoc solution is fine, but the generic solution is worth thousand times more! For this, I ended up becoming the maintainer of the driver (now named lis3lv02d) and it got recently accepted in Linus' tree. It will be part of 2.6.28...
But that's merely half the journey. We need also a daemon which observes the data obtained by the accelerometer and rotates the screen accordingly. For now I have my own little script which does this. On the long term it would be good to have it integrated with the normal desktop. Let's say at least in Gnome, I would like to get this feature integrated with the new xrandr plugin.
Last but not least, after some usage I realised that there is an annoying problem when rotating the screen with the laptop: the touchpad stays not rotated. Moving the cursor requires some special mental training! So, the obvious question is how to do that. There is unfortunately no directly available solutions. However, I'm hopeful that with the Input Device Properties that Peter Hutterer added to Xorg, plus the work by Mildred Ki'Lya for changing the rotation of the synaptic touchpad driver. To be totally generic, it would be better if any input device could be rotated (the same way), especially the evdev driver should support this as well...
So the complete ad-hoc solution is nearly there, but not yet. And the generic and upstream solution still needs lots of integration at various levels... but it's on its way! Whoever is also interested is welcome to try to create patchs (for Gnome, for Xorg) and share them.
Tuesday, November 25, 2008
Saturday, November 8, 2008
Xorg documentation: what a pain
X.Org provides the official reference implementation of the X Window System. Being the reference, one can expect it to find a default implementation as well as the description of its behaviour and the behaviour of the client applications with the server. Unfortunately, this is done extremely badly, amazingly badly. Up to the point that today, when looking for the description of the XV protocol (you know, the technology that allows you to watch video without overheating your processor), I got lost in their minimalistic wiki, found nothing in google, passed via wikipedia, and ended up in the cvs of the old xfree which has an update in a different file. In the X.Org website all I could find was this page about the conversion of all the documentation to DocBook which doesn't even mention where are the converted documentations!
It's really a pity, because it's make it even harder to code or to debug X. I wish they had something organized as well as the gnome/glib documentation. Actually, on the book shelves of the university, there are a couple of huge official old books on the X reference, so at least an outdated documentation must be exist, it's just impossible to find. If you know, please update the X.Org wiki!
It's really a pity, because it's make it even harder to code or to debug X. I wish they had something organized as well as the gnome/glib documentation. Actually, on the book shelves of the university, there are a couple of huge official old books on the X reference, so at least an outdated documentation must be exist, it's just impossible to find. If you know, please update the X.Org wiki!
Subscribe to:
Posts (Atom)