Lower USB mouse polling rate on Raspberry Pi

Recently I’ve been working on mice with 1ms report rate, and I found it having incorrect HID report rate on Raspberry Pi. It needs longer time than I expected to get the results of the HID reports.

Originally, I thought that the mouse polling rate will be the reporting rate of the mouse, which will be 1ms. But I didn’t get the correct output on Raspberry Pi. 

As a result, I learned that Linux can have a fixed polling rate to mice, which will determine how long a mouse is being polled. Rather than the default Linux setting: Using the polling rate as the mouse requested.

For more detailed info about the mouse polling rate may refer to the arch wiki

My machine is Raspberry Pi Model 3 running the latest Raspbian.
I am working on the HID events sent by the mouse. During the experiment, the result was different from the spec of the mouse. The HID report rate is always at 16ms even I am using a mouse at 1ms report rate.

The behavior has something to do with the Raspbian Linux kernel.

In Raspbian’s kernel 4.9.x, the kernel reduced the default mouse polling interval to 60Hz in order to reduce the overhead when using X Window. 

See the commit from Raspberry Pi’s repo:
hid: Reduce default mouse polling interval to 60Hz

Therefore causing the kernel poll the mouse only every 16ms, even if the mouse is reporting at 1ms rate.

To solve the problem,

1. Edit the boot command ( permanent effect )

add this line usbhid.mousepoll=4  at the end of  /boot/cmdline.txt

2. Echo to the parameter file ( lost effect at reboot )

echo 0 /sys/module/usbhid/parameters/mousepoll
and un-plug and plug the mouse/dongle
0 means set the polling rate at whatever the mouse requested

References

USBHID Mouse performance bug?

Mouse slow and lagging after rpi-update [solved]

USB mouse polling rate under Linux

Leave a Reply

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