Jump to content
  • Advertisement
Sign in to follow this  
FruitJuice27

Exactly Timing Keyboard events

This topic is 5044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to know the EXACT time that someone presses a key (within 5 milliseconds). I am using SDL_PollEvent for polling the keyboard. I have a fast engine loop and am working on implementing high acuracy timing. My main concern is how long it takes for the keyboard event to show up in the pollEvent Queue. How often does the operating system poll the keyboard? [Edited by - FruitJuice27 on November 27, 2004 5:18:30 PM]

Share this post


Link to post
Share on other sites
Advertisement
The keyboard is not a precision device. The operating system doesn't poll the keyboard at all. There's a character buffer (in the default mode) that gets filled with scan and key codes by the keyboard driver and emptied from the other end, in queue fashion, by the "operating system." It is possible to tweak this slightly, discarding certain scan codes and resizing the character buffer within certain limits, but that's about it.

You have two options when it comes to keyboards: have each keystroke generate an event which you handle at the next possible opportunity, or instantaneously check the status of the keyboard every iteration of some polling loop. Neither is particularly high precision.

Share this post


Link to post
Share on other sites
Thank you for your reply. :)

I would expect that the mouse is behaving in a simular way? Does anyone know if a mouse event is going to show up in the Queue faster than a keyboard event?

Perhaps a more precice way would be to use a midi device instead of a computer keyboard. I am registering different "hits" and they dont nessisarily need to be keyboard characters.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!