Handling Input
Posted: Fri Oct 28, 2011 01:55
I initially decided to wait on dealing with any UI elements of my game until I had some basic principles developed. Therefore, my input controller was designed to perform a key binding lookup upon an OIS keyPressed() call and then dispatched via the event system that particular notification. For example, the A key dispatches a E_PLAYER_MOVEMENT_LEFT event and W dispatches a E_PLAYER_MOVE_FORWARD event. This has worked great thus far for basic player controls. Now I am working to layer in the CEGUI framework so that I can provide UI components to my game.
As a simple example, when the game starts, the standard key bindings are loaded that map the C key to an event E_OPEN_CHARACTER_FRAME. This event is wired to my CCharacterPanel::OnOpen() method. This method basically contains a loadWindowLayout() call to my specific layout.
This character panel has a text box where the player can specify an away message while they step AFK. What I need to be able to allow is if the player's cursor is presently in this text box and it has focus; any and all input should be routed to that text box; however, if the player should click anywhere else on the game window outside of that text box, then the field looses focus and any and all input would then be handled by the default key mapping system again rather than CEGUI handling them being injected.
What are some possibilities or proper way to wire up this type of input handling based upon where the game cursor's present focus resides using a combination of OGRE / OIS / CEGUI ??
As a simple example, when the game starts, the standard key bindings are loaded that map the C key to an event E_OPEN_CHARACTER_FRAME. This event is wired to my CCharacterPanel::OnOpen() method. This method basically contains a loadWindowLayout() call to my specific layout.
This character panel has a text box where the player can specify an away message while they step AFK. What I need to be able to allow is if the player's cursor is presently in this text box and it has focus; any and all input should be routed to that text box; however, if the player should click anywhere else on the game window outside of that text box, then the field looses focus and any and all input would then be handled by the default key mapping system again rather than CEGUI handling them being injected.
What are some possibilities or proper way to wire up this type of input handling based upon where the game cursor's present focus resides using a combination of OGRE / OIS / CEGUI ??