May 31, 2006

Getting started with Wacom tablets in Linux

Author: Nathan Willis

The mouse, despite all of its admirable qualities, was created by a left-brained thinker and built for left-brained work. Mostly that's fine, but when it comes time to draw an icon or retouch a photograph, you'll be cursing your mouse as the worst input device imaginable -- awkward to hold, awkward to move with, and awkward to click. To get the right side of your brain happy, you need a pressure-sensitive tablet. Here is how to get started in Linux.

Pressure-sensitive tablets have a flat surface attached to the computer via serial, USB, or Bluetooth connection. They read the motion, pressure, and tilt of special handheld "pen" and "brush" peripherals. You work with the pens and brushes just as you would with real-world tools. Pressure sensitivity allows you to vary brush stroke and opacity, creating far more realistic interaction with the painting tools in your image editing application.

Perhaps more important to the non-painter set, though, is the greatly improved control that pressure sensitivity gives you when touching up photos. The big pitfall of both dust and scratch removal and dodge and burn retouching is how difficult it is to blend in your retouches with the original image. But because cloning, dodging and burning, and erasing are all variations of paintbrush operations, pressure sensitivity gives you the intuitive, fine-grained control to retouch without leaving hard edges or visible borders.

Wacom and Linux

The dominant manufacturer of tablets is Wacom; it offers tablets in different sizes and resolutions, starting as cheap as $99 and going up to several thousand dollars for its Cintiq line, which incorporates a built-in LCD monitor, letting you in effect draw directly on the screen. All of Wacom's tablets use magnetic resonance to sense pen motion and position; the pens are cordless and require no batteries.

Wacom does not officially develop or release device drivers for Linux, but it does cooperate with the Linux Wacom Project, supporting the development of open source drivers by providing the project with technical information and sample tablets.

Getting your tablet to function under Linux involves two tasks: setting up the kernel device driver, and setting up the X server's pressure sensitivity options. The project's site has a detailed, thorough HOWTO that presents the necessary steps in order; I will not attempt to duplicate its information here, but will only describe what the process is.

The kernel module

The driver for USB tablets is part of the vanilla kernel, so your Linux distribution may already include it. If this is the case, you can skip this step entirely and move directly to the X configuration. On the other hand, installing a new kernel driver is relatively painless, and the driver code available at the Linux Wacom site is always newer, supports more features, and the authors use it in their day-to-day systems. I recommend you try it.

Download the latest package from the project site. The package contains the sources to build the kernel module (wacom.ko) using the standard ./configure and make process. You will need to have the Linux kernel source code available, but you do not have to recompile the entire kernel.

Making a new Wacom module is slightly different for 2.4.x and 2.6.x series kernels, so consult the appropriate pages in the documentation for details. Once your new module is built, the directions show you how to test it, and if it works, install it permanently.

X server support

Various tools' pressure effects in The GIMP. Click to enlarge

Even though the kernel should now recognize your tablet, you still have to hook it up into the X Window System in order for applications to respond to its fancy pressure and tilt data. This is the job of an X extension called XInput. As is the case with the kernel driver, there is an XInput driver in the vanilla Xorg distribution, and an updated and upgraded one available from the Linux Wacom project.

In order for the X server to recognize your tablet at all, you have to add entries for it in your /etc/X11/xorg.conf file. Specifically, add InputDevice sections, one each for the stylus, cursor, and eraser -- each of which has distinct functions on your tablet.

To replace the stock XInput driver, you have two options. The linuxwacom package contains pre-built binary modules for i386 and x86-64 architectures; if that's what you run, by all means use them. Compiling X modules is more time-consuming and trickier than compiling Linux kernel modules.

Assuming that you are taking the easy route, all you need to do is copy the wacom_drv.o file from the downloaded package to your system, overwriting the existing wacom_drv.o file. You should probably make a backup of the original first. The location of your system's wacom_drv.o varies depending on your distro; search for it by typing locate wacom_drv.o. Once replaced, all you need to do is restart X and your new XInput driver will be up and running.


Extended input device settings in The GIMP. Click to enlarge

Riding high on your success at both of these steps, you will want to start using your tablet in an actual graphics application. As of this writing, the GIMP, CinePaint (which is a derivative of the GIMP), and Krita incorporate at least some pressure-sensitive support in their tools. If you know of additional apps, please point them out in the comments below.

To enable use of your tablet in the GIMP, open File -> Preferences, and click on the Input Devices preference pane. Here, click on the button labeled Configure Extended Input Devices; this will bring up a dialog box where you can set the options for the tablet's stylus, eraser, and mouse cursor.

Each of these "extended input devices" corresponds to one of the entries you added to xorg.conf, and is managed separately by the GIMP. So, for instance, if you use the eraser to choose the GIMP's Eraser tool and the stylus to select the Paintbrush tool, the app will switch back and forth between the tools for you automatically as you use the two ends of the pen.

Extra credit

When you are new to the tablet drawing world, it can take some practice to get natural movement down, but with time, it becomes second nature. Once you get the hang of the basics, you can try tweaking the sensitivity settings of the Linux Wacom driver. The project provides both command-line (xsetwacom) and graphical (wacomcpl) tools, so you can play with the settings until they feel right.

If you started off with a basic Graphire tablet (which has pressure-sensitivity but not tilt-sensitivity), you may eventually want to move up to an Intuos model. Work is ongoing continuously on the Linux Wacom drivers; in development right now is support for the programmable buttons on the higher-end tablets, and support for Wacom's new Bluetooth models.

When it comes to support, I have found the Linux Wacom project to be first-rate at answering questions, and the quality of the documentation puts a lot of other projects to shame. Over the years, Wacom has manufactured a lot of different tablet models, and if yours doesn't seem to work correctly right out of the box, ask for help -- no doubt someone has been right brain, shove that mouse to the back of the desk, and start drawing.