Jump to content
  • Advertisement
Sign in to follow this  
algorhythmic

decoupled input

This topic is 5148 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

Hi, I am currently working on an input system amongst other things am in the process of investigating various ways of modeling input in a flexible, extensible and decoupled way. I have performed a search in the GameDev forums and many threads mention the Observer pattern. I am vaguely familiar with this concept but I'm having trouble seeing in what way it can be applied to input. One poster talked about creating interface classes for each input device (IKeyboardSubscriber, etc..) which the interested objects would inherit from. I can see the benefits of such a system but I am still unclear on the manner in which the input would be 'harvested' from the underlying OS in such a system. What would the 'publisher' look like? Any help with this matter would be greatly appreciated. Many Thanks algorhythmic [Edited by - algorhythmic on August 16, 2004 3:23:08 PM]

Share this post


Link to post
Share on other sites
Advertisement
So effectively I wrap the Win32API or DirectInput and upon each loop I publish all the keyboard/mouse events to the input subscribers?

[Edited by - algorhythmic on August 17, 2004 2:55:49 PM]

Share this post


Link to post
Share on other sites
I used DirectInput and I have an InputSystem that creates an InputState object every tick. The InputState object, ideally would store a list of buffers for different devices. Currently I have InputDevice inherited by Keyboard and Mouse. I've hardcoded the InputState to store Keyboard and Mouse buffers, but will change this in due time.

This InputState object is then sent to all InputListeners.

Share this post


Link to post
Share on other sites
It goes beyond simply wrapping up an input API. You want your objects to receive notification of some action that is mapped to a certain key somewhere else. This makes things such as the user changing key assignments and AI a lot easier. For example, an AI control class telling an entity to move forward would look the same to that entity as a player pressing a key to move it forward, even if the player uses a different key to move forward.

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!