25May

The Thinkpad Yoga and Ubuntu 12.

Posted by Elf Sternberg as Uncategorized

I hate being made to feel like a fool, especially by a software bug. I wasted four hours over the past two days trying to get my new Lenovo Yoga’s touchscreen to work. It was fine in desktop mode, but rotated (for tablet mode) or inverted (for media mode), and the touchscreen’s geometry would freak out; the touchscreen pointer wouldn’t track anymore, gestures stopped working, it was a pain.

I tried using the event driver (evdev) settings, both “Axes Swap” and “Axis Inversion”. It didn’t help. I got desperate, and tried to teach myself the Coordinate Transformation Matrix, but that link is one brutally nasty “If you can’t do matrix math, I’m not stupid enough to help you” bit of writing. I am knowledgeable enough to do matrix math, but his explanation is as clear as landfill, and about as useful.

It turns out that none of my confusion was my fault. There’s a bug xf86-input-evdev-2.7, the version that ships with Ubuntu 12 (Quantal). It doesn’t handle rotation or inversion well on the ELAN Touchscreens that ship with the Yoga. It’s somewhat understandable– the Yoga is a very new piece of hardware– but damn, it’s annoying.

I downloaded, compiled and installed xf86-input-evdev-2.8, and now it works. I have only keyboard-issued orientation working, but it’s a start. The keyboard program is simple:

#!/bin/bash
ARG=$1
CMD=${ARG:0:1}
case $CMD in
    r) 
        xrandr --screen 0 -o right
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 1
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 0 1
        ;;
    l)
        xrandr --screen 0 -o left
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 1
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 1 0
        ;;
    i)
        xrandr --screen 0 -o inverted
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 0
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 1 1
        ;;
    *)
        xrandr --screen 0 -o normal 
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 0
        xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 0 0
        ;;
esac

And now, yoga r rotates the screen to portrait mode “right”, yoga l is portrait mode “left”, yoga i for “inverted” (upside down, “media mode”), and anything else, even just plain yoga, will put everything back to laptop mode, keyboard and all.

2 Responses to The Thinkpad Yoga and Ubuntu 12.

Yoga 2 Pro + Heisenbug | Lets start imagining…

December 2nd, 2013 at 4:06 pm

[...] The accelerometer doesn’t work for rotating the screen, but you can still do it manually (use this script). Battery life is okay at 9-10W draw on light usage (that’s about 5 hours) and 15-25W with [...]

NX

January 16th, 2014 at 8:48 am

Hey, thanks for the script. I customized it for my Yoga 2 Pro and set it to be called on a hotkey (the little button on the side by the volume controls) so that I can use it when I have the keyboard disabled because the keyboard is folded all the way back.

Here’s my version:

#!/bin/bash
normal=”eDP1 connected primary 3200×1800+0+0 (0×48) normal (normal left inverted right x axis y axis) 293mm x 165mm”
left=”eDP1 connected primary 1800×3200+0+0 (0×48) left (normal left inverted right x axis y axis) 293mm x 165mm”
right=”eDP1 connected primary 1800×3200+0+0 (0×48) right (normal left inverted right x axis y axis) 293mm x 165mm”
inverted=”eDP1 connected primary 3200×1800+0+0 (0×48) inverted (normal left inverted right x axis y axis) 293mm x 165mm”
ARG=0

if ( xrandr -q –verbose | grep -q “$normal” )
then ARG=r;
elif ( xrandr -q –verbose | grep -q “$right” )
then ARG=l;
elif ( xrandr -q –verbose | grep -q “$left” )
then ARG=i;
else
ARG=n;
fi

CMD=${ARG:0:1}
case “$CMD” in
r)

xrandr –screen 0 -o right
xinput set-prop ‘ELAN Touchscreen’ ‘Coordinate Transformation Matrix’ 0 1 0 -1 0 1 0 0 1
xinput disable ‘SynPS/2 Synaptics TouchPad’
;;
l)
xrandr –screen 0 -o left
xinput set-prop ‘ELAN Touchscreen’ ‘Coordinate Transformation Matrix’ 0 -1 1 1 0 0 0 0 1
xinput disable ‘SynPS/2 Synaptics TouchPad’
;;
i)
# This script rotates the screen and touchscreen input 180 degrees, disables the touchpad, and enables the virtual keyboard
xrandr –screen 0 -o inverted
xinput set-prop ‘ELAN Touchscreen’ ‘Coordinate Transformation Matrix’ -1 0 1 0 -1 1 0 0 1
xinput disable ‘SynPS/2 Synaptics TouchPad’
;;
n)
xrandr –screen 0 -o normal
xinput set-prop ‘ELAN Touchscreen’ ‘Coordinate Transformation Matrix’ 1 0 0 0 1 0 0 0 1
# xinput set-prop –type=int –format=8 “ELAN Touchscreen” “Evdev Axes Swap” 0
# xinput set-prop –type=int –format=8 “ELAN Touchscreen” “Evdev Axis Inversion” 0 0
xinput enable ‘SynPS/2 Synaptics TouchPad’
;;
esac

Comment Form

Recent Comments