tombsar
Posts: 38
Joined: Wed May 13, 2020 12:40 am

Large mouse button latency

Wed Jul 01, 2020 1:42 am

Hi all,

Something that's been frustrating me ever since I got my RPi4 has been a weird latency in its processing of mouse button events. This is particularly noticeable when dragging windows around, and they stay stuck to the cursor for a noticeable period after I try to let go.

I tried a simple test to measure the problem. On the desktop, move the mouse at a steady speed from the far left to the far right of the screen, and try to draw a selection rectangle that starts as your cursor passes the middle. What I observe is about a 300ms delay between clicking and the selection rectangle starting to appear, so it ends up much closer to the right of the screen than the left. This affects all mouse input, not just on the desktop. Particularly annoying for online chess, as I have to be very careful not to pick up the wrong piece or drop it on the wrong square!

I'm using a stock Raspberry Pi OS 32-bit image that's fully up to date, and I've had this issue across several installs. My mouse is a SteelSeries Sensei on USB.

Is this an issue for anyone else? I'm very curious to know if it's a driver issue for my particular mouse, or something in the OS.

Any ideas how to investigate?

tombsar
Posts: 38
Joined: Wed May 13, 2020 12:40 am

Re: Large mouse button latency

Wed Jul 01, 2020 4:08 pm

I tested the mouse in both USB2 and USB3 ports, and it didn't make a difference.

I then tested an older mouse I have lying around (Novatech Dragunov), and it doesn't have the issue! Unfortunately I can't use it as my main mouse because the scroll wheel is dead, but that's a separate issue...

So it seems as though the issue is isolated to the Steelseries Sensei mouse. I don't have the problem when I connect it to a Windows computer, so it is most likely in the Pi OS software stack somewhere. Any advice on how to debug?

pidd
Posts: 200
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK

Re: Large mouse button latency

Wed Jul 01, 2020 4:25 pm

I had the same problem with a dongle mouse but my USB and bluetooth mice are fine.

bjtheone
Posts: 711
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: Large mouse button latency

Wed Jul 01, 2020 9:00 pm

There are some funky interference issues with wifi, hdmi, usb 3.0 and usb 2.0 rf dongles. Easiest solution is move your usb 2.0 rf dongles away for the Pi vi a USB extender or potential a USB hub.

pidd
Posts: 200
Joined: Fri May 29, 2020 8:29 pm
Location: Wirral, UK

Re: Large mouse button latency

Wed Jul 01, 2020 9:10 pm

bjtheone wrote:
Wed Jul 01, 2020 9:00 pm
There are some funky interference issues with wifi, hdmi, usb 3.0 and usb 2.0 rf dongles. Easiest solution is move your usb 2.0 rf dongles away for the Pi vi a USB extender or potential a USB hub.
Yes, I've done that. i have also put a ferrite clamp-on choke on the USB3 lead out the Pi which improves a lot of 2.4GHz problems.

LTolledo
Posts: 3273
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Large mouse button latency

Wed Jul 01, 2020 9:50 pm

Some mouse models (specially cheapo ones) does have latency problems with RPi
actually have one set of those (tested on RPi1B+ to RPi3B+)

but those latency problem does not appear on other SBC (with another OS).

my work around includes:
1. some config changes in (then) Raspbian Stretch
2. use/get a better mouse (I do have a few around)
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

tombsar
Posts: 38
Joined: Wed May 13, 2020 12:40 am

Re: Large mouse button latency

Wed Jul 01, 2020 11:14 pm

Mine is a wired mouse, so no interference problems.

I wonder if the problem is that this mouse is actually too high-spec, and generating interrupts faster than the pi can handle properly. (I'm not trying to boast, just that I see from the spec sheet that it has a 1000Hz poll rate, which is probably faster than your average consumer mouse).

It feels to me as though somewhere in the software stack motion events are taking priority over button events, as the extra latency only happens when pressing buttons at the same time as moving. Perhaps there is a way to configure this? I'm not familiar enough with Linux and X11's input device handling to know how...

tombsar
Posts: 38
Joined: Wed May 13, 2020 12:40 am

Re: Large mouse button latency

Wed Jul 01, 2020 11:34 pm

tombsar wrote:
Wed Jul 01, 2020 11:14 pm
Perhaps there is a way to configure this? I'm not familiar enough with Linux and X11's input device handling to know how...
Partial success, thanks to DuckDuckGo! Here's what I did:

Code: Select all

lsusb
to find the ID of the mouse.
...
Bus 001 Device 004: ID 1038:1361 SteelSeries ApS Ideazon Sensei
...
"1038:1361" is the part I need.

Code: Select all

lsusb -vd 1038:1361 | grep bInterval
to find out how fast the device wants to be polled. I get "bInterval 1", which agrees with the 1000Hz poll rate claimed by the mouse.

To limit the poll rate to 125Hz, I added the following to the end of my kernel line (/boot/cmdline.txt):

Code: Select all

usbhid.mousepoll=8
After this the button latency is still not perfect, but clearly improved.

Return to “Troubleshooting”