2010-04-27

Using Trackball on Linux

I am having 3 monitors in my working setup, it help my productivity a lot and make me feels right, though moving long distance with mouse is quite painful, so I get a trackball for it (http://us.kensington.com/html/16632.html).

It works great, it has drivers for windows and OS X, the navigation mode is quite good (in this mode, you can roll the trackball to scroll in the page), though it only support very few applications.

On my Ubuntu system, after some tweak, it actually works better, here is what I did:

xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation" 8 1

xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Button" 8 8

xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Axes" 8 6, 7, 4, 5


xinput set-button-map "Kensington Kensington Slimblade Trackball" 1 2 3 4 5 6 7 10 9 8 11 12


xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Button Toggle" 8 1


In current Ubuntu (mine is 9.10), there is no need to change setup in xorg.conf, the system just detected all the buttons of the trackball, the above lines are just for the navigation mode to work.

You need to run these commands after start X server (there is a way to save the settings permanently, though I didn't try it). You can use "xinput list" to find the name of your device.

The first line is telling the xinput system to enable the mouse wheel emulation (similar to the navigation mode)
The second line is to use the upper-right button to trigger the navigation mode.
the third line make it work for both vertical and horizontal scroll.
The forth line remap the buttons a little bit, since firefox will use button 8 as back button, that's not what I want.
The fifth line is a bit tricky, in the default implementation of current mouse wheel emulation, you need to hold the button for triggering the emulation (I think it's from the thinkpad's way of using the trackpoint), though for the trackball, it feels awkward if need to keep the navigation button pressed all the time, so I made a patch on it, then it works like under the OS X(one click to switch to navigation mode, another click back to normal mode, also clicking any other button in navigation mode will switch back to normal mode too).

If you want to try the extra feature, you have to build it manually, the package name is xserver-xorg-input-evdev in ubuntu, or from git://anongit.freedesktop.org/git/xorg/driver/xf86-input-evdev

patch for ubuntu's version (1:2.2.5-1ubuntu6): https://sites.google.com/site/yjpark/downloads (ubuntu-9.10-toggle_button.diff)

patch for latest version: https://sites.google.com/site/yjpark/downloads (xf86-input-evdev-toggle_button.diff)

3 comments:

Unknown said...

I'm a maverick user. I have a disability and this would help a lot. I'm not a programmer. Can you give the steps to compile or a binary.

Tks

Unknown said...

I figured out the steps to get this patch to work on Maverick:

Open a terminal and enter
1. sudo su
2. apt-get install build-essential xutils-dev
3. apt-get install xserver-xorg-dev
4. apt-get install autoconf
5. apt-get install libtool
6. Decide which version you want and type wget http://cgit.freedesktop.org/xorg/driver/xf86-input-evdev/snapshot/xf86-input-evdev-'ver.tar.gz'
7. tar xvfz xf86-input-evdev-'ver'.tar.gz
8. cd xf86-input-evdev-'ver'
9. patch -p1 < 'YJParks diff patch'
10. ./autogen.sh --prefix=/usr
11. make
12. make install
13. reboot

My toggle now works

nostradomis@gmail.com

凍仁.翔 (Chu-Siang Lai) said...

Thank you, the xinpit command is work on Ubuntu 12.04.