Disabling the mouse scroll wheel left and right click E-mail
Saturday, 05 December 2009 12:00

I recently upgraded my old mouse to a new Logitech LX-6 cordless optical mouse.

It's a great mouse, with one really annoying little problem: the scroll wheel's left click and right click function is really easy to accidentally trigger while scrolling or middle clicking.

This becomes a big issue when using software like Blender since the default setting is to use the middle button/scroll wheel to rotate a model that is being worked on. Accidentally triggering the left and right click function of the mouse breaks out of rotation mode, turning orienting a model into an exercise in frustration.

Disabling left click and right click

It used to be that Ubuntu's input devices were configured using xorg.conf, but this is no longer the case. In these heady, modern times, HAL is used for input configuration.

First up, you'll need to find out what keys represent the left and right click of the scroll wheel. You can do this with "xev", which is executed form the command line. It will open a small window called "Event Tester" which should be arranged next to the command line window so you can see both at the same time. Place your mouse over the xev Event Tester and you'll get a stream of events appearing in the command line window as you move it around and click the button.

Using xev, I was able to determine the codes for the various buttons on my mouse:

  • 1: left click
  • 2: middle click
  • 3: right click
  • 4: scroll up
  • 5: scroll down
  • 6 & 11: scroll wheel left click
  • 8: unknown
  • 7 & 12: scroll wheel right click

To disable buttons 6, 7, 11 & 12, a file has to be created under the fdi/policy folder which I've called "disable-side-scroll.fdi". It doesn't matter what the file is called, so long as it ends with the extension ".fdi".

sudo gedit /etc/hal/fdi/policy/disable-side-scroll.fdi

Simply paste the following into the file and save it.

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.mouse">
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
<merge key="input.x11_options.ButtonMapping" type="string">1 2 3 4 5 0 0 0 0 0 0 0</merge>
</match>
</match>
</device>
</deviceinfo>

To activate the policy, you'll either need to log out and back in, or simply unplug and replug the mouse. If the change is working correctly, then you'll find that side clicks no produce button click events, which you can confirm using xev.

The magic is in the string of numbers on line 6. Each number corresponds to a mouse button identified by xev. To disable buttons 6 through to 12, I've simply put zeros in locations 6 through 12.

Disabling the scroll wheel

To go one step further and disable the scroll wheel altogether, you'll want to replace 4 and 5 with zeros as well.

blog comments powered by Disqus