[Orxonox-commit 750] r3279 - in branches/core4/src: core/input orxonox/gamestates orxonox/objects/pickup orxonox/overlays orxonox/overlays/console

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Jul 12 23:08:50 CEST 2009


Author: rgrieder
Date: 2009-07-12 23:08:50 +0200 (Sun, 12 Jul 2009)
New Revision: 3279

Modified:
   branches/core4/src/core/input/Button.cc
   branches/core4/src/core/input/HalfAxis.cc
   branches/core4/src/core/input/InputDevice.h
   branches/core4/src/core/input/InputManager.cc
   branches/core4/src/core/input/InputManager.h
   branches/core4/src/core/input/InputState.h
   branches/core4/src/core/input/KeyBinder.cc
   branches/core4/src/orxonox/gamestates/GSGraphics.cc
   branches/core4/src/orxonox/gamestates/GSLevel.cc
   branches/core4/src/orxonox/gamestates/GSMainMenu.cc
   branches/core4/src/orxonox/objects/pickup/PickupInventory.cc
   branches/core4/src/orxonox/overlays/GUIOverlay.cc
   branches/core4/src/orxonox/overlays/console/InGameConsole.cc
Log:
Heavy clean up in the InputManager; not many real code changes though.
And temporary hack-fixed a problem in the Keybinder with std::vector.reserve(1000) ;)

Modified: branches/core4/src/core/input/Button.cc
===================================================================
--- branches/core4/src/core/input/Button.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/Button.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -59,7 +59,6 @@
         nCommands_[1]=0;
         nCommands_[2]=0;
         this->configContainer_ = 0;
-        clear();
     }
 
     Button::~Button()
@@ -83,10 +82,6 @@
                 commands_[j] = 0;
                 nCommands_[j] = 0;
             }
-            else
-            {
-                commands_[j] = 0;
-            }
         }
     }
 

Modified: branches/core4/src/core/input/HalfAxis.cc
===================================================================
--- branches/core4/src/core/input/HalfAxis.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/HalfAxis.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -48,10 +48,6 @@
             delete[] paramCommands_;
             nParamCommands_ = 0;
         }
-        else
-        {
-            nParamCommands_ = 0; nParamCommands_ = 0;
-        }
     }
 
     bool HalfAxis::addParamCommand(ParamCommand* command)

Modified: branches/core4/src/core/input/InputDevice.h
===================================================================
--- branches/core4/src/core/input/InputDevice.h	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/InputDevice.h	2009-07-12 21:08:50 UTC (rev 3279)
@@ -112,7 +112,7 @@
         InputDeviceTemplated(unsigned int id)
             : InputDevice(id)
         {
-            OIS::InputManager* system = InputManager::getInstance().getInputSystem();
+            OIS::InputManager* system = InputManager::getInstance().getOISInputManager();
             oisDevice_ = static_cast<OISDeviceClass*>(system->createInputObject(OISDeviceValue, true));
             oisDevice_->setEventCallback(static_cast<DeviceClass*>(this));
             COUT(4) << "Instantiated a " << this->getClassName() << std::endl;
@@ -122,7 +122,7 @@
         {
             try
             {
-                InputManager::getInstance().getInputSystem()->destroyInputObject(oisDevice_);
+                InputManager::getInstance().getOISInputManager()->destroyInputObject(oisDevice_);
             }
             catch (...)
             {

Modified: branches/core4/src/core/input/InputManager.cc
===================================================================
--- branches/core4/src/core/input/InputManager.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/InputManager.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -35,13 +35,12 @@
 
 #include "InputManager.h"
 
-#include <climits>
 #include <cassert>
+#include <climits>
 #include <ois/OISException.h>
 #include <ois/OISInputManager.h>
 #include <boost/foreach.hpp>
 
-#include "util/Convert.h"
 #include "util/Exception.h"
 #include "util/ScopeGuard.h"
 #include "core/Clock.h"
@@ -53,68 +52,108 @@
 
 #include "InputBuffer.h"
 #include "KeyDetector.h"
-#include "InputHandler.h"
-#include "InputState.h"
-#include "JoyStickQuantityListener.h"
 #include "JoyStick.h"
+#include "JoyStickQuantityListener.h"
 #include "Mouse.h"
 #include "Keyboard.h"
 
 namespace orxonox
 {
-    SetConsoleCommand(InputManager, calibrate, true);
-    SetConsoleCommand(InputManager, reload, false);
+    // TODO: Add console commands again as member commands
+    //SetConsoleCommand(InputManager, calibrate, true);
+    //SetConsoleCommand(InputManager, reload, false);
     SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
 
+    // Abuse of this source file for the InputHandler
     InputHandler InputHandler::EMPTY;
+
     InputManager* InputManager::singletonRef_s = 0;
 
     /**
     @brief
         Defines the |= operator for easier use.
     */
-    inline InputManager::InputManagerState operator|=(InputManager::InputManagerState& lval,
-                                                      InputManager::InputManagerState rval)
+    inline InputManager::State operator|=(InputManager::State& lval, InputManager::State rval)
     {
-        return (lval = (InputManager::InputManagerState)(lval | rval));
+        return (lval = (InputManager::State)(lval | rval));
     }
 
     /**
     @brief
         Defines the &= operator for easier use.
     */
-    inline InputManager::InputManagerState operator&=(InputManager::InputManagerState& lval, int rval)
+    inline InputManager::State operator&=(InputManager::State& lval, int rval)
     {
-        return (lval = (InputManager::InputManagerState)(lval & rval));
+        return (lval = (InputManager::State)(lval & rval));
     }
 
     // ############################################################
     // #####                  Initialisation                  #####
     // ##########                                        ##########
     // ############################################################
-
     /**
     @brief
         Constructor only sets member fields to initial zero values
         and registers the class in the class hierarchy.
     */
     InputManager::InputManager(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight)
-        : inputSystem_(0)
+        : internalState_(Bad)
+        , oisInputManager_(0)
         , devices_(2)
         , windowHnd_(0)
-        , internalState_(Uninitialised)
-        , stateEmpty_(0)
+        , emptyState_(0)
         , keyDetector_(0)
-        , calibratorCallbackBuffer_(0)
+        , calibratorCallbackHandler_(0)
     {
         RegisterRootObject(InputManager);
 
         assert(singletonRef_s == 0);
         singletonRef_s = this;
 
-        setConfigValues();
+        CCOUT(4) << "Constructing..." << std::endl;
 
-        initialise(windowHnd, windowWidth, windowHeight);
+        this->setConfigValues();
+
+        this->loadDevices(windowHnd, windowWidth, windowHeight);
+
+        // Lowest priority empty InputState
+        emptyState_ = createInputState("empty", false, false, InputStatePriority::Empty);
+        emptyState_->setHandler(&InputHandler::EMPTY);
+        activeStates_[emptyState_->getPriority()] = emptyState_;
+
+        // KeyDetector to evaluate a pressed key's name
+        InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
+        // Create a callback to avoid buttonHeld events after the key has been detected
+        FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);
+        bufferFunctor->setObject(this);
+        detector->setLeaveFunctor(bufferFunctor);
+        keyDetector_ = new KeyDetector();
+        detector->setHandler(keyDetector_);
+
+        // Joy stick calibration helper callback
+        InputState* calibrator = createInputState("calibrator", false, false, InputStatePriority::Calibrator);
+        calibrator->setHandler(&InputHandler::EMPTY);
+        calibratorCallbackHandler_ = new InputBuffer();
+        calibratorCallbackHandler_->registerListener(this, &InputManager::stopCalibration, '\r', true);
+        calibrator->setKeyHandler(calibratorCallbackHandler_);
+
+        this->updateActiveStates();
+
+        {
+            // calibrate console command
+            FunctorMember<InputManager>* functor = createFunctor(&InputManager::calibrate);
+            functor->setObject(this);
+            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "calibrate"), true);
+        }
+        {
+            // reload console command
+            FunctorMember<InputManager>* functor = createFunctor(&InputManager::reload);
+            functor->setObject(this);
+            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "reload"), false);
+        }
+
+        internalState_ = Nothing;
+        CCOUT(4) << "Construction complete." << std::endl;
     }
 
     /**
@@ -136,122 +175,77 @@
     @param windowHeight
         The height of the render window
     */
-    void InputManager::initialise(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight)
+    void InputManager::loadDevices(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight)
     {
-        CCOUT(3) << "Initialising Input System..." << std::endl;
+        CCOUT(3) << "Loading input devices..." << std::endl;
 
-        if (!(internalState_ & OISReady))
-        {
-            CCOUT(4) << "Initialising OIS components..." << std::endl;
+        // When loading the devices they should not already be loaded
+        assert(internalState_ & Bad);
+        assert(devices_[InputDeviceEnumerator::Mouse] == 0);
+        assert(devices_[InputDeviceEnumerator::Keyboard] == 0);
+        assert(devices_.size() == InputDeviceEnumerator::FirstJoyStick);
 
-            // store handle internally so we can reload OIS
-            windowHnd_ = windowHnd;
+        // store handle internally so we can reload OIS
+        windowHnd_ = windowHnd;
 
-            OIS::ParamList paramList;
-            std::ostringstream windowHndStr;
+        OIS::ParamList paramList;
+        std::ostringstream windowHndStr;
 
-            // Fill parameter list
-            windowHndStr << (unsigned int)windowHnd_;
-            paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+        // Fill parameter list
+        windowHndStr << (unsigned int)windowHnd_;
+        paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 #if defined(ORXONOX_PLATFORM_WINDOWS)
-            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
-            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
-            //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
-            //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
+        //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
+        //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+        //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
+        //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
 #elif defined(ORXONOX_PLATFORM_LINUX)
-            paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
-            paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
-            paramList.insert(std::make_pair(std::string("x11_mouse_hide"), "true"));
-            bool kbNoGrab;
-            CommandLine::getValue("keyboard_no_grab", &kbNoGrab);
-            if (kbNoGrab)
-                paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
-            else
-                paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("true")));
+        paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+        paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
+        paramList.insert(std::make_pair(std::string("x11_mouse_hide"), "true"));
+        bool kbNoGrab;
+        CommandLine::getValue("keyboard_no_grab", &kbNoGrab);
+        if (kbNoGrab)
+            paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
+        else
+            paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("true")));
 #endif
 
-            // TODO: clean this up
-            try
-            {
-                inputSystem_ = OIS::InputManager::createInputSystem(paramList);
-                // Exception-safety
-                Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, inputSystem_);
-                CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+        try
+        {
+            oisInputManager_ = OIS::InputManager::createInputSystem(paramList);
+            // Exception-safety
+            Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, oisInputManager_);
+            CCOUT(ORX_DEBUG) << "Created OIS input manager." << std::endl;
 
-                _initialiseKeyboard();
+            if (oisInputManager_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+                devices_[InputDeviceEnumerator::Keyboard] = new Keyboard(InputDeviceEnumerator::Keyboard);
+            else
+                ThrowException(InitialisationFailed, "InputManager: No keyboard found, cannot proceed!");
 
-                // Nothing below should throw anymore, dismiss the guard
-                guard.Dismiss();
-            }
-            catch (OIS::Exception& ex)
-            {
-                ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what());
-            }
-
-            // TODO: Remove the two parameters
-            _initialiseMouse(windowWidth, windowHeight);
-
-            _initialiseJoySticks();
-
-            // clear all buffers
-            clearBuffers();
-
-            internalState_ |= OISReady;
-
-            CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+            // Successful initialisation
+            guard.Dismiss();
         }
-        else
+        catch (std::exception& ex)
         {
-            CCOUT(2) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+            oisInputManager_ = NULL;
+            internalState_ |= Bad;
+            ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what());
         }
 
-        if (!(internalState_ & InternalsReady))
-        {
-            CCOUT(4) << "Initialising InputStates components..." << std::endl;
+        // TODO: Remove the two parameters
+        this->loadMouse(windowWidth, windowHeight);
+        this->loadJoySticks();
 
-            // Lowest priority empty InputState
-            stateEmpty_ = createInputState("empty", false, false, InputStatePriority::Empty);
-            stateEmpty_->setHandler(&InputHandler::EMPTY);
-            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
+        // Reorder states in case some joy sticks were added/removed
+        this->updateActiveStates();
 
-            // KeyDetector to evaluate a pressed key's name
-            InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
-            FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);
-            bufferFunctor->setObject(this);
-            detector->setLeaveFunctor(bufferFunctor);
-            keyDetector_ = new KeyDetector();
-            detector->setHandler(keyDetector_);
-
-            // Joy stick calibration helper callback
-            InputState* calibrator = createInputState("calibrator", false, false, InputStatePriority::Calibrator);
-            calibrator->setHandler(&InputHandler::EMPTY);
-            calibratorCallbackBuffer_ = new InputBuffer();
-            calibratorCallbackBuffer_->registerListener(this, &InputManager::_stopCalibration, '\r', true);
-            calibrator->setKeyHandler(calibratorCallbackBuffer_);
-
-            internalState_ |= InternalsReady;
-
-            CCOUT(4) << "Initialising InputStates complete." << std::endl;
-        }
-
-        _updateActiveStates();
-
-        CCOUT(3) << "Initialising complete." << std::endl;
+        CCOUT(3) << "Input devices loaded." << std::endl;
     }
 
-    void InputManager::_initialiseKeyboard()
+    void InputManager::loadMouse(unsigned int windowWidth, unsigned int windowHeight)
     {
-        assert(devices_[InputDeviceEnumerator::Keyboard] == 0);
-        if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
-            devices_[InputDeviceEnumerator::Keyboard] = new Keyboard(InputDeviceEnumerator::Keyboard);
-        else
-            ThrowException(InitialisationFailed, "InputManager: No keyboard found, cannot proceed!");
-    }
-
-    void InputManager::_initialiseMouse(unsigned int windowWidth, unsigned int windowHeight)
-    {
-        assert(devices_[InputDeviceEnumerator::Mouse] == 0);
-        if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+        if (oisInputManager_->getNumberOfDevices(OIS::OISMouse) > 0)
         {
             try
             {
@@ -273,11 +267,9 @@
     @return
         False joy stick stay uninitialised, true otherwise.
     */
-    void InputManager::_initialiseJoySticks()
+    void InputManager::loadJoySticks()
     {
-        assert(devices_.size() == InputDeviceEnumerator::FirstJoyStick);
-
-        for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+        for (int i = 0; i < oisInputManager_->getNumberOfDevices(OIS::OISJoyStick); i++)
         {
             try
             {
@@ -294,25 +286,29 @@
             it->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick);
     }
 
-    void InputManager::_startCalibration()
+    /**
+    @brief
+        Checks whether there is already a joy stick with the given ID string.
+    @return
+        Returns true if ID is ok (unique), false otherwise.
+    */
+    bool InputManager::checkJoyStickID(const std::string& idString) const
     {
-        BOOST_FOREACH(InputDevice* device, devices_)
-            device->startCalibration();
-
-        getInstance().internalState_ |= Calibrating;
-        getInstance().requestEnterState("calibrator");
+        for (unsigned int i = InputDeviceEnumerator::FirstJoyStick; i < devices_.size(); ++i)
+            if (static_cast<JoyStick*>(devices_[i])->getIDString() == idString)
+                return false;
+        return true;
     }
 
-    void InputManager::_stopCalibration()
+    /**
+    @brief
+        Sets the the name of the command used by the KeyDetector as callback.
+    @param command
+        Command name as string
+    */
+    void InputManager::setKeyDetectorCallback(const std::string& command)
     {
-        BOOST_FOREACH(InputDevice* device, devices_)
-            device->stopCalibration();
-
-        // restore old input state
-        requestLeaveState("calibrator");
-        internalState_ &= ~Calibrating;
-        // Clear buffers to prevent button hold events
-        this->clearBuffers();
+        this->keyDetector_->setCallbackCommand(command);
     }
 
     // ############################################################
@@ -327,71 +323,63 @@
     // TODO: export this to be used with reload()
     InputManager::~InputManager()
     {
-        if (internalState_ != Uninitialised)
-        {
-            CCOUT(3) << "Destroying ..." << std::endl;
+        CCOUT(4) << "Destroying..." << std::endl;
 
-            // Destroy calibrator helper handler and state
-            delete keyDetector_;
-            requestDestroyState("calibrator");
-            // Destroy KeyDetector and state
-            delete calibratorCallbackBuffer_;
-            requestDestroyState("detector");
-            // destroy the empty InputState
-            _destroyState(this->stateEmpty_);
+        // Destroy calibrator helper handler and state
+        delete keyDetector_;
+        this->destroyState("calibrator");
+        // Destroy KeyDetector and state
+        delete calibratorCallbackHandler_;
+        this->destroyState("detector");
+        // destroy the empty InputState
+        this->destroyStateInternal(this->emptyState_);
 
-            // destroy all user InputStates
-            while (inputStatesByName_.size() > 0)
-                _destroyState((*inputStatesByName_.rbegin()).second);
+        // destroy all user InputStates
+        while (statesByName_.size() > 0)
+            this->destroyStateInternal((*statesByName_.rbegin()).second);
 
-            // destroy the devices
-            BOOST_FOREACH(InputDevice*& device, devices_)
-            {
-                std::string className = device->getClassName();
-                try
-                {
-                    if (device)
-                        delete device;
-                    device = 0;
-                    CCOUT(4) << className << " destroyed." << std::endl;
-                }
-                catch (...)
-                {
-                    CCOUT(1) << className << " destruction failed! Potential resource leak!" << std::endl;
-                }
-            }
-            devices_.resize(InputDeviceEnumerator::FirstJoyStick);
+        if (!(internalState_ & Bad))
+            this->destroyDevices();
 
+        CCOUT(4) << "Destruction complete." << std::endl;
+        singletonRef_s = 0;
+    }
+
+    void InputManager::destroyDevices()
+    {
+        CCOUT(3) << "Destroying devices..." << std::endl;
+
+        BOOST_FOREACH(InputDevice*& device, devices_)
+        {
+            if (device == NULL)
+                continue;
+            std::string className = device->getClassName();
             try
             {
-                OIS::InputManager::destroyInputSystem(inputSystem_);
+                delete device;
+                device = 0;
+                CCOUT(4) << className << " destroyed." << std::endl;
             }
             catch (...)
             {
-                CCOUT(1) << "OIS::InputManager destruction failed! Potential resource leak!" << std::endl;
+                CCOUT(1) << className << " destruction failed! Potential resource leak!" << std::endl;
             }
         }
+        devices_.resize(InputDeviceEnumerator::FirstJoyStick);
 
-        singletonRef_s = 0;
-    }
-
-    /**
-    @brief
-        Removes and destroys an InputState.
-    @return
-        True if state was removed immediately, false if postponed.
-    */
-    void InputManager::_destroyState(InputState* state)
-    {
-        assert(state && !(this->internalState_ & Ticking));
-        std::map<int, InputState*>::iterator it = this->activeStates_.find(state->getPriority());
-        if (it != this->activeStates_.end())
+        assert(oisInputManager_ != NULL);
+        try
         {
-            this->activeStates_.erase(it);
-            _updateActiveStates();
+            OIS::InputManager::destroyInputSystem(oisInputManager_);
         }
-        inputStatesByName_.erase(state->getName());
-        delete state;
+        catch (...)
+        {
+            CCOUT(1) << "OIS::InputManager destruction failed! Potential resource leak!" << std::endl;
+        }
+        oisInputManager_ = NULL;
+
+        internalState_ |= Bad;
+        CCOUT(3) << "Destroyed devices." << std::endl;
     }
 
     // ############################################################
@@ -404,72 +392,44 @@
         Public interface. Only reloads immediately if the call stack doesn't
         include the update() method.
     */
-    void InputManager::reloadInputSystem()
+    void InputManager::reload()
     {
         if (internalState_ & Ticking)
         {
             // We cannot destroy OIS right now, because reload was probably
-            // caused by a user clicking on a GUI item. The backtrace would then
+            // caused by a user clicking on a GUI item. The stack trace would then
             // include an OIS method. So it would be a very bad thing to destroy it..
             internalState_ |= ReloadRequest;
         }
-        else if (internalState_ & OISReady)
-            _reload();
+        else if (internalState_ & Calibrating)
+            CCOUT(2) << "Warning: Cannot reload input system. Joy sticks are currently being calibrated." << std::endl;
         else
-        {
-            CCOUT(2) << "Warning: Cannot reload OIS. May not yet be initialised or"
-                     << "joy sticks are currently calibrating." << std::endl;
-        }
+            reloadInternal();
     }
 
     /**
     @brief
         Internal reload method. Destroys the OIS devices and loads them again.
     */
-    void InputManager::_reload()
+    void InputManager::reloadInternal()
     {
-        try
-        {
-            CCOUT(3) << "Reloading ..." << std::endl;
+        CCOUT(3) << "Reloading ..." << std::endl;
 
-            // Save mouse clipping size
-            int mouseWidth  = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingWidth();
-            int mouseHeight = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingHeight();
-
-            internalState_ &= ~OISReady;
-
-            // destroy the devices
-            // destroy the devices
-            BOOST_FOREACH(InputDevice*& device, devices_)
-            {
-                try
-                {
-                    if (device)
-                        delete device;
-                    device = 0;
-                    CCOUT(4) << device->getClassName() << " destroyed." << std::endl;
-                }
-                catch (...)
-                {
-                    CCOUT(1) << device->getClassName() << " destruction failed! Potential resource leak!" << std::endl;
-                }
-            }
-            devices_.resize(InputDeviceEnumerator::FirstJoyStick);
-
-            OIS::InputManager::destroyInputSystem(inputSystem_);
-            inputSystem_ = 0;
-
-            // clear all buffers containing input information
-            clearBuffers();
-
-            initialise(windowHnd_, mouseWidth, mouseHeight);
-
-            CCOUT(3) << "Reloading done." << std::endl;
-        }
-        catch (OIS::Exception& ex)
+        // Save mouse clipping size
+        int clippingWidth = 800;
+        int clippingHeight = 600;
+        if (devices_[InputDeviceEnumerator::Mouse])
         {
-            CCOUT(1) << "An exception has occured while reloading:\n" << ex.what() << std::endl;
+            int clippingWidth  = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingWidth();
+            int clippingHeight = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingHeight();
         }
+
+        this->destroyDevices();
+        this->loadDevices(windowHnd_, clippingWidth, clippingHeight);
+
+        internalState_ &= ~Bad;
+        internalState_ &= ~ReloadRequest;
+        CCOUT(3) << "Reloading complete." << std::endl;
     }
 
     // ############################################################
@@ -485,13 +445,11 @@
     */
     void InputManager::update(const Clock& time)
     {
-        if (internalState_ == Uninitialised)
-            return;
+        if (internalState_ & Bad)
+            ThrowException(General, "InputManager was not correctly reloaded.");
+
         else if (internalState_ & ReloadRequest)
-        {
-            _reload();
-            internalState_ &= ~ReloadRequest;
-        }
+            reloadInternal();
 
         // check for states to leave
         if (!stateLeaveRequests_.empty())
@@ -501,12 +459,12 @@
             {
                 (*it)->left();
                 // just to be sure that the state actually is registered
-                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
+                assert(statesByName_.find((*it)->getName()) != statesByName_.end());
 
                 activeStates_.erase((*it)->getPriority());
                 if ((*it)->getPriority() < InputStatePriority::HighPriority)
                     (*it)->setPriority(0);
-                _updateActiveStates();
+                updateActiveStates();
             }
             stateLeaveRequests_.clear();
         }
@@ -518,7 +476,7 @@
                 it != stateEnterRequests_.end(); ++it)
             {
                 // just to be sure that the state actually is registered
-                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
+                assert(statesByName_.find((*it)->getName()) != statesByName_.end());
 
                 if ((*it)->getPriority() == 0)
                 {
@@ -537,7 +495,7 @@
                         (*it)->setPriority(1);
                 }
                 activeStates_[(*it)->getPriority()] = (*it);
-                _updateActiveStates();
+                updateActiveStates();
                 (*it)->entered();
             }
             stateEnterRequests_.clear();
@@ -549,7 +507,7 @@
             for (std::set<InputState*>::iterator it = stateDestroyRequests_.begin();
                 it != stateDestroyRequests_.end(); ++it)
             {
-                _destroyState((*it));
+                destroyStateInternal((*it));
             }
             stateDestroyRequests_.clear();
         }
@@ -565,21 +523,19 @@
             }
         }
         if (bUpdateRequired)
-            _updateActiveStates();
+            updateActiveStates();
 
         // mark that we now start capturing and distributing input
         internalState_ |= Ticking;
 
-        // Capture all the input. This calls the event handlers in InputManager.
+        // Capture all the input and handle it
         BOOST_FOREACH(InputDevice* device, devices_)
-            device->update(time);
+            if (device != NULL)
+                device->update(time);
 
-        if (!(internalState_ & Calibrating))
-        {
-            // update the states with a general tick afterwards
-            for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
-                activeStatesTicked_[i]->update(time.getDeltaTime());
-        }
+        // Update the states
+        for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
+            activeStatesTicked_[i]->update(time.getDeltaTime());
 
         internalState_ &= ~Ticking;
     }
@@ -589,11 +545,13 @@
         Updates the currently active states (according to activeStates_) for each device.
         Also, a list of all active states (no duplicates!) is compiled for the general update().
     */
-    void InputManager::_updateActiveStates()
+    void InputManager::updateActiveStates()
     {
         // temporary resize
         for (unsigned int i = 0; i < devices_.size(); ++i)
         {
+            if (devices_[i] == NULL)
+                continue;
             std::vector<InputState*>& states = devices_[i]->getStateListRef();
             bool occupied = false;
             states.clear();
@@ -612,8 +570,9 @@
         // Using a std::set to avoid duplicates
         std::set<InputState*> tempSet;
         for (unsigned int i = 0; i < devices_.size(); ++i)
-            for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)
-                tempSet.insert(devices_[i]->getStateListRef()[iState]);
+            if (devices_[i] != NULL)
+                for (unsigned int iState = 0; iState < devices_[i]->getStateListRef().size(); ++iState)
+                    tempSet.insert(devices_[i]->getStateListRef()[iState]);
 
         // copy the content of the std::set back to the actual vector
         activeStatesTicked_.clear();
@@ -628,50 +587,47 @@
     void InputManager::clearBuffers()
     {
         BOOST_FOREACH(InputDevice* device, devices_)
-            device->clearBuffers();
+            if (device != NULL)
+                device->clearBuffers();
     }
 
-
-    // ############################################################
-    // #####                Friend functions                  #####
-    // ##########                                        ##########
-    // ############################################################
-
     /**
     @brief
-        Checks whether there is already a joy stick with the given ID string.
-    @return
-        Returns true if ID is ok (unique), false otherwise.
+        Starts joy stick calibration.
     */
-    bool InputManager::checkJoyStickID(const std::string& idString) const
+    void InputManager::calibrate()
     {
-        for (unsigned int i = InputDeviceEnumerator::FirstJoyStick; i < devices_.size(); ++i)
-            if (static_cast<JoyStick*>(devices_[i])->getIDString() == idString)
-                return false;
-        return true;
+        COUT(0) << "Move all joy stick axes fully in all directions." << std::endl
+                << "When done, put the axex in the middle position and press enter." << std::endl;
+
+        BOOST_FOREACH(InputDevice* device, devices_)
+            if (device != NULL)
+                device->startCalibration();
+
+        internalState_ |= Calibrating;
+        enterState("calibrator");
     }
 
+    void InputManager::stopCalibration()
+    {
+        BOOST_FOREACH(InputDevice* device, devices_)
+            if (device != NULL)
+                device->stopCalibration();
 
+        // restore old input state
+        leaveState("calibrator");
+        internalState_ &= ~Calibrating;
+        // Clear buffers to prevent button hold events
+        this->clearBuffers();
+    }
+
     // ############################################################
-    // #####         Other Public Interface Methods           #####
+    // #####                    Iput States                   #####
     // ##########                                        ##########
     // ############################################################
 
     /**
     @brief
-        Sets the the name of the command used by the KeyDetector as callback.
-    @param command
-        Command name as string
-    */
-    void InputManager::setKeyDetectorCallback(const std::string& command)
-    {
-        this->keyDetector_->setCallbackCommand(command);
-    }
-
-    // ###### InputStates ######
-
-    /**
-    @brief
         Creates a new InputState by type, name and priority.
         
         You will have to use this method because the
@@ -688,7 +644,7 @@
     InputState* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
     {
         InputState* state = new InputState;
-        if (_configureInputState(state, name, bAlwaysGetsInput, bTransparent, priority))
+        if (configureInputState(state, name, bAlwaysGetsInput, bTransparent, priority))
             return state;
         else
         {
@@ -711,19 +667,19 @@
     @return
         True if added, false if name or priority already existed.
     */
-    bool InputManager::_configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority)
+    bool InputManager::configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority)
     {
         if (name == "")
             return false;
         if (!state)
             return false;
-        if (inputStatesByName_.find(name) == inputStatesByName_.end())
+        if (statesByName_.find(name) == statesByName_.end())
         {
             if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
             {
                 // Make sure we don't add two high priority states with the same priority
-                for (std::map<std::string, InputState*>::const_iterator it = this->inputStatesByName_.begin();
-                    it != this->inputStatesByName_.end(); ++it)
+                for (std::map<std::string, InputState*>::const_iterator it = this->statesByName_.begin();
+                    it != this->statesByName_.end(); ++it)
                 {
                     if (it->second->getPriority() == priority)
                     {
@@ -733,7 +689,7 @@
                     }
                 }
             }
-            inputStatesByName_[name] = state;
+            statesByName_[name] = state;
             state->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick);
             state->setName(name);
             state->bAlwaysGetsInput_ = bAlwaysGetsInput;
@@ -751,46 +707,6 @@
 
     /**
     @brief
-        Removes and destroys an input state internally.
-    @param name
-        Name of the handler.
-    @return
-        True if removal was successful, false if name was not found.
-    @remarks
-        You can't remove the internal states "empty", "calibrator" and "detector".
-        The removal process is being postponed if InputManager::update() is currently running.
-    */
-    bool InputManager::requestDestroyState(const std::string& name)
-    {
-        if (name == "empty")
-        {
-            COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
-            return false;
-        }
-        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
-        if (it != inputStatesByName_.end())
-        {
-            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
-            {
-                // The state is still active. We have to postpone
-                stateLeaveRequests_.insert(it->second);
-                stateDestroyRequests_.insert(it->second);
-            }
-            else if (this->internalState_ & Ticking)
-            {
-                // cannot remove state while ticking
-                stateDestroyRequests_.insert(it->second);
-            }
-            else
-                _destroyState(it->second);
-
-            return true;
-        }
-        return false;
-    }
-
-    /**
-    @brief
         Returns the pointer to the requested InputState.
     @param name
         Unique name of the state.
@@ -799,8 +715,8 @@
     */
     InputState* InputManager::getState(const std::string& name)
     {
-        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
-        if (it != inputStatesByName_.end())
+        std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
+        if (it != statesByName_.end())
             return it->second;
         else
             return 0;
@@ -808,17 +724,6 @@
 
     /**
     @brief
-        Returns the current input state (there might be others active too!)
-    @return
-        The current highest prioritised active input state.
-    */
-    InputState* InputManager::getCurrentState()
-    {
-        return (*activeStates_.rbegin()).second;
-    }
-
-    /**
-    @brief
         Activates a specific input state.
         It might not be really activated if the priority is too low!
     @param name
@@ -826,11 +731,11 @@
     @return
         False if name was not found, true otherwise.
     */
-    bool InputManager::requestEnterState(const std::string& name)
+    bool InputManager::enterState(const std::string& name)
     {
         // get pointer from the map with all stored handlers
-        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
-        if (it != inputStatesByName_.end())
+        std::map<std::string, InputState*>::const_iterator it = statesByName_.find(name);
+        if (it != statesByName_.end())
         {
             // exists
             if (activeStates_.find(it->second->getPriority()) == activeStates_.end())
@@ -856,7 +761,7 @@
     @return
         False if name was not found, true otherwise.
     */
-    bool InputManager::requestLeaveState(const std::string& name)
+    bool InputManager::leaveState(const std::string& name)
     {
         if (name == "empty")
         {
@@ -864,8 +769,8 @@
             return false;
         }
         // get pointer from the map with all stored handlers
-        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
-        if (it != inputStatesByName_.end())
+        std::map<std::string, InputState*>::const_iterator it = statesByName_.find(name);
+        if (it != statesByName_.end())
         {
             // exists
             if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
@@ -878,30 +783,60 @@
         return false;
     }
 
-
-    // ############################################################
-    // #####                Console Commands                  #####
-    // ##########                                        ##########
-    // ############################################################
-
     /**
     @brief
-        Starts joy stick calibration.
+        Removes and destroys an input state.
+    @param name
+        Name of the handler.
+    @return
+        True if removal was successful, false if name was not found.
+    @remarks
+        You can't remove the internal states "empty", "calibrator" and "detector".
+        The removal process is being postponed if InputManager::update() is currently running.
     */
-    void InputManager::calibrate()
+    bool InputManager::destroyState(const std::string& name)
     {
-        COUT(0) << "Move all joy stick axes fully in all directions." << std::endl
-                << "When done, put the axex in the middle position and press enter." << std::endl;
+        if (name == "empty")
+        {
+            COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
+            return false;
+        }
+        std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
+        if (it != statesByName_.end())
+        {
+            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
+            {
+                // The state is still active. We have to postpone
+                stateLeaveRequests_.insert(it->second);
+                stateDestroyRequests_.insert(it->second);
+            }
+            else if (this->internalState_ & Ticking)
+            {
+                // cannot remove state while ticking
+                stateDestroyRequests_.insert(it->second);
+            }
+            else
+                destroyStateInternal(it->second);
 
-        getInstance()._startCalibration();
+            return true;
+        }
+        return false;
     }
 
     /**
     @brief
-        Reloads the input system
+        Destroys an InputState internally
     */
-    void InputManager::reload()
+    void InputManager::destroyStateInternal(InputState* state)
     {
-        getInstance().reloadInputSystem();
+        assert(state && !(this->internalState_ & Ticking));
+        std::map<int, InputState*>::iterator it = this->activeStates_.find(state->getPriority());
+        if (it != this->activeStates_.end())
+        {
+            this->activeStates_.erase(it);
+            updateActiveStates();
+        }
+        statesByName_.erase(state->getName());
+        delete state;
     }
 }

Modified: branches/core4/src/core/input/InputManager.h
===================================================================
--- branches/core4/src/core/input/InputManager.h	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/InputManager.h	2009-07-12 21:08:50 UTC (rev 3279)
@@ -43,120 +43,94 @@
 #include <string>
 #include <vector>
 
-#include "util/Math.h"
-#include "util/OrxEnum.h"
 #include "core/OrxonoxClass.h"
+#include "InputState.h"
 
 namespace orxonox
 {
-    struct InputStatePriority : OrxEnum<InputStatePriority>
-    {
-        OrxEnumConstructors(InputStatePriority);
-
-        static const int Empty        = -1;
-        static const int Dynamic      = 0;
-
-        static const int HighPriority = 1000;
-        static const int Console      = HighPriority + 0;
-        static const int Calibrator   = HighPriority + 1;
-        static const int Detector     = HighPriority + 2;
-    };
-
     /**
     @brief
         Captures and distributes mouse and keyboard input.
     */
     class _CoreExport InputManager : public OrxonoxClass
     {
-        // --> setConfigValues is private
-        friend class ClassIdentifier<InputManager>;
-
     public:
-        enum InputManagerState
+        enum State
         {
-            Uninitialised    = 0x00,
-            OISReady         = 0x01,
-            InternalsReady   = 0x02,
-            Ticking          = 0x04,
-            Calibrating      = 0x08,
-            ReloadRequest    = 0x10,
+            Nothing       = 0x00,
+            Bad           = 0x02,
+            Ticking       = 0x04,
+            Calibrating   = 0x08,
+            ReloadRequest = 0x10,
         };
 
         InputManager (size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight);
         ~InputManager();
+        void setConfigValues();
 
-        void initialise(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight);
-
-        void reloadInputSystem();
-
+        void update(const Clock& time);
         void clearBuffers();
+        void calibrate();
+        void reload();
 
-        void setWindowExtents(const int width, const int height);
-        void setKeyDetectorCallback(const std::string& command);
-
+        //-------------------------------
+        // Input States
+        //-------------------------------
         InputState* createInputState(const std::string& name, bool bAlwaysGetsInput = false, bool bTransparent = false, InputStatePriority priority = InputStatePriority::Dynamic);
+        InputState* getState(const std::string& name);
+        bool enterState     (const std::string& name);
+        bool leaveState     (const std::string& name);
+        bool destroyState   (const std::string& name);
 
-        InputState* getState       (const std::string& name);
-        InputState* getCurrentState();
-        bool requestDestroyState   (const std::string& name);
-        bool requestEnterState     (const std::string& name);
-        bool requestLeaveState     (const std::string& name);
-
-        OIS::InputManager* getInputSystem() { return this->inputSystem_; }
+        //-------------------------------
+        // Various getters and setters
+        //-------------------------------
+        void setKeyDetectorCallback(const std::string& command);
         bool checkJoyStickID(const std::string& idString) const;
         unsigned int getJoyStickQuantity() const
             { return devices_.size() - InputDeviceEnumerator::FirstJoyStick; }
+        OIS::InputManager* getOISInputManager()
+            { return this->oisInputManager_; }
 
-        void update(const Clock& time);
-
         static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
-        static InputManager* getInstancePtr() { return singletonRef_s; }
 
-        // console commands
-        static void calibrate();
-        static void reload();
-
     private: // functions
         // don't mess with a Singleton
         InputManager(const InputManager&);
 
         // Intenal methods
-        void _initialiseKeyboard();
-        void _initialiseMouse(unsigned int windowWidth, unsigned int windowHeight);
-        void _initialiseJoySticks();
+        void loadDevices(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight);
+        void loadMouse(unsigned int windowWidth, unsigned int windowHeight);
+        void loadJoySticks();
+        void destroyDevices();
 
-        void _startCalibration();
-        void _stopCalibration();
+        void stopCalibration();
 
-        void _destroyState(InputState* state);
+        void destroyStateInternal(InputState* state);
+        void updateActiveStates();
+        bool configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority);
 
-        void _reload();
+        void reloadInternal();
 
-        void _updateActiveStates();
-        bool _configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority);
-
-        void setConfigValues();
-
     private: // variables
-        OIS::InputManager*                  inputSystem_;          //!< OIS input manager
+        State                               internalState_;        //!< Current internal state
+        OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
         std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
         size_t                              windowHnd_;            //!< Render window handle
-        InputManagerState                   internalState_;        //!< Current internal state
 
         // some internally handled states and handlers
-        InputState*                         stateEmpty_;
+        InputState*                         emptyState_;
         KeyDetector*                        keyDetector_;          //!< KeyDetector instance
-        InputBuffer*                        calibratorCallbackBuffer_;
+        InputBuffer*                        calibratorCallbackHandler_;
 
-        std::map<std::string, InputState*>  inputStatesByName_;
+        std::map<std::string, InputState*>  statesByName_;
+        std::map<int, InputState*>          activeStates_;
+        std::vector<InputState*>            activeStatesTicked_;
 
         std::set<InputState*>               stateEnterRequests_;   //!< Request to enter a new state
         std::set<InputState*>               stateLeaveRequests_;   //!< Request to leave a running state
         std::set<InputState*>               stateDestroyRequests_; //!< Request to destroy a state
 
-        std::map<int, InputState*>          activeStates_;
-        std::vector<InputState*>            activeStatesTicked_;
-
         static InputManager*                singletonRef_s;
     };
 }

Modified: branches/core4/src/core/input/InputState.h
===================================================================
--- branches/core4/src/core/input/InputState.h	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/InputState.h	2009-07-12 21:08:50 UTC (rev 3279)
@@ -35,11 +35,25 @@
 #include <string>
 #include <vector>
 
+#include "util/OrxEnum.h"
 #include "InputHandler.h"
 #include "JoyStickQuantityListener.h"
 
 namespace orxonox
 {
+    struct InputStatePriority : OrxEnum<InputStatePriority>
+    {
+        OrxEnumConstructors(InputStatePriority);
+
+        static const int Empty        = -1;
+        static const int Dynamic      = 0;
+
+        static const int HighPriority = 1000;
+        static const int Console      = HighPriority + 0;
+        static const int Calibrator   = HighPriority + 1;
+        static const int Detector     = HighPriority + 2;
+    };
+
     class _CoreExport InputState : public JoyStickQuantityListener
     {
         friend class InputManager;

Modified: branches/core4/src/core/input/KeyBinder.cc
===================================================================
--- branches/core4/src/core/input/KeyBinder.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/core/input/KeyBinder.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -56,6 +56,9 @@
         mousePosition_[0] = 0;
         mousePosition_[1] = 0;
 
+        joyStickButtons_.reserve(1000);
+        joyStickAxes_.reserve(1000);
+
         RegisterRootObject(KeyBinder);
 
         // intialise all buttons and half axes to avoid creating everything with 'new'

Modified: branches/core4/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSGraphics.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/gamestates/GSGraphics.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -149,7 +149,7 @@
         CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
 
         // enable master input
-        InputManager::getInstance().requestEnterState("master");
+        InputManager::getInstance().enterState("master");
     }
 
     /**
@@ -169,7 +169,7 @@
 */
 
         masterInputState_->setHandler(0);
-        InputManager::getInstance().requestDestroyState("master");
+        InputManager::getInstance().destroyState("master");
         delete this->masterKeyBinder_;
 
         delete this->guiManager_;

Modified: branches/core4/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSLevel.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/gamestates/GSLevel.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -133,7 +133,7 @@
             InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
 
             // level is loaded: we can start capturing the input
-            InputManager::getInstance().requestEnterState("game");
+            InputManager::getInstance().enterState("game");
         }
     }
 
@@ -143,13 +143,13 @@
         {
             GUIManager::getInstance().showGUI("inGameTest");
             GUIManager::getInstance().executeCode("showCursor()");
-            InputManager::getInstance().requestEnterState("guiMouseOnly");
+            InputManager::getInstance().enterState("guiMouseOnly");
         }
         else
         {
             GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
             GUIManager::getInstance().executeCode("hideCursor()");
-            InputManager::getInstance().requestLeaveState("guiMouseOnly");
+            InputManager::getInstance().leaveState("guiMouseOnly");
         }
     }
 
@@ -177,7 +177,7 @@
         //Loader::close();
 
         if (GameMode::showsGraphics())
-            InputManager::getInstance().requestLeaveState("game");
+            InputManager::getInstance().leaveState("game");
 
         if (GameMode::isMaster())
             this->unloadLevel();
@@ -217,7 +217,7 @@
             gameInputState_->setHandler(0);
             guiMouseOnlyInputState_->setHandler(0);
             guiKeysOnlyInputState_->setHandler(0);
-            InputManager::getInstance().requestDestroyState("game");
+            InputManager::getInstance().destroyState("game");
             if (this->keyBinder_)
             {
                 delete this->keyBinder_;
@@ -285,7 +285,7 @@
                 if (bound)
                 {
                     COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-                    InputManager::getInstance().requestEnterState("detector");
+                    InputManager::getInstance().enterState("detector");
                     bindingString = command;
                     bTemporarySaved = bTemporary;
                     bound = false;
@@ -300,7 +300,7 @@
                     std::string name = command.substr(this->keyDetectorCallbackCode_.size());
                     COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
                     this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
-                    InputManager::getInstance().requestLeaveState("detector");
+                    InputManager::getInstance().leaveState("detector");
                     bound = true;
                 }
                 // else: A key was pressed within the same tick, ignore it.

Modified: branches/core4/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSMainMenu.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/gamestates/GSMainMenu.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -95,7 +95,7 @@
             CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_);
         }
 
-        InputManager::getInstance().requestEnterState("mainMenu");
+        InputManager::getInstance().enterState("mainMenu");
 
         this->ambient_ = new SoundMainMenu();
         this->ambient_->play(true);
@@ -105,8 +105,8 @@
     {
         delete this->ambient_;
 
-        InputManager::getInstance().requestLeaveState("mainMenu");
-        InputManager::getInstance().requestDestroyState("mainMenu");
+        InputManager::getInstance().leaveState("mainMenu");
+        InputManager::getInstance().destroyState("mainMenu");
 
         GUIManager::getInstance().setCamera(0);
         GraphicsManager::getInstance().setCamera(0);

Modified: branches/core4/src/orxonox/objects/pickup/PickupInventory.cc
===================================================================
--- branches/core4/src/orxonox/objects/pickup/PickupInventory.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/objects/pickup/PickupInventory.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -87,13 +87,13 @@
         if(PickupInventory::getSingleton()->isVisible()) {
             GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
             GUIManager::getInstance().executeCode("hideCursor()");
-            InputManager::getInstance().requestLeaveState("guiMouseOnly");
+            InputManager::getInstance().leaveState("guiMouseOnly");
         }
         else
         {
             GUIManager::getInstance().showGUI("PickupInventory");
             GUIManager::getInstance().executeCode("showCursor()");
-            InputManager::getInstance().requestEnterState("guiMouseOnly");
+            InputManager::getInstance().enterState("guiMouseOnly");
         }
         PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
     }

Modified: branches/core4/src/orxonox/overlays/GUIOverlay.cc
===================================================================
--- branches/core4/src/orxonox/overlays/GUIOverlay.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/overlays/GUIOverlay.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -69,14 +69,14 @@
             out << (long)this;
             str = out.str();
             GUIManager::getInstance().executeCode("showCursor()");
-            InputManager::getInstance().requestEnterState("guiMouseOnly");
+            InputManager::getInstance().enterState("guiMouseOnly");
             GUIManager::getInstance().executeCode("showGUI(\"" + this->guiName_ + "\", " + str + ")");
         }
         else
         {
             GUIManager::getInstance().executeCode("hideGUI(\"" + this->guiName_ + "\")");
             GUIManager::getInstance().executeCode("hideCursor()");
-            InputManager::getInstance().requestLeaveState("guiMouseOnly");
+            InputManager::getInstance().leaveState("guiMouseOnly");
         }
     }
 

Modified: branches/core4/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- branches/core4/src/orxonox/overlays/console/InGameConsole.cc	2009-07-12 21:06:41 UTC (rev 3278)
+++ branches/core4/src/orxonox/overlays/console/InGameConsole.cc	2009-07-12 21:08:50 UTC (rev 3279)
@@ -97,7 +97,7 @@
         this->deactivate();
 
         // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
-        InputManager::getInstance().requestDestroyState("console");
+        InputManager::getInstance().destroyState("console");
 
         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
         if (ovMan)
@@ -506,7 +506,7 @@
         if (!this->bActive_)
         {
             this->bActive_ = true;
-            InputManager::getInstance().requestEnterState("console");
+            InputManager::getInstance().enterState("console");
             Shell::getInstance().registerListener(this);
 
             this->windowResized(this->windowW_, this->windowH_);
@@ -528,7 +528,7 @@
         if (this->bActive_)
         {
             this->bActive_ = false;
-            InputManager::getInstance().requestLeaveState("console");
+            InputManager::getInstance().leaveState("console");
             Shell::getInstance().unregisterListener(this);
 
             // scroll up




More information about the Orxonox-commit mailing list