Blur Busters Forums

Who you gonna call? The Blur Busters! For Everything Better Than 60Hz™ Skip to content

Measuring keyboard input lag

Everything about input lag. Tips, testing methods, mouse lag, display lag, game engine lag, whole input lag chain, VSYNC OFF vs VSYNC ON, and more!

Re: Measuring keyboard input lag

Postby Sparky » 20 Jan 2015, 19:00

Alright, I tested with the "which one registers first" method, tweaking a millisecond delay in the arduino to figure out where the threshold is:

Kensington K64370A (rubber dome switches)
USB polling interval: 10ms
Key sample interval: 3.6ms
max latency compared to arduino: 27ms
min latency compared to arduino: 12ms
median latency compared to arduino: 19ms

WASD V1 with Cherry MX brown switches:
USB Polling interval: 1ms
Key sample interval: 1.5ms
max latency compared to arduino: 14ms
min latency compared to arduino: 9ms
median latency compared to arduino: 10ms

Arduino Micro:
USB Polling interval: 1ms
Key sample method: interrupt contingent on the keyboard's key sample interval.
Debounce method: Latch on switch closed, reset 5ms after switch opens.

I'm 95% confident these results are accurate to within 2ms. Possible error sources are the arduino delay() function, USB polling quirks, and large delays that happen <1% of the time.
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

Re: Measuring keyboard input lag

Postby flood » 20 Jan 2015, 20:32

random question
when you have multiple usb hid devices, are the polls synchronized?
flood
 
Posts: 881
Joined: 21 Dec 2013, 01:25

Re: Measuring keyboard input lag

Postby Sparky » 20 Jan 2015, 21:03

flood wrote:random question
when you have multiple usb hid devices, are the polls synchronized?
The computer needs to be able to handle asynchronous polling, because different devices are allowed to have different polling rates. If you have two USB controllers that happen to run on the same clock, I could see synchronized polling happening by accident. Of course, there are a lot of reasons you might need to give one input priority over the other, like two keyboards simultaneously typing into a text editor, you have to decide somehow which letter to print first. Ultimately it depends on every part of the hardware and software stack allowing it, so probably not.
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

Re: Measuring keyboard input lag

Postby Sparky » 21 Jan 2015, 10:20

Looking into the MCU of my WASD, it's program memory is OTP ROM, so I won't be modifying it. But I did get to thinking about the 6 key rollover limitation of USB, why not just add another interrupt endpoint to get 12 key rollover? Sure, the system might see 2 keyboards, but is that actually a problem?
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

Re: Measuring keyboard input lag

Postby Q83Ia7ta » 21 Jan 2015, 16:53

Nice results!
What you can say about PS/2 and USB gaming keyboards?
Q83Ia7ta
 
Posts: 591
Joined: 18 Dec 2013, 09:29

Re: Measuring keyboard input lag

Postby Sparky » 21 Jan 2015, 20:20

Q83Ia7ta wrote:Nice results!
What you can say about PS/2 and USB gaming keyboards?

Luckily both these keyboards can do PS/2 as well as USB. The WASD was about 1 ms faster over PS/2(some improvement, but within the error bars), the kensington was significantly faster over PS/2, which makes sense given the 10ms poll interval(more room to improve). The maximum latency dropped by just about exactly 10ms, with the minimum latency staying about the same. Significant improvment, though still slower than the WASD.


So, if your keyboard and computer can do PS/2, it's probably worth using it. If you don't have a PS/2 port, make sure your keyboard uses a 1ms poll interval.
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

Re: Measuring keyboard input lag

Postby stirner » 21 Jan 2015, 20:51

Thanks for the results. I have been using PS/2 over USB despite my keyboard having 1kHz support because I don't like the processor having to maintain strict intervals for both the mouse and keyboard. Although I'm convinced 1kHz USB is faster than PS/2 (over the latter my keyboard maxes out at ~2.7ms between key event reports).

Are you referring to matrix scan rate with key sample rate? Also, any chance to test for debounce times/technique used?
stirner
 
Posts: 74
Joined: 07 Aug 2014, 04:55

Re: Measuring keyboard input lag

Postby Sparky » 21 Jan 2015, 21:04

stirner wrote:Thanks for the results. I have been using PS/2 over USB despite my keyboard having 1kHz support because I don't like the processor having to maintain strict intervals for both the mouse and keyboard. Although I'm convinced 1kHz USB is faster than PS/2 (over the latter my keyboard maxes out at ~2.7ms between key event reports).

Are you referring to matrix scan rate with key sample rate? Also, any chance to test for debounce times/technique used?

I am referring to matrix scan rate. All I can tell you about debounce method is that neither keyboard uses hardware debouncing, and neither keyboard uses interrupts. Definitely room for improvement.

Is the 2.7ms interval for the same key, or for any two keys? That might just be your matrix scan interval.
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

Re: Measuring keyboard input lag

Postby stirner » 21 Jan 2015, 21:28

Two keys. I know that it isn't where the matrix scan caps out because with USB I can hit 1ms.
Either PS/2 operation changes something there or it's simply PS/2 having a maximum sample rate of 360Hz.
stirner
 
Posts: 74
Joined: 07 Aug 2014, 04:55

Re: Measuring keyboard input lag

Postby Sparky » 21 Jan 2015, 22:10

stirner wrote:Two keys. I know that it isn't where the matrix scan caps out because with USB I can hit 1ms.
Either PS/2 operation changes something there or it's simply PS/2 having a maximum sample rate of 360Hz.

Well, it is an interrupt based interface, so it's entirely possible there's some delay after receiving a packet, before you can get the next one. I don't know a whole lot about the PS/2 protocol, but I expect it has some wide tolerances.
Sparky
 
Posts: 516
Joined: 15 Jan 2014, 02:29

PreviousNext

Return to Input Lag

Who is online

Users browsing this forum: daniloberserk and 1 guest