Sunday, February 27, 2011

More about the touchsceen and multitouch

Hey everybody,
 So for the longest time I had things a bit switched up in my mind, I talked about multitouch and enabling the touchcreen as though they were one and the same...but they're not. Merely enabling the touchscreen allows the OS to register the "touch" events, mainly where you clicked and a mouse click...multitouch says that you've used more than one finger and thus two/three locations would be registeted instead.

In my post about installing ubuntu I don't make much of a distinction, in fact I used the terms interchangeably. All that changed when my friend Reiner told me about twofing, which basically captures multitouch events and does special things with particular windows such as scroll forward in evince if you swipe two fingers acoss the screen.

Well first off et me describe how to get the multitouch driver installed. Please note that if you had gotten the touchscreen to work using the method described in the Ubuntu installation post, you will need to undo these changes...namely remove the usbhid.quirks changes to the GRUB file and remove the 99-calibration.conf file rom /etc/X11/xorg.conf.d/

Next you will need to make sure you have added the utouch-team repository to the ubuntu packager (you may not need the unstable repo anymore)

sudo add-apt-repository ppa:utouch-team/utouch
sudo add-apt-repository ppa:utouch-team/unstable

sudo apt-get upgrade
sudo apt-get update

Next, download the egalax drivers:

sudo apt-get install hid-egalax-dkms

You should now be good to go. Restart the machine. For some reason I was getting weird behavior on my first restart and had to manually shut down the machine by holding down the power button. But the next time it loaded up it was in case you run in to any problems...restart again, if it persists across more restarts then you have a different issue.

Now if you recall, we had rotation scripts...well those won't work anymore, atleast not the way they are at the moment. Instead your files should now look like so:


xrandr -o normal
xinput set-int-prop 9 "Evdev Axes Swap" 8 0
xinput set-int-prop 9 "Evdev Axis Calibration" 32 0 32760 0 32760
xinput set-int-prop 10 "Evdev Axes Swap" 8 0
xinput set-int-prop 10 "Evdev Axis Calibration" 32 0 32760 0 32760



xrandr -o left

xinput set-int-prop 9 "Evdev Axes Swap" 8 1
xinput set-int-prop 9 "Evdev Axis Calibration" 32 32760 0 0 32760
xinput set-int-prop 10 "Evdev Axes Swap" 8 1
xinput set-int-prop 10 "Evdev Axis Calibration" 32 32760 0 0 32760

It took me a bit to figure out the settings, but basically it looks like the hid-egalax driver granulates the screen differently (and possibly with different scales depending on what axis).

You should now be running with multitouch support and at the same point where the ubuntu installation post left off.

The next bit just explains where the coordinates above came from. If you're not interested in that, well then you're done and can go enjoy!

If you run xinput_calibrator you will get some output that looks like:

Warning: multiple calibratable devices found, calibrating last one (eGalax Inc. USB TouchController)
    use --device to select another one.
Calibrating EVDEV driver for "eGalax Inc. USB TouchController" id=10
    current calibration values (from XInput): min_x=0, max_x=32760 and min_y=0, max_y=32760

Doing dynamic recalibration:
    Setting new calibration data: -29, 32920, 387, 32606

 Now I'm mainly interested in the bolded line, it tells us what the default values for the perfectly functional landscape setup is. The new calibration is ok, but you will find that it isn't perfect.

Ok so let's cut that up, it seems to say that in landscape mode, the lower left corner of the screen is at coordinates (min_x,min_y) which is (0,0).

What about the max? That's our upper right corner of the screen, (max_x,max_y) which is (32760,32760).

So the calibration string with min_x, max_x, min_y, max_y will be:
0 32760 0 32760

Ok, well what happens when we rotate the screen. Well we need to set the new lower left corner of our screen but using the same coordinate system as before. So our screen's origin (new lower-left corner) is now where (32760,0) used to be and the new upper right corner is at (0,32760) thus the new calibration string  with min_x, max_x, min_y, max_y will be:
32760 0 0 32760

Well that's all folks. Next time I will explain how I got twofing to work.


  1. hid-egalax works for me
    Any suggestion how to check multitouch is there?

  2. try out twofing which should allow you to do some gesture based tricks like scrolling with two-finger swipes

  3. You should try using "Evdev Axis Inversion" (in addition to Axes Swap) instead of redoing the calibration…

    Also, in xorg-xserver >= 1.8(e.g in ubuntu 11.04), there's a new generic property "Coordinate Transformation Matrix" that should be used instead. Cf