Thursday, May 17, 2012

Ubuntu's Sticky Tablet Stylus


Since I recently had to reinstall Ubuntu 11.10 some of the inherent problems of the operating system have resurfaced. Most have been corrected through updates, but some remain, which are persistent to the point of recurring in version 12.04 Lts. Among these, an issue most relevant to digital artists is the usability of a digitizing tablet such as my old wacom 6x8. As any digital artist will probably tell you, freehand painting with a mouse simply doesn't offer an intuitive way of applying your creativity to the digital canvas. Thus, tablet functionality is essential for any operating system hoping to appeal to digital artists; particularly to those who do commercial work like myself.

The good news is, that Ubuntu now offers tablet support from the start and even features a nice configuration utility that works through the graphic user interface. No need for command line input.

The bad news is that this utility is very limited in terms of what you can actually configure, unlike the windows driver which allows configuration for just about every input feature the tablet has. Another problem that arises in some cases (as in my case) is one where the tablet pen “sticks”, meaning when you press the tip against the tablet surface the “click” event will remain active even after the pen's tip has been lifted away from the tablet. If you click an icon and drag it to another place on the desktop with your pen for example, you will continue to drag the icon around even after no contact between the pen and the tablet remains, and you have to move the pen really far away from the tablet for it to release. This is an intensely irritating issue and one that renders your wonderful and expensive tablet completely useless.

One thing I've come to like about Ubuntu, and Linux in general is that it being open source means just about any problem that arises can be resolved. The better part of it is that this particular debacle is quite easy to fix.

I won't go into unnecessary details about how the driver works or its history, simply because it's something I don't fully understand yet, but please note that it is an independent driver created by some really kind people from the Linux community and like most software of its kind, its under constant development, so expect it to get better as time passes.

Okay, all we have to do to fix this problem is make some small alterations to a configuration file. This is all we have to do, but to do it, we first need to identify the tablet hardware in our system and then bypass some of Ubuntu's security features so it allows us to edit the configuration file. We'll take it one step at a time.

First lets locate the file we need to edit. The file path is: [/usr/share/X11/xorg.conf.d/50-wacom.conf] (without the brackets). This means the file's name is 50-wacom.conf and /usr/share/X11/xorg.conf.d is the directory or the series of folders where the file is found. Once the file is located you can double click on it and it should open in “Gedit”. Gedit is ubuntu's default text editor. What you should see, is a lot of text divided in small groups or “sections”. These contain instructions on how the tablet hardware is recognized and what the system should do with it. What we have to do now is edit some of the entries present and create some new ones. Do notice however, that any changes we do to the file at this point become null because the save function has been disabled. This is because you need administrative privileges to do so. So lets back up a bit so we can remediate this.

Now, advanced users, please bear with me, since I'm writing this with the absolute beginner in mind.

Do not be afraid, we are going to use the command line interface, aka: “Terminal”. Either click the “Dash” icon and type “terminal” in the search bar to look it up or press “ctrl alt T” on your keyboard to bring it up. Remember, the ominous plain purple box now staring at you is your friend, so don't freak out. We'll only be using a couple of simple commands in order to see how your system identifies your tablet. Now type: [lsusb] (without the brackets) and press enter. A list of all USB devices currently connected to your computer will appear. Look for a line that describes your tablet, such as: [Bus 004 Device 002: ID 056a:0042 Wacom Co., Ltd Intuos2 6x8]. All we need is the last part (Intuos2 6x8 in my case), which describes the particular model in use. Keep Terminal open, since we'll need its information to alter the 50-wacom.conf file a bit later.

At this point we'll again locate the 50-wacom.conf file in:/usr/share/X11/xorg.conf.d/, but we'll do it a little different now. What we are going to do before we access the file is temporarily elevate our user privileges to “super user” or “root” as it is often called. For this we'll call again on our trusted purple friend: “Terminal”. Without closing the prior Terminal window, lets open a new one; it'll make it easier for you, trust me.

In the new terminal window we will use two commands. The first one is called [sudo], this the part that will grant you permission to edit the file; it “elevates” your user status to “super user” or “system administrator” without the need to log in as “root”, which could potentially harm your system. The second one will be [nautilus]. This is the part that will let you locate the file itself. Nautilus is the “window system” Ubuntu uses to find and manage files. Similar to “windows explorer” on windows. The [nautilus] command simply invokes a window in which to find and view the file we're looking for, but because it'll be preceded by the sudo command, this window will allow you temporary “root” access thus removing the security limitations we faced when we previously accessed the file. In other words, we'll be able to edit 50-wacom.conf and save any changes permanently. A word of caution however, opening this window is like opening pandora's box. We will use it to fix the issue at hand specifically, but should you fiddle with the wrong things here, there will be breakage, you will cripple your system, and you will pay the price, so do what you have to do and then quickly close the darn thing.

Type [sudo nautilus] and press enter. Terminal will then ask you for a password, this should be the same password you use to log into your user account. The password won't appear as you type; not even little asterisks, so just type away and press enter. A bunch of information we don't care about will appear in Terminal and finally the magic super window opens. Now find the file and before you do anything to it, copy it, and paste the copy in a safe place as a backup, just in case. Now that the file is backed up, open the original and you will see the save function is now available in Gedit. These are the things we have to change:

The last section under the comment line: [# N-Trig Duosense Electromagnetic Digitizer] has three parameters that have to be changed. The first one is [Identifier "Wacom N-Trig class"]; the parameter has to be changed so it reflects the tablet information found on the first Terminal window we opened. Once the change is made, the line should read something like: [Identifier "Intuos2 6x8"]. The next lines reads: [MatchProduct "HID 1b96:0001|N-Trig Pen"]. Now do the same as in the previous line; all you're doing is replacing the generic information between the quotation marks with the specific data you found about your tablet in the first Terminal window. The line should now read similarly to: [MatchProduct "Intuos2 6x8"]. Remember, the parameter [“Intuos2 6x8”] is only an example, you have to use the information Terminal returned to you after you used the [lsusb] command. The next line only needs changing if you are having the same problem I was having, where both stylus buttons would have the same function regardless of how I configured them in the Ubuntu graphical configuration utility. If such is your case, then all you have to do, is go to the line: [Option "Button2" "3"] and add the word “Button” before the “3” so it looks like this: [Option "Button2" "Button3"]. This made my pen buttons act again like two separate inputs, rather than a single one. Finally, the last step is to add a new line right under [Option "Button2" "Button3"], which will tell the system when it should release the pen tip's click event. The line should be similar to this: [Option "Threshold" "150"]. The number can be basically any value, but anywhere from 175 to 150 seems to work fine in my case.

All that remains now is to save the changes. After that we can close Gedit. Terminal windows are closed by typing [exit] and pressing enter in each one; this will close the special Nautilus window as well. Now just log out of Ubuntu and log back in (no need to restart) and your tablet should work properly.
I hope this has been helpful to some extent and that you've learned a thing or two. I love Linux and I hope this post helps everyone who reads it love Linux too. I also hope this can remind those a bit shy about giving Linux a try that the only thing one should fear is fear itself.

For more information check out:
The linux wacom project
The official Nautilus page
ubuntu.com

1 comment:

  1. having jumpy cursor and random clicks on mine.

    ReplyDelete