Hi, I’m currently working on a rhythm game in which we need to support the best accuracy possible for keyboard input. Ideally this should be as accurate to the millisecond as possible.
The InputSystem’s input events currently include a ‘time’ at which the event is generated. With a device such as a gamepad I’m able to set a high polling frequency (125hz+) and get a time value which tells me when the event was generated during a given frame. When the input event is processed I’m able to calculate a deltaTime from the event’s time to the current time the event is being processed in Update and use that to improve our input accuracy with a gamepad. The game runs at 60fps so the time difference is generally between 1-16ms which is what I was expecting. However, on Keyboard the time difference is much more consistent and much smaller tending to be less than 1ms. This leads me to believe the keyboard events are being generated in a more frame-rate dependent way and I’m not getting the accuracy improvement I was hoping for.
I’m aware that you can use FixedUpdate to process input events however our game does make some use of physics and I’d rather not increase the rate FixedUpdate runs to increase our input accuracy.
So my main question is how are the Keyboard events being generated? Are they being generated on the main thread? It seems like I cannot set a polling rate for the keyboard to get more accurate timestamps for InputEvents generated by the keyboard. Is fixed update the only way I have to improve the frequency of keyboard polling?
Btw, I am getting input events by subscribing to the InputAction’s started callback. I am then processing the events later in an Update() method.