Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/InputState


Ignore:
Timestamp:
Sep 15, 2008, 10:14:11 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/InputState

    v1 v1  
     1= InputState =
     2This class is a container for [wiki:KeyHandler KeyHandlers] to make input distribution easier. Information about how to use different InputStates is given in the article for the InputManager. This text deals more about the internals.
     3
     4== Overview ==
     5What is it anyway? Any InputState can be associated with a certain state or mode in the game. This can be as simple as the in-game console or as complicated as a whole level. It doesn't actually matter, it's up to the programmer to decide. From this article's point of view, the important question is "What next?". Whenever input reaches an InputState, it is automatically sent to all registered [wiki:KeyHandler KeyHandlers]. There is no active/inactive, only registered or not. [[br]]
     6In most cases, there is only one KeyHandler registered in an InputState. For instance, the console only needs an OutputBuffer to accumulate text. For this reason InputState is only an abstract class. There are two derivates: SimpleInputStates and ExtendedInputStates, both explained below.
     7
     8== Creating and Destruction ==
     9That part is up to the InputManager as the constructors and destructors are private to all other classes. Call InputManager::getInstance().createInputState<InputState derivative>(string name, int priority) in order to get a new InputState. Very important: It really belongs to the InputManager, so it also takes care of its destruction (also in the case of an InputManager destruction!). [[br]]
     10
     11== SimpleInputState ==
     12This is the easier one. It only supports exactly one InputHandler per device, which is mostly sufficient. With methods like setKeyHandler, you can add a KeyHandler (for instance a KeyBinder). [[br]]
     13setHandler is quite special, as it will register one InputHandler for all devices, even if the device gets added with InputManager::reload().
     14
     15== ExtendedInputState ==
     16Behaves almost exactly like SimpleInputState, but stores an arbitrary number of InputHandlers for each device separately. It also updates the internal list when addHandler was called and the devices change.
     17
     18== Executors ==
     19There is a possibility to register an arbitrary function with no no arguments to be called whenever the state is actually activated (not only added to the list of active states) or deactivated.