Mouse Input Latency
Hello! Awesome project and loving mine so far. I've attached a USB mouse to my Raspberry Pi 3A+ and have the output through the IBM PC compatible board through Mouse PS/2.
I am noticing some input latency (feels more than 0.75ms) when moving the mouse consistently (similar mouse movements to how you would move in a fast paced shooter such as Unreal Tournament, or just stress testing by moving the mouse in a circle consistently).
However, latency has been great for individual key presses (clicks), but seems to be noticeable with consistent fast input.
I unfortunately don't have any measurements or analysis, but just an anecdotal experience which I notice the difference when the mouse is plugged directly in to the PC vs through the USB4VC.
Hi there! Another user recently had a similar issue with Pi 3B+. It was solved by adding force_turbo=1 in the config.txt under boot partition on the SD card. The user reports that a Pi4 works out of box too.
New development! Try adding usbhid.mousepoll=0 to the end of cmdline.txt under boot partition on the SD card.
This will increase the mouse polling rate for better responsiveness.
More info here: https://peppe8o.com/fixing-slow-mouse-with-raspberry-pi-os/
Thanks again for the discussions in the Discord channel leading to discovering usbhid.mousepoll=0 which indeed does fix the mouse latency issue!
Adding to that article above and in case anyone is curious, the RPi usbhid driver will default to 62.5Hz for all mouse input (presumably to keep the performance hit low on the CPU). Details of this happening in the driver can be found on this line: https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/hid/usbhid/hid-core.c#L1114
Setting to usbhid.mousepoll=0 will bypass that code and use the mouse poll interval requested by the device/mouse.
Also just a troubleshooting note for people (like me) specifically running Raspberry Pi 3A+ which only has 1 physical USB port:
- I added
usbhid.mousepoll=0to the end of/boot/cmdline.txt - I used a tool evhz: https://git.sr.ht/~iank/evhz which outputs the current Hz mouse refresh rate
- When I plugged directly in to onboard USB port this was the output:
Press CTRL-C to exit.
event0: SteelSeries Sensei Raw Gaming Mouse
event1: SteelSeries Sensei Raw Gaming Mouse
event2: SteelSeries Sensei Raw Gaming Mouse
event3: vc4
SteelSeries Sensei Raw Gaming Mouse: Latest 62Hz, Average 61Hz
SteelSeries Sensei Raw Gaming Mouse: Latest 62Hz, Average 61Hz
SteelSeries Sensei Raw Gaming Mouse: Latest 62Hz, Average 61Hz
-
For some reason it's capped at 62Hz and I could still notice latency
-
Once I plugged in a USB Hub or USB Hat to the RPi 3A+ and plugged my mouse in to that, this is what evhz reported:
SteelSeries Sensei Raw Gaming Mouse: Latest 499Hz, Average 472Hz
SteelSeries Sensei Raw Gaming Mouse: Latest 500Hz, Average 473Hz
SteelSeries Sensei Raw Gaming Mouse: Latest 500Hz, Average 474Hz
SteelSeries Sensei Raw Gaming Mouse: Latest 500Hz, Average 476Hz
- 500Hz! Much better. Not sure why it works properly with a USB hub, but in combination with
usbhid.mousepoll=0it fixed all latency issues with a mouse for me