Screwtape (thristian) wrote,
Screwtape
thristian

Lazyweb: Trackpoint USB Keyboard under Linux

Years ago, I used a Toshiba laptop for a week or two that had a TrackPoint (commonly known as a “nipple mouse”). My first impression was that it was incredibly annoying, but I kept using it and when I gave the laptop back I was amazed to discover that switching back was even more frustrating: half a second of feeling around the desk hunting for where I left the mouse, instead of just moving my index finger an inch to the left.

Ever since, I’ve wanted to try a standalone TrackPoint keyboard, but never found one I liked - IBM originally had full-size Model-M style keyboards with TrackPoints, but they were hideously expensive. Later models only had two mouse buttons (where Linux really wants 3), or were too big, or had a useless trackpad attached. The other day, I was whining on IRC, and a friend pointed out that Lenovo had released a model that met all my criteria, and I had no excuses left not to pony up the cash and find out for myself.

A few days ago it arrived, so I plugged it in and started figuring out how to get everything working. Most of the stuff I can find on Google is exclusively about the built-in ThinkPad TrackPoints which connect via PS/2, not USB like this keyboard. For the sake of future generations, here’s what I’ve got so far.

Basic functionality

Out of the box, all the basic functionality works fine under Ubuntu 9.10, although if your system happens to have Num Lock enabled, the right-hand half of the keyboard will produce numpad keycodes rather than letters. The standard keys work, the TrackPoint works, all the mouse buttons work.

I usually have my keyboards configured with Caps Lock as an additional control key, and at work under Fedora 6 I had issues with keyboard-shortcuts that used Ctrl+Shift as a modifier. I guessed that whoever designed the keyboard never thought that Caps Lock and Shift might be held down together, but when I got the keyboard home those keyboard shortcuts worked flawlessly, so who knows what was really going on.

Special keys

Some of the special keys work: the mute and volume-control buttons work, the back and forward buttons work (at least in Firefox). I told my music player to enable its “DBus Multimedia Keys” plugin, and the play/pause/stop/prev/next functions on the arrow keys worked without further messing about.

The rest of the special keys and functions don’t do what their little icons advertise, although in many cases it wouldn’t be useful anyway. For example, Fn+F8 is “switch between TrackPoint and trackpad”, but I don’t have a trackpad so I don’t feel I’m missing out. Sadly, these keys don’t produce any keycode at all, so they can’t be rebound to more useful functions - although I see a patch posted to the linux-hotplug list that would fix that problem for most of the keys, which is already in Debian and might make it into Ubuntu 10.04.

Special TrackPoint features

From what I can tell, the Linux PS/2-pointing-device driver has special hacks that are enabled if it detects a TrackPoint, which let you configure the sensitivity, and enable ‘tap-to-click’ mode. Since the USB keyboard isn’t a PS/2 device, these settings are unavailable. Personally, I don’t mind this - the default sensitivity is reasonable, and tap-to-click sounds like horror.

The other feature the Windows drivers support is mouse-wheel emulation while the middle-button is held down. Middle-clicking still works, but multi-directional scrolling sounds pretty neat and I miss my scroll-wheel. Unfortunately, this feature is being quite annoying to set up.

Temporary configuration with XInput

Modern Xorg allows input devices to be configured at runtime through the XInput system. Ubuntu has the “xinput” tool installed, so we can mess around with it. The first step is to figure out what the device ID for the TrackPoint is. To find the device ID, run:
xinput list --short
There should be two devices named “Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint”, and both will be labelled as “XExtensionKeyboard”. Note down their ID numbers, then run:
xinput list-props $NUMBER
...for each ID number. The “correct” ID number is the one that has the “Evdev Wheel Emulation” property, and will likely change every time you plug the keyboard in or reboot the computer. Once you have the ID number, you can run:
xinput set-int-prop $NUMBER “Evdev Wheel Emulation Axes” 8 6 7 4 5
xinput set-int-prop $NUMBER “Evdev Wheel Emulation Button” 8 2
xinput set-int-prop $NUMBER “Evdev Wheel Emulation” 8 1
Unfortunately, when you unplug the keyboard or restart the computer, XInput forgets these settings and you have to do the find-the-ID dance again.

Permanent configuration

In an ideal world, there would be a config file somewhere that says “when you see a TrackPoint USB keyboard attached, configure it this way. Back in the day, this was done with a system called HAL, but HAL must have offended somebody and these days udev is apparently the solution. ThinkWiki has instructions on configuring udev but of course they refer to the PS/2 version which helps me not a lot. After a lot of mucking around with the udevadm command, looking for useful attributes to filter on, I have cobbled together the following udev rules file, based on the ThinkWiki one:
ACTION!=”add|change“, GOTO=”xorg_trackpoint_end“

ENV{ID_MODEL}!=”ThinkPad_USB_Keyboard_with_TrackPoint“, GOTO=”xorg_trackpoint_end“

ENV{x11_options.EmulateWheel}=”1“
ENV{x11_options.EmulateWheelButton}=”2“
ENV{x11_options.XAxisMapping}=”6 7“
ENV{x11_options.YAxisMapping}=”4 5“
ENV{x11_options.Emulate3Buttons}=”0“

LABEL=”xorg_trackpoint_end“
Unfortunately, it doesn’t work.

That is to say, udev parses it, and ”udevadm test /path/to/device/directory“ includes those x11_options.* properties in the resulting property list, but XInput doesn’t pick up the settings when I plug the keyboard in, or restart X.

I think part of the problem is I’m not quite sure what device the properties should be added to. ”udevadm monitor“ lists about half a dozen device nodes appearing when I plug the keyboard in, representing interfaces like ”USB device“, ”USB HID device“, ”USB HID keyboard device“... and so forth. I have no idea which of these device nodes XInput is examining for properties, and I can’t seem to find any documentation on the matter. If any one knows, feel free to let me know!

UPDATE: My friend rasher has pointed out that Ubuntu 9.10 is sufficiently outdated that it still uses HAL for its hardware autodetection needs. Therefore, rather than a udev rules file, one needs to save something like the following to /etc/hal/fdi/policy/trackpoint.fdi:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
    <device>
        <match key="info.product" contains="TrackPoint">
            <merge key="input.x11_options.EmulateWheel" type="string">true</merge>
            <merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>
            <merge key="input.x11_options.YAxisMapping" type="string">4 5</merge>
            <merge key="input.x11_options.XAxisMapping" type="string">6 7</merge>
        </match>
    </device>
</deviceinfo>

UPDATE 2: See my next post

Subscribe

  • A Year of Photography

    About this time last year, I took the plunge and bought my first-ever DSLR. Having just come back from a tropical-island holiday (where I was…

  • Trackpoint USB Keyboard under Linux, part 2

    I haven’t blogged in a very long time; the top item of my To Do list is “post a review of The Legend of Zelda: Spirit Tracks” but although I wrote…

  • (no subject)

    So, 22:15 and I just got home. I left work about 19:30 or so (got to work late, gotta do my hours) and on a whim, instead of taking the most direct…

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 4 comments