-   Linux - Hardware (
-   -   Using all buttons of my trackball (

werner1975 10-23-2007 12:29 PM

Using all buttons of my trackball
I have a Kensington Turbo Mouse Pro with 10 additional buttons (6 shortcuts on to + 4 large buttons in a circle)

How could I assign special behaviors to these buttons? Especially for the 4 buttons, I'd like to keep click and right-click as usual, but for the two other buttons, I'd like one to act as "double-click" and the other one as "Ctrl-Q". Any idea how I could do that?

David the H. 10-23-2007 01:24 PM

Sorry to say, but we're pretty much out of luck. It's possible to get all four main buttons to work, but the 6 multimedia buttons are basically dead (well actually, the first two buttons work now, but they only send the same events as two of the other buttons). I've been waiting years for someone to get around to writing in support for them, but I guess it's just too uncommon of a product for anyone to bother writing a decent driver. I even wrote the company about it a couple of years ago and got nothing but a noncommittal "we have no plans at this time" in answer.

And last I saw, it looks like the pro series has been discontinued, so there's even less likelihood in the future. Frustrating really, because they were really convenient back when I was using Windows.

The only time I came across anything that had even a remote possibility was a patch someone posted in a newsgroup for an old 2.4 era mouse driver that added key call events for the buttons, which could then be mapped to keysyms. But I can't believe that it would still work now.

*Edit: It seems that by using the ExplorerPS/2 protocol in xorg.conf, you can get the two extra main buttons to register as buttons "8" and "9", and media buttons 1 and 2 also register as "2" and "8". Everything else is dead. Pehaps there are other ways to configure it, but I haven't found them.

werner1975 10-23-2007 01:58 PM

Thanks. I was actually thinking more about a simple GUI utility that lits when you click a button, and then in front of the light you have a drop-down menu to choose what behavior you want associated to this click. Does such utility exist? :)

David the H. 10-23-2007 03:24 PM

No, not that I know of, though it might depend on the desktop environment you're using. KDE doesn't seem to have anything useful at least. Seriously, mouse button and keyboard mapping on Linux still leaves a lot to be desired. It's mostly cryptic xmodmap commands and such right now, and I just can't get my mind around how it's all supposed to work. I still haven't even figured out how to get the extra working buttons to map to anything useful myself.

One interesting note though. Your post motivated me into doing another search, and I found this newsgroup post, where the writer claims that the extra buttons have recently started sending useful keypresses. But his configuration didn't work at all for me. Perhaps he's just confused about the first two buttons sort-of working or something. Seems strange though. Since he's able to modify his window manager to handle the buttons, they must be working for him. So perhaps there's hope after all. I'll have to keep digging.

David the H. 10-27-2007 03:17 PM

I've had some time now to play with it now, and it does indeed seem that it's possible to get all the buttons working on the Kensington Pro series. But it's not necessarily easy.

Apparently sometime in the last year or so the evdev driver has finally included full support for all the buttons. So all you have to do to enable them is to change the mouse driver entry in your /etc/X11/xorg.conf to use it instead of the regular mouse driver directly. Indeed, since the evdev driver is basically a plug&play mouse and keyboard driver virtualizer, all most people need are three entries, everything else is automatic:


Section "InputDevice"
    Identifier    "Mouse0"
    Driver        "evdev"
    Option        "Device"    "/dev/input/event1"

Note that the Identifier entry must match the one found in the ServerLayout section. And the Device entry must use the same 'event' device found in the 'Handlers' line of your mouse entry in 'cat /proc/bus/input/devices'. In most cases it should be event1.

After restarting your xserver you should be able to run 'xmodmap -pp' and get the following lines:


$ xmodmap -pp
There are 13 pointer buttons defined.

Physical  Button
Button    Code
  1        1
  2        2
  3        7
  4        4
  5        5
  6        6
  7        3
  8        8
  9        9
  10        10
  11        11
  12        12
  13        13

And you should be now getting active button actions from xev as well.


At least for me with my Expert Mouse Pro, not all is working as it should. :( xev does show outputs for all 13 buttons, but 'xmodmap -pp' only gives me 9 buttons. I don't know yet if this affects the ability to use them. But even worse for me is that for some reason, the buttons become completely unmappable. I'm left-handed so I need to be able to swap buttons 1 and 3, but none of the traditional ways to switch the buttons around seem to be working. When I try it with xmodmap, for example, it says it has reversed the buttons, and 'xmodmap -pp' shows them as reversed, but the system itself still uses them in the original order. The KDE mouse settings don't have any effect either. So it looks like I'm personally still stuck with a crippled trackball. Grr.

I suspect this has something to do with my particular model though, and that other, newer versions probably work better. So if you decide to try it, I'd like to know how it turns out.

So, if you can get the thing working, then all you need to do after that is apply some useful functions to the buttons. I still haven't gotten around to configuring this yet, but it seems that xbindkeys is the foundation; you use it to map buttons and keypresses to shell commands. Probably the main action you want to set up is to tell xvkbd to send a keyboard combination (crtl+shift+F12, for example) whenever you click, which can then be used for keyboard shortcuts, or with the kde input action daemon, or such. But there are many other possibilities.

Indeed, the more I think about it, the more powerful this seems. It may be harder to configure than Kensington's MouseWorks configurator, sure, but you can also do about 10 times as much with it. xbindkeys will let you set up almost any combination of buttons and keys, [[even things like mouse chords for the left two or right two buttons together, or media buttons 1+2]] (Edit: it looks like I was wrong. You can set up multiple key combos with xbindkey, or key+mouse button combos, but it doesn't look like it will let you set up multiple button combos alone. Does anyone know any way to do this?). And with a little scripting knowledge you can set these combinations to do just about ANYTHING. The only limit is your imagination, really.

Now if they'll only fix that mapping problem....

werner1975 10-28-2007 05:13 AM

Thanks, I'm gonna try it today. The most important thing to me is assinging "double-click" to the upper-right button when I single-click, how could I do it? Thanks,

David the H. 10-28-2007 09:02 AM

To simulate button presses, use xmacroplay. Assuming physical button number 7, for example, create the following rule in your ~/.xbindkeysrc:


"echo ButtonRelease 7 ButtonPress 1 ButtonRelease 1 ButtonPress 1 ButtonRelease 1 | xmacroplay -d 0 :0.0"

Assuming your display is :0
That should make the button always send a simulated double-click of the first button. It took me a long time to figure out that I needed to release button 7 first though. I haven't been able to find any good documentation for xmacro anywhere.

[[Edit: There's a double-click script available here that's probably better than the above, as well as some other useful example scripts.]]

When I get my final key configuration set up, I'm probably going to throw the actual actions into some bash scripts, one for each button. That way I can use 'case' commands to set up different actions for different programs. I don't know how much extra delay it might entail yet though.

I also found a nice useful program that works well with xbindkeys: Apwal. You can use it to give you a selection of icon launchers right at your mouse cursor. Check it out.

Finally, I have an open question for the board. Apparently, you can compile xbindkeys with guile support. I want to know what this is good for and what I can do with it. Could I use it to set up button chords, like I originally wanted?

David the H. 10-28-2007 12:42 PM

Ho, we're in luck! It turns out that the Debian version of xbindkeys already supports guile. I just had to install the libraries for it. And after reading the sample config script and playing around with it a bit, it is indeed possible to set up mouse button chords. The syntax is more difficult than the straight xbindkeysrc, and you need a small subscript function included in the config before it will work, but fortunately that's already included in the sample file. In any case, it's doable.

I am having some problems with it though. First, it's not sensitive enough. I can set it up so that two buttons in tandem will run a command, but it's only able to detect the proper sequence about 1/10 of the time. It needs to be modified so that it can read the click sequences more clearly.

Second, it's useless when used on buttons 1-5 (without modifiers), which already have default actions built into them. The script as provided blocks the default action. I need some way to let it pass the original action through when one button is clicked alone, and only activate a command when multiple commands are pressed.

Since this is a programming-related question, I'm going to start a thread in the programming forum and see if I can get some help there. Then I'll post/link to whatever answers I get back here.

Edit: The thread I started is here.

pbrochard 11-20-2007 07:09 AM


Originally Posted by David the H. (Post 2939688)
Finally, I have an open question for the board. Apparently, you can compile xbindkeys with guile support. I want to know what this is good for and what I can do with it. Could I use it to set up button chords, like I originally wanted?

Hi, the guile/scheme configuration file enable a full access to the xbindkeys internal. A grabbed key can start a shell command or run a scheme function. This enable to do more powerful things inside xbindkeys without the need of an external shell script (like double click, timed double click , keys combinations, add/remove keys on the fly, create new functions to factor keys definitions...).
This let you extend xbindkeys the way you want.

David the H. 11-21-2007 09:12 AM

Thank you. But I had already figured that out. I can see that it allows for a much more flexible configuration. I think I could get it to do just about anything if I just knew how to configure it correctly.

But that's the problem. guile configuration is really a kind of scripting, and I just don't understand enough about the syntax to get it to do what I want. See my last post above for what I'm hoping to do, and the problems I'm having. I'd really appreciate any help I could get here.

KohlInGA 01-03-2008 11:21 AM

How to Use The Buttons of Your Trackball in Linux
There's a very good how-to program the 4 buttons on the sides of roller. You can find it here:
How to Use the Buttons of Your Trackball in Linux

I'm having difficulties getting things to work as described but you'll probably have no problems. I wouldn't be surprised if there's a way to combine the two solutions.


calande 01-04-2008 03:37 AM

Oh, the URL is

KohlInGA 01-05-2008 06:03 AM


Originally Posted by calande (Post 3010790)

How right you are sir. Dunno why my link doesn't work (scratches :confused: head)

I'm having trouble understanding how xmacro is supposed to work. The archive doesn't contain a INSTALL file but the files xmacrorec and xmacroplay are already present. I've tried copying those 2 files to /usr/bin but %xev | grep command doesn't create the event testing window as it should. Instead, bash returns "command not found" and I haven't been able to figure out why. I believe if I can get over this hurdle I might actually be able to program the buttons on my trackball to work the way I'd like.

calande 01-06-2008 09:13 AM

Strange, I just downloaded the tarball from Sourceforge and I don't see these files, I only see source files with a Makefile. What you have to do is run:


#make install

Then you'll see xmacrorec and xmacroplay in the directory. Copy them into /usr/bin/, but apparently you've done all that already.

When you type just:



Does it still report "Command not found"? For which of them?

You could run:


%whereis xev
To find out where xev is located.

KohlInGA 01-07-2008 08:26 AM


Originally Posted by calande (Post 3013266)
What you have to do is run:


#make install

Thanks calande for taking the time to help with my situation.

I've tried the above command both as user and su. Both times bash returns: xmacro-0.4.5> make install
make: *** No rule to make target `install'. Stop.


When you type just:


Does it still report "Command not found"? For which of them?
All above commands results with
xmacro-0.4.5> %xev
bash: fg: %xev: no such job

(I only posted the %xev result, xmacroplay and xmacroplay, all three have the same results.)


You could run:

%whereis xev
To find out where xev is located.
xev does exist:
whereis xev
xev: /usr/bin/xev /usr/bin/X11/xev /usr/share/man/man1/xev.1x.gz

Thanks again.

All times are GMT -5. The time now is 09:28 AM.