A mouse might have a frequency of 125Hz, meaning that the system will read off the mouses position every 8ms. Keyboards work in a similar manner.
If a key is pressed and held down, events are continuously raised.
Does every one of these events make it to the game loop?
I imagine that if the game loop does not complete fast enough, the user interactions will buffer, causing a noticeable interaction latency.
I can think of ways to deal with this:
Add a maximum size to the input buffer so that as new events arrive, older ones are pushed from the front of the queue as the new events are pushed to the back of the queue (enqueued).
When the key is pressed, send a "key-down" message and let the game loop repeat the received message until a "key-up" message is received.
Can anyone think of other ways to deal with user input, and do any of my suggestions have obvious flaws?
UPDATE I am not developing a game, I am doing research and so my above questions are purely academic. I am not using any API.