September 2010 Archives

September 13, 2010

Trackball Configuration

I have a slightly strange configuration for my trackball.  I have it set up left-handed, so the main button on the right is "left click", and vice-versa.  There are two smaller buttons, one on each side, and I have the left-hand one as "middle click" and the right-hand one turning the ball into a "scroll wheel" when it's held ("wheel emulation" in X speak).  To complicate matters, I have the trackpad on my laptop right-handed.  In previous times, I'd configure this with some lines like these in the relevant section of xorg.conf to set up the buttons properly just for the trackball:

Option "Buttons" "9"
Option "EmulateWheel" "on"
Option "EmulateWheelButton" "9"
Option "ButtonMapping" "3 8 1 4 5 6 7 2 9"

That worked until the business of HAL for X input configuration came along.  Then I put something like this in /etc/hal/fdi/policy/trackball.fdi:

<deviceinfo version="0.2">
  <match key="info.product" string="Logitech USB Trackball">
   <merge key="input.x11_driver" type="string">mouse</merge>
   <merge key="input.x11_options.Buttons" type="string">5</merge>
   <merge key="input.x11_options.EmulateWheel" type="string">true</merge>
   <merge key="input.x11_options.EmulateWheelButton" type="string">9</merge>
   <merge key="input.x11_options.ZaxisMapping" type="string">4 5</merge>
   <merge key="input.x11_options.ButtonMapping" type="string">3 2 1 4 5 6 7 8 9</merge>
   <merge key="input.x11_options.MinSpeed" type="string">0.40</merge>
   <merge key="input.x11_options.MaxSpeed" type="string">0.60</merge>
   <merge key="input.x11_options.AccelFactor" type="string">0.010</merge>

That worked, but never quite satisfactorily.  In some versions, the trackball would only work properly if plugged in after I'd booted up and logged in.  In later versions (notably Fedora 12 and 13) it would never work correctly at all.  In Fedora 13, the HAL method was deprecated and replaced with a method via files under /etc/X11/xorg.conf.d/.  I added a file called "01-trackball.conf" containing:

Section "InputClass"
  Identifier     "trackball"
  MatchProduct   "Logitech USB Trackball"
  Option         "Buttons" "9"
  Option         "EmulateWheel" "on"
  Option         "EmulateWheelButton" "9"
  Option         "ButtonMapping" "3 8 1 4 5 6 7 2 9"

Section "InputClass"
  Identifier     "trackpad"
  MatchProduct   "SynPS/2 Synaptics TouchPad"
  Option         "ButtonMapping" "1 2 3"

These lines define the exact button configuration for both the trackball and the trackpad, and the combination of InputClass and MatchProduct means that the rule works even if the trackball isn't present when X starts.

But it still didn't quite work.  It seemed that the settings always got overridden by Gnome's central mouse options, left or right handed but not my strange mixture.  The main buttons (left and right click) on the trackball had to be the same as the trackpad because Gnome couldn't understand the idea of having the two configured differently.

With a little clear thought, it's probably already obvious what was going wrong, though it was infuriating for a long time.  Gnome (specifically gnome-settings-daemon) does indeed override your nicely thought out X config.  Fortunately, besides "left handed" and "right handed" modes, it also has an extra mode called "don't screw with my damn setup you piece of ****".  It just takes a little more surgery to enable:

$ gconftool-2 -s /apps/gnome_settings_daemon/plugins/mouse/active --type bool false

With Gnome's mouse config stuff safely (and permanently) anaesthetised, you're clear to configure things your way again.