How to install MultiTouch from source

From ThinkWiki
Jump to: navigation, search

As things stand in August 2008 the latest packages of Ubuntu of the linux-wacom-project do not support MultiTouch for the X61 Tablet and X60 Tablet. However in the development packages MultiTouch is supported and work is going on there to improve things.

For the distribution Fedora Core 8 in Installing Fedora 8 (Werewolf) on an X61 Tablet a rpm based on the patch Usable Multitouch Support has been created. As things change rapidly the patch has to be updated for every new version. Besides the patch is only applicable to the FC8 distribution.

In contrast to that the procedure in the present article tries to benefit from either the latest development version of the linux-wacom-project or the latest stable release. It describes how to get the sources via cvs, compile and install the drivers. It shows how to tweak the source code to get the calibration right.

The steps have been tested on a X61 Tablet MultiTouch with Ubuntu 8.04 (Hardy) distribution. Nevertheless it should work on other distributions as well.

Removing old wacom-drivers

First remove all old wacom drivers and tools. In Ubuntu Hardy these are

  • wacom-tools
  • xserver-xorg-input-wacom

According to the installation manual [1] remove or comment out all wacom related lines in the X-Server configuration file /etc/X11/xorg.conf. Restart the X-Server and test if everything has been removed by looking at /var/log/Xorg.0.log.


note: Please only *remove* xserver-xorg-input-wacom, but don't *purge* it. xserver-xorg-input-wacom provides the necessary init files to create /dev/input/wacom on boot. (under Hardy)

Getting and compiling the code

We present here to ways: the first one is to get the latest developer release directly from the CVS server. However note that there might be errors. The other way is to download the latest stable release from linux-wacom-project, which might be saver. However note, that a lot of work is currently (August 2008) going on to enhance the support for MultiTouch.

In either way we will first we have to get a few packages related with the Autotools. In Ubuntu Hardy these are

  • automake
  • autoconf
  • libtool

and dependencies. Furthermore we will need the development libraries ncurses and Xlib [[2]] as well as tcl/tk, which are in Ubuntu Hardy

  • xorg-dev
  • libncurses5
  • libncurses5-dev
  • libx11-6
  • libx11-dev
  • tcl8.4
  • tcl8.4-dev
  • tk8.4
  • tk8.4-dev


Getting and preparing the latest development release

The linux-wacom-project is hosted on [Sourceforge]. We will get the sources via CVS. Therefore we have to install the corresponding programs before. In Ubuntu Hardy this is just the cvs-package.

Following the cvs instructions at [Sourceforge CVS] we first login as anonumous. $ cvs -d:pserver:anonymous@linuxwacom.cvs.sourceforge.net:/cvsroot/linuxwacom login

When prompted for a password just press enter. Now we are ready to download the development branch of the Wacom driver to the automatically created subdirectory linuxwacom-dev by issuing $ cvs -z3 -d:pserver:anonymous@linuxwacom.cvs.sourceforge.net:/cvsroot/linuxwacom co -P linuxwacom-dev

Change directory into linuxwacom-dev and issue

$ autoreconf -i

Getting a stable release

Go to linux-wacom-project and download the latest stable release (linuxwacom-0.8.0-3.tar.bz2 in August 2008). Untar the file and change directory.

Configuring and compiling the code (either way)

After that we can configure our linux-wacom tools. We just use the default options except for the request to build wacom.o by stating

   $ ./configure --enable-wacom

After that we can compile the driver and install it by

   $ make
   $ sudo make install

Editing /etc/X11/xorg.conf

After that we have to configure our X-server to recognize our new wacom input devices [[3]]. First add the following input devices at the end of the file

Section "InputDevice"
  Driver        "wacom"
  Identifier    "stylus"
  Option        "Device"        "/dev/ttyS0"          # SERIAL ONLY
  Option        "Type"          "stylus"
  Option        "ForceDevice"   "ISDV4"               # Tablet PC ONLY
  # http://wiki.informatik.hu-berlin.de/nomads/index.php     
  Option          "Button2" "3"
EndSection
Section "InputDevice"
  Driver        "wacom"
  Identifier    "eraser"
  Option        "Device"        "/dev/ttyS0"          # SERIAL ONLY
  Option        "Type"          "eraser"
  Option        "ForceDevice"   "ISDV4"               # Tablet PC ONLY
  # http://wiki.informatik.hu-berlin.de/nomads/index.php     
  Option          "Button3" "2"
EndSection 
Section "InputDevice"
  Driver        "wacom"
  Identifier    "cursor"
  Option        "Device"        "/dev/ttyS0"          # SERIAL ONLY
  Option        "Type"          "cursor"
  Option        "ForceDevice"   "ISDV4"               # Tablet PC ONLY
EndSection 
# This section is for the TabletPC that supports touch
Section "InputDevice"
  Driver        "wacom"
  Identifier    "touch"
  Option        "Device"        "/dev/ttyS0"          # SERIAL ONLY
  Option        "Type"          "touch"
  Option        "ForceDevice"   "ISDV4"               # Tablet PC ONLY
EndSection

After that we have to add a few lines into the Section "Server Layout":

Section "ServerLayout" 
  Identifier	"Default Layout"
  Screen	"Default Screen"
  InputDevice	"Synaptics Touchpad"
  # http://linuxwacom.sourceforge.net/index.php/howto/srvlayout
  InputDevice    "stylus"    "SendCoreEvents"
  InputDevice    "eraser"    "SendCoreEvents"
  InputDevice    "touch"     "SendCoreEvents"
EndSection

Now restart the X-server. After that the X-Server should react on touching the screen. Note that if a stylus is near the screen it automatically disables MultiTouch input.

Tweaking the driver

If you experience calibration problems first try

$ wacomcpl

If it gives you an error we have to calibrate MultiTouch manually. For that we have to run

$ xidump -u raw touch

Then try out the extreme x and y coordinates of your screen. After that edit the file src/xdrv/wcmISDV4.c. Find the function

static int isdv4Parse(LocalDevicePtr local, const unsigned char* data)

and in the function the part where the information about the touch event is parsed. In version 1.15 it should say starting from line 373

  	if (common->wcmPktLength == 5 ) /* a touch */
  	{
  		/* MultiTouch input only has 5 bytes of data */
  		ds->x = (((int)data[1]) << 7) | ((int)data[2]);
  		ds->y = (((int)data[3]) << 7) | ((int)data[4]);
  		ds->buttons = ds->proximity = data[0] & 0x01;
  		ds->device_type = TOUCH_ID;
  		ds->device_id = TOUCH_DEVICE_ID;
  		DBG(8, priv->debugLevel, ErrorF("isdv4Parse MultiTouch "
  			"%s proximity \n", ds->proximity ? "in" : "out of"));
  	}

Now remap the x and y coordinate by linearily transforming [xmin:xmax] to the full resolution [0:1024] and in the same manner [ymin:ymax] to [0:768]. Here xmin/xmax and ymin/ymax, respectively, are the measured minimal and maximal x-coordinates and y-coordinates of the touch events. In my case this is [41:927] and [80,738] so I write

 if (common->wcmPktLength == 5 ) /* a touch */
 {
       /* MultiTouch input only has 5 bytes of data */
       ds->x = (((int)data[1]) << 7) | ((int)data[2]);
       // remapping from [41,927] to [0,1024]
       ds->x = (ds->x - 41) * 1024 / (927-41);
       ds->y = (((int)data[3]) << 7) | ((int)data[4]);
       // remapping [80,738] to [0,768]
       ds->y = (ds->y - 80) * 768 / (738-80);
       ds->buttons = ds->proximity = data[0] & 0x01;
       ds->device_type = TOUCH_ID;
       ds->device_id = TOUCH_DEVICE_ID;
       DBG(8, priv->debugLevel, ErrorF("isdv4Parse MultiTouch "
               "%s proximity \n", ds->proximity ? "in" : "out of"));
  }

If you find the values to be to inaccurate just reiterate until you are satisfied.