Index: code/branches/core5/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/core5/data/defaultConfig/keybindings.ini	(revision 5862)
+++ code/branches/core5/data/defaultConfig/keybindings.ini	(revision 5863)
@@ -25,5 +25,5 @@
 KeyEscape="exit"
 KeyF="scale -1 moveUpDown"
-KeyF1=
+KeyF1="OverlayGroup toggleVisibility Debug"
 KeyF10=
 KeyF11=
@@ -41,5 +41,5 @@
 KeyF9=
 KeyG=greet
-KeyGrave=
+KeyGrave="openConsole"
 KeyH=
 KeyHome=showGUI
@@ -126,5 +126,5 @@
 KeyU=
 KeyUP="scale 1 moveFrontBack"
-KeyUnassigned=
+KeyUnassigned="openConsole"
 KeyUnderline=
 KeyUnlabeled=
Index: code/branches/core5/data/defaultConfig/masterKeybindings.ini
===================================================================
--- code/branches/core5/data/defaultConfig/masterKeybindings.ini	(revision 5862)
+++ 	(revision )
@@ -1,167 +1,0 @@
-[Keys]
-KeyA=
-KeyABNT_C1=
-KeyABNT_C2=
-KeyAT=
-KeyAX=
-KeyApostrophe=
-KeyApps=
-KeyB=
-KeyBack=
-KeyBackslash=
-KeyC=
-KeyCalculator=
-KeyCapsLock=
-KeyColon=
-KeyComma=
-KeyConvert=
-KeyD=
-KeyDelete=
-KeyDivide=
-KeyDown=
-KeyE=
-KeyEnd=
-KeyEquals=
-KeyEscape=
-KeyF=
-KeyF1="OverlayGroup toggleVisibility Debug"
-KeyF10=
-KeyF11=
-KeyF12=
-KeyF13=
-KeyF14=
-KeyF15=
-KeyF2=
-KeyF3=
-KeyF4=
-KeyF5=
-KeyF6=
-KeyF7=
-KeyF8=
-KeyF9=
-KeyG=
-KeyGrave="openConsole"
-KeyH=
-KeyHome=
-KeyI=
-KeyInsert=
-KeyJ=
-KeyK=
-KeyKana=
-KeyKanji=
-KeyL=
-KeyLeft=
-KeyLeftAlt=
-KeyLeftBracket=
-KeyLeftControl=
-KeyLeftShift=
-KeyLeftWindows=
-KeyLessThan=
-KeyM=
-KeyMail=
-KeyMediaSelect=
-KeyMediaStop=
-KeyMinus=
-KeyMultiply=
-KeyMute=
-KeyMyComputer=
-KeyN=
-KeyNextTrack=
-KeyNoConvert=
-KeyNumLock=
-KeyNumRow0=
-KeyNumRow1=
-KeyNumRow2=
-KeyNumRow3=
-KeyNumRow4=
-KeyNumRow5=
-KeyNumRow6=
-KeyNumRow7=
-KeyNumRow8=
-KeyNumRow9=
-KeyNumpad0=
-KeyNumpad1=
-KeyNumpad2=
-KeyNumpad3=
-KeyNumpad4=
-KeyNumpad5=
-KeyNumpad6=
-KeyNumpad7=
-KeyNumpad8=
-KeyNumpad9=
-KeyNumpadAdd=
-KeyNumpadComma=
-KeyNumpadEnter=
-KeyNumpadEquals=
-KeyNumpadPeriod=
-KeyNumpadSubtract=
-KeyO=
-KeyP=
-KeyPageDown=
-KeyPageUp=
-KeyPause=
-KeyPeriod=
-KeyPlayPause=
-KeyPower=
-KeyPreviousTrack=
-KeyQ=
-KeyR=
-KeyReturn=
-KeyRight=
-KeyRightAlt=
-KeyRightBracket=
-KeyRightControl=
-KeyRightShift=
-KeyRightWindows=
-KeyS=
-KeyScrollLock=
-KeySemicolon=
-KeySlash=
-KeySleep=
-KeySpace=
-KeyStop=
-KeySystemRequest=
-KeyT=
-KeyTab=
-KeyU=
-KeyUP=
-KeyUnassigned="openConsole"
-KeyUnderline=
-KeyUnlabeled=
-KeyV=
-KeyVolumeDown=
-KeyVolumeUp=
-KeyW=
-KeyWake=
-KeyWebBack=
-KeyWebFavorites=
-KeyWebForward=
-KeyWebHome=
-KeyWebRefresh=
-KeyWebSearch=
-KeyWebStop=
-KeyX=
-KeyY=
-KeyYen=
-KeyZ=
-
-[MouseButtons]
-MouseButton3=
-MouseButton4=
-MouseButton5=
-MouseButton6=
-MouseButton7=
-MouseLeft=
-MouseMiddle=
-MouseRight=
-MouseWheel1Down=
-MouseWheel1Up=
-MouseWheel2Down=
-MouseWheel2Up=
-
-[MouseAxes]
-MouseXNeg=
-MouseXPos=
-MouseYNeg=
-MouseYPos=
-
Index: code/branches/core5/src/libraries/core/Core.cc
===================================================================
--- code/branches/core5/src/libraries/core/Core.cc	(revision 5862)
+++ code/branches/core5/src/libraries/core/Core.cc	(revision 5863)
@@ -69,4 +69,5 @@
 #include "TclThreadManager.h"
 #include "input/InputManager.h"
+#include "input/KeyBinderManager.h"
 
 namespace orxonox
@@ -288,4 +289,7 @@
         inputManager_.reset(new InputManager());
 
+        // Manages KeyBinders and makes them available
+        keyBinderManager_.reset(new KeyBinderManager());
+
         // load the CEGUI interface
         guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),
@@ -304,4 +308,5 @@
         this->graphicsScope_.reset();
         this->guiManager_.reset();
+        this->keyBinderManager_.reset();
         this->inputManager_.reset();
         this->graphicsManager_.reset();
Index: code/branches/core5/src/libraries/core/Core.h
===================================================================
--- code/branches/core5/src/libraries/core/Core.h	(revision 5862)
+++ code/branches/core5/src/libraries/core/Core.h	(revision 5863)
@@ -100,4 +100,5 @@
             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
+            scoped_ptr<KeyBinderManager>  keyBinderManager_;    //!< Manages all KeyBinders
             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
             scoped_ptr<Scope<ScopeID::Root> >     rootScope_;
Index: code/branches/core5/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/core5/src/libraries/core/CorePrereqs.h	(revision 5862)
+++ code/branches/core5/src/libraries/core/CorePrereqs.h	(revision 5863)
@@ -212,4 +212,5 @@
     class JoyStick;
     class KeyBinder;
+    class KeyBinderManager;
     class Keyboard;
     class KeyDetector;
Index: code/branches/core5/src/libraries/core/input/CMakeLists.txt
===================================================================
--- code/branches/core5/src/libraries/core/input/CMakeLists.txt	(revision 5862)
+++ code/branches/core5/src/libraries/core/input/CMakeLists.txt	(revision 5863)
@@ -9,4 +9,5 @@
   JoyStickQuantityListener.cc
   KeyBinder.cc
+  KeyBinderManager.cc
   Keyboard.cc
   KeyDetector.cc
Index: code/branches/core5/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/InputManager.cc	(revision 5862)
+++ code/branches/core5/src/libraries/core/input/InputManager.cc	(revision 5863)
@@ -264,9 +264,4 @@
     }
 
-    void InputManager::setKeyDetectorCallback(const std::string& command)
-    {
-        this->keyDetector_->setCallbackCommand(command);
-    }
-
     // ############################################################
     // #####                    Destruction                   #####
Index: code/branches/core5/src/libraries/core/input/InputManager.h
===================================================================
--- code/branches/core5/src/libraries/core/input/InputManager.h	(revision 5862)
+++ code/branches/core5/src/libraries/core/input/InputManager.h	(revision 5863)
@@ -161,6 +161,4 @@
         // Various getters and setters
         //-------------------------------
-        //! Sets the the name of the command used by the KeyDetector as callback.
-        void setKeyDetectorCallback(const std::string& command);
         //! Returns the number of joy stick that have been created since the c'tor or last call to reload().
         unsigned int getJoyStickQuantity() const
Index: code/branches/core5/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyBinder.cc	(revision 5862)
+++ code/branches/core5/src/libraries/core/input/KeyBinder.cc	(revision 5863)
@@ -27,13 +27,9 @@
  */
 
-/**
- @file
- @brief Implementation of the different input handlers.
- */
-
 #include "KeyBinder.h"
 
 #include "util/Convert.h"
 #include "util/Debug.h"
+#include "util/Exception.h"
 #include "core/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
@@ -48,6 +44,7 @@
         Constructor that does as little as necessary.
     */
-    KeyBinder::KeyBinder()
+    KeyBinder::KeyBinder(const std::string& filename)
         : deriveTime_(0.0f)
+        , filename_(filename)
     {
         mouseRelative_[0] = 0;
@@ -103,4 +100,8 @@
         // set them here to use allHalfAxes_
         setConfigValues();
+
+        // Load the bindings if filename was given
+        if (!this->filename_.empty())
+            this->loadBindings();
     }
 
@@ -240,24 +241,15 @@
     @brief
         Loads the key and button bindings.
-    @return
-        True if loading succeeded.
-    */
-    void KeyBinder::loadBindings(const std::string& filename)
+    */
+    void KeyBinder::loadBindings()
     {
         COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
 
-        if (filename.empty())
-            return;
-
-        if (this->configFile_ == ConfigFileType::NoType)
-        {
-            // Get a new ConfigFileType from the ConfigFileManager
-            this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
-        }
-
-        ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
+        // Get a new ConfigFileType from the ConfigFileManager
+        this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
+
+        ConfigFileManager::getInstance().setFilename(this->configFile_, this->filename_);
 
         // Parse bindings and create the ConfigValueContainers if necessary
-        clearBindings();
         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
             it->second->readConfigValue(this->configFile_);
Index: code/branches/core5/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyBinder.h	(revision 5862)
+++ code/branches/core5/src/libraries/core/input/KeyBinder.h	(revision 5863)
@@ -26,10 +26,4 @@
  *
  */
-
-/**
-@file
-@brief
-    Different definitions of input processing.
-*/
 
 #ifndef _KeyBinder_H__
@@ -53,20 +47,32 @@
     /**
     @brief
-        Handles mouse, keyboard and joy stick input while in the actual game mode.
-        Manages the key bindings.
+        Maps mouse, keyboard and joy stick input to command strings and executes them.
+
+        The bindings are stored in ini-files (like the one for configValues) in the config Path.
+    @remarks
+        You cannot change the filename because the KeyBinderManager maps these filenames to the
+        KeyBinders. If you need to load other bindings, just create a new one.
     */
     class _CoreExport KeyBinder : public InputHandler, public JoyStickQuantityListener
     {
     public:
-        KeyBinder ();
+        KeyBinder (const std::string& filename);
         virtual ~KeyBinder();
 
-        void loadBindings(const std::string& filename);
         void clearBindings();
         bool setBinding(const std::string& binding, const std::string& name, bool bTemporary = false);
+        const std::string& getBindingsFilename()
+            { return this->filename_; }
         void setConfigValues();
         void resetJoyStickAxes();
 
     protected: // functions
+        void loadBindings();
+        void buttonThresholdChanged();
+        void initialiseJoyStickBindings();
+        void compilePointerLists();
+        // from JoyStickQuantityListener interface
+        virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
+
         void allDevicesUpdated(float dt);
         void mouseUpdated(float dt);
@@ -74,10 +80,4 @@
         // internal
         void tickHalfAxis(HalfAxis& halfAxis);
-
-        void buttonThresholdChanged();
-        // from JoyStickQuantityListener interface
-        virtual void JoyStickQuantityChanged(const std::vector<JoyStick*>& joyStickList);
-        void initialiseJoyStickBindings();
-        void compilePointerLists();
 
         void buttonPressed (const KeyEvent& evt);
@@ -144,4 +144,6 @@
         float deriveTime_;
 
+        //! Name of the file used in this KeyBinder (constant!)
+        const std::string filename_;
         //! Config file used. ConfigFileType::NoType in case of KeyDetector. Also indicates whether we've already loaded.
         ConfigFileType configFile_;
@@ -171,4 +173,5 @@
     };
 
+
     inline void KeyBinder::buttonPressed (const KeyEvent& evt)
     { assert(!keys_[evt.getKeyCode()].name_.empty()); keys_[evt.getKeyCode()].execute(KeybindMode::OnPress); }
Index: code/branches/core5/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyBinderManager.cc	(revision 5863)
+++ code/branches/core5/src/libraries/core/input/KeyBinderManager.cc	(revision 5863)
@@ -0,0 +1,165 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "KeyBinderManager.h"
+
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "InputManager.h"
+#include "KeyDetector.h"
+
+namespace orxonox
+{
+    KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;
+
+    KeyBinderManager::KeyBinderManager()
+        : currentBinder_(NULL)
+        , bDefaultFileLoaded_(true)
+        , bBinding_(false)
+    {
+        this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);
+
+        RegisterObject(KeyBinderManager);
+        this->setConfigValues();
+
+        // keybind console commands
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind,  this), "keybind" ));
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind"));
+
+        // Load default key binder
+        this->setCurrent(defaultFilename_);
+    }
+
+    KeyBinderManager::~KeyBinderManager()
+    {
+        // Delete all remaining KeyBinders
+        for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
+            delete it->second;
+        delete this->callbackFunction_;
+    }
+
+    void KeyBinderManager::setConfigValues()
+    {
+        SetConfigValue(defaultFilename_, "keybindings.ini")
+            .description("Filename for the default keybindings file.")
+            .callback(this, &KeyBinderManager::defaultFilenameChanged);
+    }
+
+    void KeyBinderManager::defaultFilenameChanged()
+    {
+        if (this->bDefaultFileLoaded_)
+            this->setCurrent(this->defaultFilename_);
+    }
+
+    void KeyBinderManager::setCurrent(const std::string& filename)
+    {
+        this->currentBinder_ = this->get(filename);
+        if (filename == this->defaultFilename_)
+            this->bDefaultFileLoaded_ = true;
+        else
+            this->bDefaultFileLoaded_ = false;
+    }
+
+    void KeyBinderManager::load(const std::string& filename)
+    {
+        std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.find(filename);
+        if (it != this->binders_.end())
+            return;
+
+        KeyBinder* binder = new KeyBinder(filename);
+        this->binders_[filename] = binder;
+    }
+
+    void KeyBinderManager::unload(const std::string& filename)
+    {
+        if (filename == this->defaultFilename_)
+            ThrowException(General, "KeyBinderManager: Cannot unload the default file");
+        if (filename == this->currentBinder_->getBindingsFilename())
+        {
+            // unloading current file --> set default file
+            this->setCurrent(this->defaultFilename_);
+        }
+        std::map<std::string, KeyBinder*>::iterator it = this->binders_.find(filename);
+        if (it != this->binders_.end())
+        {
+            delete it->second;
+            this->binders_.erase(it);
+        }
+    }
+
+    KeyBinder* KeyBinderManager::get(const std::string& name)
+    {
+        this->load(name);
+        return this->binders_[name];
+    }
+
+    InputHandler* KeyBinderManager::getCurrentAsHandler()
+    {
+        return this->getCurrent();
+    }
+
+    InputHandler* KeyBinderManager::getDefaultAsHandler()
+    {
+        return this->getDefault();
+    }
+
+    InputHandler* KeyBinderManager::getAsHandler(const std::string& name)
+    {
+        return this->get(name);
+    }
+
+    void KeyBinderManager::keybindInternal(const std::string& command, bool bTemporary)
+    {
+        if (!this->bBinding_)
+        {
+            COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+            KeyDetector::getInstance().setCallback(callbackFunction_);
+            InputManager::getInstance().enterState("detector");
+            this->command_ = command;
+            this->bTemporary_ = bTemporary;
+            this->bBinding_ = true;
+        }
+        // else: We're still in a keybind command. Ignore this call.
+    }
+
+    // Gets called by the KeyDetector (registered with a Functor)
+    void KeyBinderManager::callback(const std::string& keyName)
+    {
+        if (this->bBinding_)
+        {
+            COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
+            this->currentBinder_->setBinding(command_, keyName, bTemporary_);
+            InputManager::getInstance().leaveState("detector");
+            this->bBinding_ = false;
+        }
+        // else: A key was probably pressed within the same tick, ignore it.
+    }
+}
Index: code/branches/core5/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyBinderManager.h	(revision 5863)
+++ code/branches/core5/src/libraries/core/input/KeyBinderManager.h	(revision 5863)
@@ -0,0 +1,120 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _KeyBinderManager_H__
+#define _KeyBinderManager_H__
+
+#include "InputPrereqs.h"
+
+#include <map>
+#include <string>
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Handles the KeyBinders and supplies them throughout the game.
+
+        This interface merely serves to provide a static "keybind" command that always
+        maps to the currently active KeyBinder. You can set that with setCurrent().
+        There is also a default one, retrieved with getDefault(). The idea is that
+        mostly the default KeyBinder is active except for special situtations (mini-game for inst).
+    @remarks
+        You are not forced to use the KeyBinder imposed by getCurrent(). But be aware that "keybind"
+        will not work as expected!
+    */
+    class _CoreExport KeyBinderManager : public Singleton<KeyBinderManager>, public OrxonoxClass
+    {
+        friend class Singleton<KeyBinderManager>;
+    public:
+        KeyBinderManager();
+        ~KeyBinderManager();
+        void setConfigValues();
+
+        //! Returns the currently selected KeyBinder
+        KeyBinder*    getCurrent()
+            { return this->currentBinder_; }
+        //! Like getCurrent(), but returns it as InputHandler* (so you don't have to include KeyBinder.h)
+        InputHandler* getCurrentAsHandler();
+        //! Selects the current KeyBinder and creates it if not yet loaded.
+        void setCurrent(const std::string& filename);
+
+        //! Returns the default KeyBinder
+        KeyBinder*    getDefault()
+            { return binders_[this->defaultFilename_]; }
+        //! Returns the default KeyBinder as InputHandler* (so you don't have to include KeyBinder.h)
+        InputHandler* getDefaultAsHandler();
+        //! Returns the filename of the default key bindings
+        const std::string& getDefaultFilename()
+            { return defaultFilename_; }
+        //! Selects the default KeyBinder as current one
+        void setToDefault()
+            { this->setCurrent(this->defaultFilename_); }
+
+        //! Returns a pointer to a KeyBinder (creates it if not yet loaded)
+        KeyBinder*    get(const std::string& name);
+        //! Like get() but return value is of type InputHandler* (so you don't have to include KeyBinder.h)
+        InputHandler* getAsHandler(const std::string& name);
+
+        //! Loads a KeyBinder by creating it (no different from get() except for the return value)
+        void load  (const std::string& filename);
+        //! Destroys a KeyBinder completely (does nothing if not yet loaded)
+        void unload(const std::string& filename);
+
+        //! Bind 'command' to any key pressed after this call (use with care!)
+        inline void keybind(const std::string& command)
+            { this->keybindInternal(command, false); }
+        //! Bind 'command' to any key pressed after this call (use with care!), but temporarily (no file save)
+        inline void tkeybind(const std::string& command)
+            { this->keybindInternal(command, true); }
+
+    private:
+        KeyBinderManager(const KeyBinderManager&);
+        void keybindInternal(const std::string& command, bool bTemporary);
+        void callback(const std::string& keyName);
+        void defaultFilenameChanged();
+
+        // KeyBinder management
+        KeyBinder* currentBinder_;                   //! Currently selected KeyBinder (never NULL!)
+        std::map<std::string, KeyBinder*> binders_;  //! All loaded KeyBinders
+        bool bDefaultFileLoaded_;                    //! Tells whether the default one is loaded
+        std::string defaultFilename_;                //! Name of the file with the default key bindings
+
+        // keybind command related
+        Functor* callbackFunction_;                  //! Function to be called when key was pressed after "keybind" command
+        bool bBinding_;                              //! Tells whether a key binding process is active
+        bool bTemporary_;                            //! Stores tkeybind/keybind value
+        std::string command_;                        //! Stores the command received by (t)keybind
+
+        static KeyBinderManager* singletonPtr_s;
+    };
+}
+
+#endif /* _KeyBinderManager_H__ */
Index: code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSGraphics.cc	(revision 5862)
+++ code/branches/core5/src/orxonox/gamestates/GSGraphics.cc	(revision 5863)
@@ -41,7 +41,4 @@
 #include "core/Game.h"
 #include "core/GUIManager.h"
-#include "core/input/InputManager.h"
-#include "core/input/KeyBinder.h"
-#include "core/input/InputState.h"
 #include "core/Loader.h"
 #include "core/XMLFile.h"
@@ -56,18 +53,10 @@
     GSGraphics::GSGraphics(const GameStateInfo& info)
         : GameState(info)
-        , masterKeyBinder_(0)
-        , masterInputState_(0)
         , debugOverlay_(0)
     {
-        // load master key bindings
-        masterInputState_ = InputManager::getInstance().createInputState("master", true);
-        masterKeyBinder_ = new KeyBinder();
-        masterInputState_->setKeyHandler(masterKeyBinder_);
     }
 
     GSGraphics::~GSGraphics()
     {
-        InputManager::getInstance().destroyState("master");
-        this->masterKeyBinder_->destroy();
     }
 
@@ -94,12 +83,7 @@
         Loader::open(debugOverlay_);
 
-        masterKeyBinder_->loadBindings("masterKeybindings.ini");
-
         // add console command to toggle GUI
         this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI");
         CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
-
-        // enable master input
-        InputManager::getInstance().enterState("master");
     }
 
Index: code/branches/core5/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSGraphics.h	(revision 5862)
+++ code/branches/core5/src/orxonox/gamestates/GSGraphics.h	(revision 5863)
@@ -60,6 +60,4 @@
 
     private:
-        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
-        InputState*           masterInputState_;    //!< Special input state for master input
         XMLFile*              debugOverlay_;
         ConsoleCommand*       ccToggleGUI_;         //!< Console command to toggle GUI
Index: code/branches/core5/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSLevel.cc	(revision 5862)
+++ code/branches/core5/src/orxonox/gamestates/GSLevel.cc	(revision 5863)
@@ -35,5 +35,5 @@
 #include "core/input/InputManager.h"
 #include "core/input/InputState.h"
-#include "core/input/KeyBinder.h"
+#include "core/input/KeyBinderManager.h"
 #include "core/ConsoleCommand.h"
 #include "core/ConfigValueIncludes.h"
@@ -57,5 +57,4 @@
     GSLevel::GSLevel(const GameStateInfo& info)
         : GameState(info)
-        , keyBinder_(0)
         , gameInputState_(0)
         , guiMouseOnlyInputState_(0)
@@ -63,7 +62,4 @@
     {
         RegisterObject(GSLevel);
-
-        this->ccKeybind_ = 0;
-        this->ccTkeybind_ = 0;
     }
 
@@ -74,5 +70,4 @@
     void GSLevel::setConfigValues()
     {
-        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
     }
 
@@ -84,7 +79,6 @@
         {
             gameInputState_ = InputManager::getInstance().createInputState("game");
-            keyBinder_ = new KeyBinder();
-            keyBinder_->loadBindings("keybindings.ini");
-            gameInputState_->setHandler(keyBinder_);
+            gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
+            KeyBinderManager::getInstance().setToDefault();
 
             guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
@@ -102,12 +96,4 @@
         if (GameMode::showsGraphics())
         {
-            // keybind console command
-            ccKeybind_ = createConsoleCommand(createFunctor(&GSLevel::keybind, this), "keybind");
-            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
-            ccTkeybind_ = createConsoleCommand(createFunctor(&GSLevel::tkeybind, this), "tkeybind");
-            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
-            // set our console command as callback for the key detector
-            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
-
             // level is loaded: we can start capturing the input
             InputManager::getInstance().enterState("game");
@@ -136,18 +122,4 @@
     void GSLevel::deactivate()
     {
-/*
-        // destroy console commands
-        if (this->ccKeybind_)
-        {
-            delete this->ccKeybind_;
-            this->ccKeybind_ = 0;
-        }
-        if (this->ccTkeybind_)
-        {
-            delete this->ccTkeybind_;
-            this->ccTkeybind_ = 0;
-        }
-*/
-
         if (GameMode::showsGraphics())
         {
@@ -181,9 +153,4 @@
             InputManager::getInstance().destroyState("guiKeysOnly");
             InputManager::getInstance().destroyState("guiMouseOnly");
-            if (this->keyBinder_)
-            {
-                this->keyBinder_->destroy();
-                this->keyBinder_ = 0;
-            }
         }
     }
@@ -211,58 +178,3 @@
         delete startFile_s;
     }
-
-    void GSLevel::keybind(const std::string &command)
-    {
-        this->keybindInternal(command, false);
-    }
-
-    void GSLevel::tkeybind(const std::string &command)
-    {
-        this->keybindInternal(command, true);
-    }
-
-    /**
-    @brief
-        Assigns a command string to a key/button/axis. The name is determined via KeyDetector.
-    @param command
-        Command string that can be executed by the CommandExecutor
-        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
-        the key/button/axis that has been activated. This is configured above in activate().
-    */
-    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
-    {
-        if (GameMode::showsGraphics())
-        {
-            static std::string bindingString = "";
-            static bool bTemporarySaved = false;
-            static bool bound = true;
-            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
-            // Howerver there will be no real issue if it happens anyway.
-            if (command.find(keyDetectorCallbackCode_) != 0)
-            {
-                if (bound)
-                {
-                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-                    InputManager::getInstance().enterState("detector");
-                    bindingString = command;
-                    bTemporarySaved = bTemporary;
-                    bound = false;
-                }
-                //else:  We're still in a keybind command. ignore this call.
-            }
-            else
-            {
-                if (!bound)
-                {
-                    // user has pressed the key
-                    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().leaveState("detector");
-                    bound = true;
-                }
-                // else: A key was pressed within the same tick, ignore it.
-            }
-        }
-    }
 }
Index: code/branches/core5/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSLevel.h	(revision 5862)
+++ code/branches/core5/src/orxonox/gamestates/GSLevel.h	(revision 5863)
@@ -57,20 +57,7 @@
         void unloadLevel();
 
-        // console commands
-        void keybind(const std::string& command);
-        void tkeybind(const std::string& command);
-        void keybindInternal(const std::string& command, bool bTemporary);
-
-        KeyBinder*               keyBinder_;               //!< tool that loads and manages the input bindings
         InputState*              gameInputState_;          //!< input state for normal ingame playing
         InputState*              guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
         InputState*              guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
-
-        //##### ConfigValues #####
-        std::string           keyDetectorCallbackCode_;
-
-        // console commands
-        ConsoleCommand*       ccKeybind_;
-        ConsoleCommand*       ccTkeybind_;
     };
 }
Index: code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc	(revision 5862)
+++ code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc	(revision 5863)
@@ -34,4 +34,5 @@
 #include "core/input/InputManager.h"
 #include "core/input/InputState.h"
+#include "core/input/KeyBinderManager.h"
 #include "core/Game.h"
 #include "core/ConsoleCommand.h"
@@ -51,4 +52,5 @@
         inputState_ = InputManager::getInstance().createInputState("mainMenu");
         inputState_->setHandler(GUIManager::getInstancePtr());
+        inputState_->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
         inputState_->setJoyStickHandler(&InputHandler::EMPTY);
         inputState_->setIsExclusiveMouse(false);
@@ -86,4 +88,5 @@
         CommandExecutor::addConsoleCommandShortcut(this->ccStartMainMenu_);
 
+        KeyBinderManager::getInstance().setToDefault();
         InputManager::getInstance().enterState("mainMenu");
 
