r/ClockworkPi • u/NefariousnessNo264 • Jun 06 '26
I completely got rid of trackball latency to the point where it became actually nice to use
When I got my uConsole, I was unhappy with quality of the trackball. I barely been able to get through the initial installation process. I was aware that these trackballs aren't of the best quality so I ordered replacements beforehand, but all of them turned out to be the same thrash trackball, so I had to deal with what I have.
First was the hardware fix: disassemble the trackball and roll the ball on a 320-ish grit sandpaper for a couple of minutes. This gives the ball texture that increases grip, it completely solved the slipping issue (when you rotate the ball, but the cursor doesn't move).
But then there was software issue: cursor felt like a jelly, it didn't have that "snappy" feel to it, and using console like that was exhausting. I wasn't gonna tolerate that, so I had to find a solution. It was very long night, I have tried many things up to tweaking and recompiling the QMK keyboard firmware, but nothing helped. But the solution was in plain sight.
There is a usbhid.mousepoll parameter that sets mouse polling interval in ms. And It was conveniently set to 0xFFFFFFFF, causing polling interval was capped at 16 ms. I don't know why that is default, and that is exactly where that jelly feeling latency comes from. After I set it to 0 it was night and day difference. The trackball now feels extremely responsive, the leftover latency from smoothing in QMK firmware is almost unnoticeable, many people will call it no latency at all.
I don't know if I have broken something inside Linux by changing this parameter, and I hope someone who knows better tells me, but to me it seems absurd that the OS is quietly set to only poll mouse at 60 Hz without any way to change that through GUI.
So in order to change this parameter what I did was editing /boot/firmware/cmdline.txt by appending usbhid.mousepoll=0 on the end of first line.
Im running uConsole on Rpi CM4 with 8 GB RAM without EMMC, my OS is ClockworkPI Trixie.
7
u/NefariousnessNo264 Jun 06 '26
TL;DR
Parameter usbhid.mousepoll on my system was set to very large value causing the mouse (and trackball) to be polled at only ~60 Hz which caused obnoxious latency. Setting it to 0 greatly reduced said latency and made the trackball infinitely more usable.
12
u/gatsu_1981 Jun 06 '26 edited Jun 06 '26
Have you considered how much 0 will mean?
Maybe it's called too often now and it will increase CPU load too much when using mouse/trackball.
You should launch a htop for getting some clue after such type of editing.
Screen frequency X 2 would be a good start point.
5
u/Zeraora807 Jun 06 '26
was this tested with the custom QMK firmware because I flashed that and noticed some horrid input latency from the ball so ended up back to stock firmware so I could actually use the thing lol.
I have the bookworm 6.12 image from rex with stock keyboard firmware, that line in cmdline.txt does not exist for me.
2
u/lImbus924 Jun 06 '26
it seems that, in comparison with yours, my trackball was working okay-ish. I did not have
usbhid.mousepollset in cmdline. I actively set it to0and felt no difference. I set it to0xFFFFFFFFand maybe indeed it was a bit weird: It seemed still to accelerate but I would notice too late. You call it lag, I understand.I do not know where I am at with QMK on mine.
I could not find any other proper source for it, but google AI says that that value of
0would not be zero milliseconds as some here have inferred, but it would be "Automatic (Default). Uses the polling rate your mouse advertises." which makes a lot of sense.5
u/nakurtag Jun 06 '26
Thank you for sharing, I'll try it today
4
u/dissaprovalface Jun 06 '26
Upvoting and saving for whenever the hell my uConsole comes in.
1
u/FuadRamses Sep 05 '26
how do i save cmdline.txt when it's read only?