Improve the mouse response and acceleration in Debian

Note: This information is now slightly outdated, as the patch is already in Debian Squeeze.

One of my biggest issues with moving from Windows to Linux as my desktop is how the mouse is handled in xorg. In xorg, the mouse had (and still has, in Debian Lenny) two settings for mouse speed: acceleration and threshold. Simply put, what these do is that whenever the mouse is moving faster than the threshold, it gets accelerated by the acceleration value, and otherwise it’s unaccelerated.

While this may work for some people, I found it horribly annoying. Before anyone jumps up and bites me, I do know that I can set the threshold to 0 and get some sort of normal acceleration, but I hate that one too. Luckily, Simon Thum has come up with a solution.

His solution has been patched into the newer versions of xorg. The bug is available at freedesktop.org, and the latest patch is here. However, while this patch goes into version 1.4 or xorg without a hitch, the Debian (and probably Ubuntu) build system requires an additional change in the Makefile.in file.

In short, here’s a howto for Debian Lenny on getting the new and much improved mouse handling in:

Become root

su (type root password)

First, make sure you’ve installed everything required to build stuff in the first place:

apt-get update && apt-get install build-essential fakeroot

Become a normal user again

exit

Make a temporary directory, cd to it, then get the sources for xserver-xorg-core

mkdir mousepatch
cd mousepatch
apt-get source xserver-xorg-core

apt-get will download the sources, extract them and apply the Debian-specific patches.
Next, we need all the build-dependencies. These are the libraries used in xserver-xorg-core, which we’ll need to compile the source code.

apt-get build-dep xserver-xorg-core

Now make a backup of the source code (This is not strictly necessary, but I like to do so anyway before messing around with it. Saves doing another apt-get download.)

cp -r xorg-server-1.4.2 xorg-server-1.4.2-orig

Now we want to apply the mouse patch. You can either use Simon’s original patch from the link above, or you can download a Debian-specific version of it here. This is the exact same patch as the one above, except it only fits into this specific source code, and it contains the changes to the Makefile.in file, which allows dpkg-buildpackage to successfully compile it.

LINK TO DEBIAN-SPECIFIC PATCH

cd xorg-server-1.4.2
patch -p1 <path to mouse patch>

Now build the package.

dpkg-buildpackage -rfakeroot

This will generate quite a few .deb files in the parent directory, and will probably also exit with a return value of 1, complaining it is unable to find Julien Christau’s private key. You are most likely not Julien Christau, so you will not be able to sign the package as him. This is irrelevant, as we’re not going to distribute this package anyway.

The only .deb you have actually changed is the one named xserver-xorg-core_1.4.2-10_i386.deb, so this is the one we want to install:

cd ..
su   (root password again)
dpkg -i xserver-xorg-core_1.4.2-10_i386.deb

Now, assuming all went well, you may restart X or reboot, whatever your preference, and enjoy your newfound mouse bliss. I actually prefer my new Linux mouse-setup to my dualbooted WinXP IntelliMouse drivers now.

To learn how to set up your new mouse acceleration, please refer to the developer documentation. For the record, these are the relevant lines from xorg.conf for my current setup:

Section "InputDevice"
    Identifier	"Configured Mouse"
    Driver		"mouse"
    Option		"Device"	"/dev/input/mice"
    Option		"Protocol"	"auto"
    Option		"Buttons"	"7"
    Option		"ButtonMapping"	"1 2 3 6 7"
    Option		"ZAxisMapping"	"4 5"
    Option		"AccelerationProfile" "1"
    Option		"VelocityScale" "10"
EndSection

Only the AccelerationProfile and VelocityScale is specific to this patch. Also, I use “xset m 18/10 0” to set my mouse speed.

3 Comments

  • Jimmy says:

    WOW! I just got this working and it’s PERFECT! THANKS!!!!!!!!1

  • Shay says:

    Thanks for this. I’m coming from Mac OS Classic and wanted to write my own mouse acceleration handling that matches the Mac’s (using an acceleration curve defined by a table). This has been perfect for figuring out what code I need to modify, and how to rebuild it. The main trick will be testing changes without having to reboot every time…

Leave a Reply

Your email address will not be published. Required fields are marked *