Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 20, 2008, 6:49:24 PM (16 years ago)
Author:
rgrieder
Message:

Finally! The InputManager is now working like I imagined it to. And it's even easier to use it as well.
A little explanation: Every time you change something about the input distribution, it is a change of 'state' represented by the class 'InputState'.
That can be for instance: "console", "game", "gui", etc. Every state has a name and a priority which describes who comes first. Now if one state doesn't handle mouse input or instance, then the one with the next lower priority gets it. To prevent that, you can add the 'EmptyHandler' to the state with setMouseHandler.
InputState is just an abstract base class. There are two classes implementing it: SimpleInputState and ExtendedInputState. The latter allows for multiple input handlers for one single device.

Basically, what you need to know is what you see in Orxonox.cc, InGameConsole.cc and Shell.cc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/Orxonox.cc

    r1629 r1637  
    5858#include "core/Loader.h"
    5959#include "core/input/InputManager.h"
     60#include "core/input/SimpleInputState.h"
     61#include "core/input/KeyBinder.h"
    6062#include "core/TclBind.h"
    6163#include "core/Core.h"
     
    135137    if (this->timer_)
    136138      delete this->timer_;
     139    dynamic_cast<SimpleInputState*>(InputManager::getState("game"))->removeAndDestroyAllHandlers();
    137140    InputManager::destroy();
    138141    GraphicsEngine::getSingleton().destroy();
     
    290293            ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
    291294        return false;
     295      KeyBinder* keyBinder = new KeyBinder();
     296      InputManager::createSimpleInputState("game", 20)->setHandler(keyBinder);
    292297
    293298      // TOOD: load the GUI here
    294299      // set InputManager to GUI mode
    295       InputManager::setInputState(InputManager::IS_GUI);
    296300      // TODO: run GUI here
    297301
    298302      // The following lines depend very much on the GUI output, so they're probably misplaced here..
    299303
    300       InputManager::setInputState(InputManager::IS_NONE);
     304      keyBinder->loadBindings();
     305      InputManager::requestEnterState("game");
    301306
    302307      // create Ogre SceneManager
     
    325330        return false;
    326331    }
    327 
    328     InputManager::setInputState(InputManager::IS_NORMAL);
    329332
    330333    return startRenderLoop();
Note: See TracChangeset for help on using the changeset viewer.