Start pagina

Trust / Aiptek Tablets on Debian Linux


Blog lezen

I recently bought a Trust 400-V2 wireless tablet, and I spend quite a bit of time getting it to work properly on my Debian Linux system. Here's how I finally got it all working correctly.

Getting the drivers

The Trust tablet apparently is a rebranded Aiptek 8000U. Neither Trust nor Aiptek support linux, but there is a sourceforge project with GPL drivers at http://aiptektablet.sourceforge.net/.

Get the "Aiptek unified package" from http://sourceforge.net/projects/aiptektablet.

There are 3 parts to the package; a kernel module, an X server module, and a GUI application for configuring the kernel module. I couldn't get all the dependencies for compiling the GUI app, so I do without it.

Compiling the kernel module

Make sure you've got your kernel source thats correctly configured for your system. If you've never done this before, check out Creating custom kernels with Debian's kernel-package system by Keven McKinley.

I'm assuming you've got /usr/src/linux as a symlink to your kernel source tree. I used the debian package kernel-source-2.6.11 as the base.

There is a version of the aiptek kernel module in my debian kernel-source, but it's old and buggy. I recommend using the kernel module from the Aiptek unified package or the SVN repository instead of the one in the kernel tree *: untar the package and copy unified_package/src/linux_kernel_module/2.6/aiptek.c to /usr/src/linux/drivers/usb/input/aiptek.c.

* Update for recent kernels (2006-08-13)

I noticed that in kernel version 2.6.17 (probably since 2.6.15) the unified package driver does not compile anymore. Using the HEAD version (v2.0, 2006-Apr-18) of the driver from the svn repository fixed the problem. View the latest changes to aiptek.c or download the latest aiptek.c file directly.

Now setup you kernel configuration. Go to /usr/src/linux, make menuconfig and go to Device drivers -> USB Support.

Switch on "Support for Host-side USB", "USB Human Interface Device (full HID) support", "HID input layer support" and set "Aiptek 6000U/8000U tablet support" to "M" (module). Now compile the kernel package and install it. Reboot.

Hotplug system

The following is needed if you have hotplug instead of udev installed. Udev is the default for newer kernels. You should probably use it instead of hotplug.

The kernel module should be loaded automatically if you have the hotplug system running, but you need to set up some symlinks when that is done. Also on my system the mouse buttons are set up wrong in the default configuration, so I wanted to switch them.

To do all this, I created the following script as /etc/hotplug/usb/aiptek:

#!/bin/sh
#
# configure & setup aiptek usb tablets
#
# AUTHOR: Joost Diepenmaat - joost@zeekat.nl
#
# CHANGES:
#    2005-05-16:
#        Removed module reloading code - caused page fault
#        while booting
#
#    2005-05-10: 
#        Moved from init.d script to hotplug script
#
#    2005-04-24: 
#        Better detection of tablet's /sys/bus/usb location
#        Doesnt try to unload kernel module if there isn't one loaded
#
#    2005-04-21:
#        Initial version
#
. /etc/hotplug/hotplug.functions

if [[ "$ACTION" != "add" ]]; then
    exit 0;
fi

AIPDIR=`echo $DEVPATH|grep -o '[^\/]*$'`

if [[ "$AIPDIR" ==  "" ]]; then
    mesg "Can't find aiptek tablet /sys entry"
    exit 1;
fi

AIPDIR="/sys/bus/usb/drivers/aiptek/$AIPDIR"
INPUT_PATH=`cat $AIPDIR/input_path`

if [[ ("$INPUT_PATH" == "") || ("$INPUT_PATH" == "/dev/input/") ]]; then
    mesg "input_path is empty: try replugging the tablet"
    exit 0
fi

mesg "Linking /dev/input/aiptektablet to $INPUT_PATH"

if [[ -L /dev/input/aiptektablet ]]; then
    rm -f /dev/input/aiptektablet
fi
ln -s $INPUT_PATH /dev/input/aiptektablet


mesg "Configuring tablet"
# correct middle and right buttons
#echo "middle" >$AIPDIR/mouse_right
#echo "right" >$AIPDIR/mouse_middle
echo "execute" >$AIPDIR/execute


To make sure that runs when you insert the tablet, I copied the aiptek lines from /lib/modules/*kernel-version*/modules.usbmap to /etc/hotplug/usb/aiptek.usermap:

aiptek               0x0003      0x08ca   0x0001    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0010    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0020    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0021    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0022    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0023    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0
aiptek               0x0003      0x08ca   0x0024    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x0

This will test the module, reload it if necessary, install a symlink in /dev/input/aiptek-tablet to the correct input event, and reset the tablet. After that, if you've got gpm running, you can use the mouse and pen in console mode.

The script reloads the module if the /sys/bus/usb/drivers/aiptek/*/input_path virtual file is empty, because that's the only way I could find to figure out how to get at the correct information for installing the /dev/input/aiptek-tablet symlink.

This is pretty annoying hack, and the udev option below works a lot better.

Udev rule

If you have udev installed, create new rules file as /etc/udev/rules.d/aiptek-tablet.rules:

# links /dev/input/aiptektablet to the correct /dev/input/event*
# without it, X will not be able to locate the tablet
#
# The idVendor and idProduct values work for my Trust V2 tablet.
# Other aiptek-compatible tablets might need different values.
#
# You can run "lsusb" to see the ids for currently plugged in devices.
#
KERNEL=="event[0-9]*", SYSFS{idVendor}=="08ca", SYSFS{idProduct}=="0021", SYMLINK+="input/aiptektablet"

Installing X modules

First, see if you have the XFree86 or Xorg server. Debian is moving from XFree86 to Xorg, but I found getting the Xorg drivers to work a bit more hassle.

Installing the XFree86 module

Debian doesn't have the aiptek X server module in their package list, so I copied it from the unified package. cp unified_package/prebuilt/2.6/aiptek_drv.o /usr/X11R6/lib/modules/input/aiptek_drv.o

I don't know if the unified package X driver works with the v2.0 kernel driver. You should probably use both X and kernel driver from the unified package if at all possible.

Installing the Xorg module via apt-get

If you have the newer Xorg X server, debian provides an aiptek input driver in the "xserver-xorg-input-aiptek" package. If you're lucky, apt-get install xserver-xorg-input-aiptek will install the driver for you.

I couldn't get this input driver to work with the v2.0 kernel driver from the aitektablet site, so I compiled a new one myself.

Building your own Xorg module

Dependencies

You'll need some sort of working C compiler environment plus at least the following packages (install via apt-get [package names]): subversion and xserver-xorg-dev.

Get the sources

Get the latest sources from the SVN repository and run xmkmf:

> svn co https://svn.sourceforge.net/svnroot/aiptektablet/trunk/
> cd trunk/xserver_input_driver
> xmkmf

This will create a Makefile that is slightly broken for Xorg. You'll need to edit it.

Open Makefile with your favorite editor, find the line starting with INCLUDES = and append -I/usr/include/xorg -I/usr/include/X11. In my case, the final line (#1081) looked like this:

INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) -I$(SERVERSRC)/include -I$(SERVERSRC)/mi -I$(XINCLUDESRC) -I$(EXTINCSRC) -I/usr/include/xorg -I/usr/include/X11

Then run make in the same directory. If all is well, you now have a aiptek_drv.so file. Copy it to the right location (Makefile doesn't know the right location, so make install won't work right):

> cp aiptek_drv.so /usr/lib/xorg/modules/input/aiptek_drv.so

And you're done. Now configure the X server.

Configuring X windows

Below are some changes to the X server configuration. Note that the name of your X config file is dependent on your X server type. If you have XFree86 it's called /etc/X11/XF86Config-4 or /etc/X11/XF86Config. If you're running Xorg, it's /etc/X11/xorg.conf.

Standard mouse

The Aiptek X driver is very picky about the name of your mouse device. If you've got this far, you should have a couple of mouse* entries in /dev/input. Find out which is the correct one for you. A simple way of testing is to do cat /dev/input/mouse0 and move the mouse to see if you get any output (binary garbage). My mouse is at /dev/input/mouse0. Do not use /dev/input/mice! Find the InputDevice entry in the X config file and make sure the "Device" entry is configured to use that device. Mine looks like this:


Section "InputDevice"
        Identifier      "Configured Mouse"
        Driver          "mouse"
        Option          "CorePointer"
        Option          "Device"                "/dev/input/mouse0"
        Option          "Protocol"              "ImPS/2"
        Option          "Emulate3Buttons"       "true"
        Option          "ZAxisMapping"          "4 5"
EndSection

Tablet entries

Now set up the entries for the tablet. Add the folowing to your X config file:


Section "InputDevice"
    Identifier  "pen"
    Driver      "aiptek"
    Option      "Device"    "/dev/input/aiptektablet"
    Option      "Type"      "stylus"
    Option      "Mode"      "absolute"
    Option      "Cursor"    "stylus"
    Option      "Mode" "absolute"
    Option      "PressCurve" "0,5,95,100"
    Option      "zMin" "0"
    Option      "zMax" "512"
    Option      "ZThreshold" "0"
    Option      "USB"       "on"
    Option      "KeepShape" "on"
    Option      "debuglevel"    "0"
EndSection

Section "InputDevice"
    Identifier  "cursor"
    Driver      "aiptek"
    Option      "Device"    "/dev/input/aiptektablet"
    Option      "Type"      "cursor"
    Option      "Mode"      "absolute"
    Option      "Cursor"    "puck"
    Option      "Mode" "absolute"
    Option      "PressCurve" "0,5,95,100"
    Option      "KeepShape" "on"
    Option      "zMin" "0"
    Option      "zMax" "512"
    Option      "ZThreshold"  "0"
    Option      "USB"       "on"
    Option      "debuglevel"    "0"
EndSection

Section "InputDevice"
    Identifier  "eraser"
    Driver      "aiptek"
    Option      "Device"    "/dev/input/aiptektablet"
    Option      "Type"      "eraser"
    Option      "Mode"      "absolute"
    Option      "Cursor"    "stylus"
    Option      "Mode" "absolute"
    Option      "PressCurve" "0,5,95,100"
    Option      "zMin" "0"
    Option      "zMax" "512"
    Option      "ZThreshold" "0"
    Option      "USB"       "on"
    Option      "KeepShape" "on"
    Option      "debuglevel"    "0"
EndSection

You can find information on these options in the AIPTEK(4) manual page. Then find the ServerLayout entry and add the tablet devices. Mine looks like this:


Section "ServerLayout"
    Identifier      "Default Layout"
    Screen          "Default Screen"
    InputDevice     "Generic Keyboard"
# this is the entry for the standard mouse
    InputDevice     "Configured Mouse" "CorePointer"
    
# the following are entries for the tablet
    InputDevice "pen"       "AlwaysCore"
    InputDevice "cursor"    "AlwaysCore"
    InputDevice "eraser"    "AlwaysCore"
EndSection

If you don't have a standard mouse, or you don't care about it, remove its entry and change the


    InputDevice "cursor"    "AlwaysCore"

line to


    InputDevice "cursor"    "CorePointer"

Restart your X server and with a bit of luck, you can now use the tablet!

Note that with this configuration, the tablet needs to be plugged in and configured or X won't start. Also, if you remove and re-insert the tablet, you'll need to restart X.

Configuring the GIMP

If you want to use pressure-sensitivity in the Gimp image editor, start gimp, and select to File -> Preferences -> Input Devices -> Configure Extended Input Devices. Select device "pen" and set the Mode to "screen". Save and close the configuration windows.

To test: open a new image, use the pen to draw with the brush tool. You can set the pressure effect with the "pressure sensitivity" options.

Have Fun! J.

$Id: content.html,v 1.9 2007-10-31 12:48:02 joost Exp $