I've always used to expose all current user input in a singleton called InputManager, which has it's state updated on every frame. On every frame, i poll SDL input for changes, and update the state of InputManager. Then, all my game objects are able to ask it for the state of keys like this:
InputManager.isKeyDown('Left');InputManager.isKeyDown('Right');Do you guys think this is a good way of handling input? How do you do it in your engines?
My preferd way of handling input would be event driven. I just think its a much better and cleaner way of handling inputs and events all togheter. Then again thats my opinion and maybe someone else has better points on handle keyboard input.
If you need some examples check http://lazyfoo.net/tutorials/SDL/index.php Lesson 3 for event and Lesson 4 for keyboard handling