Shawn Rutledge

Ideally you should only need to run xorientd in your X11 session (add it to your .xinitrc, for example). When you rotate your tablet, the screen will automatically rotate.

This project has several goals:

  • provide liborient as a plain-C library with no dependencies, for the use of any program or graphical toolkit which needs to read the orientation of the screen via the accelerometer. (Treating it as a more fine-grained input device is out of scope at this time, although I might consider it.)

  • use liborient to implement xorientd, which will rotate the X11 screen as well as any pointer devices (such as touchscreens) that need to be rotated along with it; thus most X11 programs will not need to do anything except perhaps optimize layout depending on the window's aspect ratio

  • detect the typical accelerometers and touchscreens automatically

  • read from a config file to override settings or to avoid having to search for devices at startup

The first two PC tablet machines I have available for testing are a Lenovo S10-3t and an ExoPC. It turns out that both of them have joystick emulation for their accelerometers. So that's the first case which is supported. xorientd also detects the touchscreens on those machines and rotates them too. It's still not clear to me whether it's better to rotate the master pointer or just the touchscreen, and whether to do it with the arbitrary transform matrix or with the individual axis swap and inversion properties. So far I'm having better luck with the transform, on the touchscreen only. But the cursor is jumpy, and I don't understand why; it's as if only the drags are affected by the transform, but the "mouse" release events are not.

So far I know of the following interfaces that accelerometers can have:

  • /dev/input/jsX (joystick emulation)

  • /dev/input/eventX (generic evdev) (example: Galaxy Note running Android)

  • /sys/bus/iio/... (IIO for the I2C bus) (example: Nexus 7; if you use the Android kernel then you get the same interface regardless of distro, so e.g. KDE Plasma Active would need something like this to handle rotation)

For the long term, I think XInput and Wayland input protocols maybe should have accelerometer events; then xorientd would not need to read the device directly, and liborient could rather be used to write the drivers. But for now, I was surprised to find that none of the X11-based distributions for tablets do this automatic rotation at all, so wanted to come up with a solution for that.

Project admins:

Project Admins: