decoupled input

Started by
3 comments, last by algorhythmic 19 years, 8 months ago
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]
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi
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]
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi
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.
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.
-------------------------http://www.roachpuppy.com
Someone mentionned event systems but I'm not having much luck finding information about this.
[email=algorhythmic@transcendenz.co.uk]algorhythmic[/email] | home | xltronic | whatever you do will be insignificant, but it is very important that you do it - mahatma gandhi

This topic is closed to new replies.

Advertisement