Main Menu

Projects

Linux Games
Linux Games
[HOWTO Home :: HOWTO INDEX Hardware :: This page]  

Increase USB Mouse Polling Interval

Authors: krejler
Keywords: USB Polling, Mouse Polling

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike2.5 License.

Warning: This HOWTO comes with no explicit or implicit warranty whatsoever. Use at your own risk!

Table of Content

  1. Preface
  2. Enough talking. How do I enable it?
  3. Is there not a way to change the polling interval on-the-fly?
  4. I'm a bit confused. Which interval should I choose? Which one is the best?
  5. Conclusion

1. Preface

This document will guide you through how to override the default polling interval of USB-mice in Linux.

One might ask oneself why this would be a useful feature. There is a good answer for this, and that is: precision. Increasing the interval at which your mouse is polled for data, will make it more precise, since the driver is able to capture mouse movement much more often.

The polling interval decides how often an interrupt is fired for the mouse. Thus, a lower polling interval means a more precise mouse, but also increased interrupt overhead. It is therefore important to find a golden middleway, so you won't lose valuable CPU-time in gaining precision for your gaming.

2. Enough talking. How do I enable it?

The patch to enable the default polling interval to overridden, was first included with the 2.6.12-version of the mainline Linux-kernel, and (some?) 2.6.11-versions of SuSE-kernels. At the time of this writing, the 2.6.12 kernel is three months old. It is therefore doubtful that there is a demand for a patch that backports it to earlier kernels. If such a demand is present, please comment this article, and make me aware of it - I will find a diff for you.

The interval overriding-patch adds a module parameter to the usbhid-driver. This module parameter takes an unsigned integer as its argument. This unsigned integer is used to specify the polling interval in miliseconds. Setting it to 1 ms will yield 1000 interrupts per second, 2 ms will yield 500 interrupts per second, and so on.

How to pass this parameter to the usbhid-driver, depends on how the kernel is configured. Naturally enough, if usbhid is built as a module, a module parameter is needed, and if usbhid is built into the kernel, a boot-time parameter is needed.

Let uss begin with describing how to change the polling interval when usbhid is built directly into the kernel.

Passing module parameters to drivers that are built directly into the kernel is actually quite simple. All that is needed is to add a parameter to your kernel commandline. The parameter is laid out like this:

[driver].[parameter]=[value]

Since the driver we're dealing with is usbhid, and the parameter we want to change is called "mousepoll", a line like the one below should be added to the kernel command for changing the polling interval:

usbhid.mousepoll=[polling interval]

Now, onto the overriding the polling interval when the usbhid driver is built as a module. This is actually just as simple as the method above, just a little different.

First of all, there is, of course, the possibility to pass the parameter to the module using the module-utilities included with your distrobution. A tiny example on how to pass the parameter to the module using insmod/modprobe would look something like this:

modprobe usbhid mousepoll=[polling interval]

Since it isn't too practical to load the module like this every time you reboot, there is a way to always pass certain module parameters to modules on load. The module utilities included with your distrobution has a config file, most likely called something like /etc/modules.conf, or /etc/modprobe.conf, depending on your distrobution. The syntax for adding module parameters to certain modules in those files are as follows:

options [module name] [parm1=foo parm2=bar parm3=baz]

So, to to override the default polling interval using this method, we simply add a line like this:

options usbhid mousepoll=[polling interval]

to one of the files above. Which one to add it to, depends on your distrobution.

3. Is there not a way to change the polling interval on-the-fly?

There is, sort of. You can change the value the driver uses as the overriding-value, by writing to the file /sys/module/usbhid/parameters/mousepoll. However, to make use of this newly set value, you have to re-plug your mouse.

Alternatively, you could also re-load the usbhid module with a new polling interval. This, of course, only works when usbhid is built as a module. It should also be noted, that things like X.org might not like to suddenly lose a driver while running. You have been warned.

4. I'm a bit confused. Which interval should I choose? Which one is the best?

That is hard to say. Most people use, and recommend an interval of 2, meaning that the mouse will be polled for new data at a frequency of 500Hz.

However, I recommend to play around with it. There is always the "but can I really feel it?"-argument. There is of course no need to use an insanely low polling interval, if you can't feel the difference between it, and the lower intervals. This would just be a (hypothetical) loss of valuable CPU cycles.

Therefore, please add your comments of the best polling interval, or the "golden middleway" to the comment-section.

5. Conclusion

Being able to override the polling interval of your mouse is a feature you really grow accustomed to - once you've tried it, you can't live without it. At least that is the way I feel.

Now, there is of course the added interrupt overhead to all this. Personally, I must admit that I do not feel bitten by this, at all. However, I would love to hear a lot of whining about fps-loss, and so on, if that actually happens, as I've already slightly mentioned in the previous chapter.

This "hack" has been tested on quite a lot of mice, and has worked on all of them. Although some special cases like wireless mice, might not be the prime audience of this hack. Nevertheless, it would be quite nice to get some comments on mice that actually do not like being polled as quick as perhaps 500 times per second, and act weirdly because of it.

Mice that are mostly guaranteed to work, are mice from Logitech's MX-series, and mice from Microsoft's Intellimouse-series. Other mice from these two vendors should work as well, as well as specially made OEM-versions of these. Other mouse-brands have been tried out as well, although not as much feedback has been received, as most people (or should I say, people that are crazy enough to try this weird hack?) use Logitech or Microsoft mice.

Last modified: 15.11.09 by GlaDiaC  

Comments
The comments are owned by the poster. We aren't responsible for their content.
Linux Games
Linux Games
Terms of Use · Privacy Policy · Creative Commons License · Credits · Linux Games · Linux Games · World Time · Vereins Intern