Index: code/branches/input/src/core/InputHandler.cc
===================================================================
--- code/branches/input/src/core/InputHandler.cc	(revision 1210)
+++ code/branches/input/src/core/InputHandler.cc	(revision 1213)
@@ -34,4 +34,6 @@
 #include "InputHandler.h"
 #include "Debug.h"
+#include "ConfigValueIncludes.h"
+#include "CoreIncludes.h"
 #include "util/Convert.h"
 #include "core/CommandExecutor.h"
@@ -48,5 +50,191 @@
   KeyBinder::KeyBinder()
   {
+    RegisterObject(KeyBinder);
     clearBindings();
+
+    std::string keyNames[] = {
+    "UNASSIGNED",
+		"ESCAPE",
+		"1",
+		"2",
+		"3",
+		"4",
+		"5",
+		"6",
+		"7",
+		"8",
+		"9",
+		"0",
+		"MINUS",
+		"EQUALS",
+		"BACK",
+		"TAB",
+		"Q",
+		"W",
+		"E",
+		"R",
+		"T",
+		"Y",
+		"U",
+		"I",
+		"O",
+		"P",
+		"LBRACKET",
+		"RBRACKET",
+		"RETURN",
+		"LCONTROL",
+		"A",
+		"S",
+		"D",
+		"F",
+		"G",
+		"H",
+		"J",
+		"K",
+		"L",
+		"SEMICOLON",
+		"APOSTROPHE",
+		"GRAVE",
+		"LSHIFT",
+		"BACKSLASH",
+		"Z",
+		"X",
+		"C",
+		"V",
+		"B",
+		"N",
+		"M",
+		"COMMA",
+		"PERIOD",
+		"SLASH",
+		"RSHIFT",
+		"MULTIPLY",
+		"LMENU",
+		"SPACE",
+		"CAPITAL",
+		"F1",
+		"F2",
+		"F3",
+		"F4",
+		"F5",
+		"F6",
+		"F7",
+		"F8",
+		"F9",
+		"F10",
+		"NUMLOCK",
+		"SCROLL",
+		"NUMPAD7",
+		"NUMPAD8",
+		"NUMPAD9",
+		"SUBTRACT",
+		"NUMPAD4",
+		"NUMPAD5",
+		"NUMPAD6",
+		"ADD",
+		"NUMPAD1",
+		"NUMPAD2",
+		"NUMPAD3",
+		"NUMPAD0",
+		"DECIMAL",
+    "","",
+		"OEM_102",
+		"F11",
+		"F12",
+    "","","","","","","","","","","",
+		"F13",
+		"F14",
+		"F15",
+    "","","","","","","","","","",
+		"KANA",
+    "","",
+		"ABNT_C1",
+    "","","","","",
+		"CONVERT",
+    "",
+		"NOCONVERT",
+    "",
+		"YEN",
+		"ABNT_C2",
+    "","","","","","","","","","","","","","",
+		"NUMPADEQUALS",
+    "","",
+		"PREVTRACK",
+		"AT",
+		"COLON",
+		"UNDERLINE",
+		"KANJI",
+		"STOP",
+		"AX",
+		"UNLABELED",
+		"NEXTTRACK",
+    "","",
+		"NUMPADENTER",
+		"RCONTROL",
+    "","",
+		"MUTE",
+		"CALCULATOR",
+		"PLAYPAUSE",
+    "",
+		"MEDIASTOP",
+    "","","","","","","","","",
+		"VOLUMEDOWN",
+    "",
+		"VOLUMEUP",
+    "",
+		"WEBHOME",
+		"NUMPADCOMMA",
+    "",
+		"DIVIDE",
+    "",
+		"SYSRQ",
+		"RMENU",
+    "","","","","","","","","","","","",
+		"PAUSE",
+    "",
+		"HOME",
+		"UP",
+		"PGUP",
+    "",
+		"LEFT",
+    "",
+		"RIGHT",
+    "",
+		"END",
+		"DOWN",
+		"PGDOWN",
+		"INSERT",
+		"DELETE",
+    "","","","","","","",
+		"LWIN",
+		"RWIN",
+		"APPS",
+		"POWER",
+		"SLEEP",
+    "","","",
+		"WAKE",
+    "",
+		"WEBSEARCH",
+		"WEBFAVORITES",
+		"WEBREFRESH",
+		"WEBSTOP",
+		"WEBFORWARD",
+		"WEBBACK",
+		"MYCOMPUTER",
+		"MAIL",
+		"MEDIASELECT"
+    };
+    for (int i = 0; i < numberOfKeys_s; i++)
+      keyNames_[i] = keyNames[i];
+
+    std::string mouseButtonNames[] = {
+    "MouseLeft", "MouseRight", "MouseMiddle",
+    "MouseButton3", "MouseButton4", "MouseButton5",
+    "MouseButton6", "MouseButton7" };
+    for (int i = 0; i < numberOfMouseButtons_s; i++)
+      mouseButtonNames_[i] = mouseButtonNames[i];
+
+    for (int i = 0; i < numberOfJoyStickButtons_s; i++)
+      joyStickButtonNames_[i] = "JoyStick" + getConvertedValue<int, std::string>(i);
   }
 
@@ -56,4 +244,88 @@
   KeyBinder::~KeyBinder()
   {
+  }
+
+  /**
+    @brief Loader for the key bindings, managed by config values.
+  */
+  void KeyBinder::setConfigValues()
+  {
+    ConfigValueContainer* cont;
+    std::string modes[] = {"P_", "R_", "H_"};
+
+    // keys
+    for (int i = 0; i < numberOfKeys_s; i++)
+    {
+      for (int j = 0; j < 3; j++)
+      {
+        cont = getIdentifier()->getConfigValueContainer(modes[j] + keyNames_[i]);
+        if (!cont)
+        {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + keyNames_[i], "");
+          getIdentifier()->addConfigValueContainer(modes[j] + keyNames_[i], cont);
+        }
+        switch (j)
+        {
+          case 0:
+            cont->getValue(bindingsKeyPress_ + i);
+            break;
+          case 1:
+            cont->getValue(bindingsKeyRelease_ + i);
+            break;
+          case 2:
+            cont->getValue(bindingsKeyHold_ + i);
+        }
+      }
+    }
+
+    // mouse buttons
+    for (int i = 0; i < numberOfMouseButtons_s; i++)
+    {
+      for (int j = 0; j < 3; j++)
+      {
+        cont = getIdentifier()->getConfigValueContainer(modes[j] + mouseButtonNames_[i]);
+        if (!cont)
+        {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + mouseButtonNames_[i], "");
+          getIdentifier()->addConfigValueContainer(modes[j] + mouseButtonNames_[i], cont);
+        }
+        switch (j)
+        {
+          case 0:
+            cont->getValue(bindingsMouseButtonPress_ + i);
+            break;
+          case 1:
+            cont->getValue(bindingsMouseButtonRelease_ + i);
+            break;
+          case 2:
+            cont->getValue(bindingsMouseButtonHold_ + i);
+        }
+      }
+    }
+
+    // joy stick buttons
+    for (int i = 0; i < numberOfJoyStickButtons_s; i++)
+    {
+      for (int j = 0; j < 3; j++)
+      {
+        cont = getIdentifier()->getConfigValueContainer(modes[j] + joyStickButtonNames_[i]);
+        if (!cont)
+        {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), modes[j] + joyStickButtonNames_[i], "");
+          getIdentifier()->addConfigValueContainer(modes[j] + joyStickButtonNames_[i], cont);
+        }
+        switch (j)
+        {
+          case 0:
+            cont->getValue(bindingsJoyStickButtonPress_ + i);
+            break;
+          case 1:
+            cont->getValue(bindingsJoyStickButtonRelease_ + i);
+            break;
+          case 2:
+            cont->getValue(bindingsJoyStickButtonHold_ + i);
+        }
+      }
+    }
   }
 
@@ -91,11 +363,6 @@
     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings..." << std::endl;
 
-    // clear all the bindings at first.
-    clearBindings();
-
-    // TODO: Insert the code to load the bindings from file.
-    bindingsKeyPress_[OIS::KC_NUMPADENTER] = "activateConsole";
-    bindingsKeyPress_[OIS::KC_ESCAPE] = "exit";
-    bindingsKeyHold_ [OIS::KC_U] = "exec disco.txt";
+    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
+    setConfigValues();
 
     COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
@@ -110,4 +377,5 @@
   bool KeyBinder::keyPressed(const OIS::KeyEvent &e)
   {
+    COUT(3) << "Key: " << e.key << std::endl;
     // find the appropriate key binding
     std::string cmdStr = bindingsKeyPress_[int(e.key)];
Index: code/branches/input/src/core/InputHandler.h
===================================================================
--- code/branches/input/src/core/InputHandler.h	(revision 1210)
+++ code/branches/input/src/core/InputHandler.h	(revision 1213)
@@ -39,4 +39,5 @@
 #include <string>
 #include "ois/OIS.h"
+#include "OrxonoxClass.h"
 
 namespace orxonox
@@ -85,5 +86,5 @@
            Manages the key bindings.
   */
-  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler
+  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
   {
   public:
@@ -93,4 +94,8 @@
     bool loadBindings();
     void clearBindings();
+
+    void setConfigValues();
+
+    std::string testtest;
 
   private: // functions
@@ -112,17 +117,18 @@
 
   private: // variables
-    /** denotes the maximum number of different keys there are in OIS.
-        256 should be ok since the highest number in the OIS enum is 237. */
-    static const int numberOfKeys_s = 256;
+
+    //! denotes the number of different keys there are in OIS.
+    static const int numberOfKeys_s = 0xEE;
     //! Array of input events for every pressed key
     std::string bindingsKeyPress_  [numberOfKeys_s];
     //! Array of input events for every released key
     std::string bindingsKeyRelease_[numberOfKeys_s];
-    //!Array of input events for every held key
+    //! Array of input events for every held key
     std::string bindingsKeyHold_   [numberOfKeys_s];
+    //! Names of the keys as strings
+    std::string keyNames_[numberOfKeys_s];
 
-    /** denotes the maximum number of different buttons there are in OIS.
-        16 should be ok since the highest number in the OIS enum is 7. */
-    static const int numberOfMouseButtons_s = 16;
+    //! denotes the number of different mouse buttons there are in OIS.
+    static const int numberOfMouseButtons_s = 8;
     //! Array of input events for every pressed mouse button
     std::string bindingsMouseButtonPress_  [numberOfMouseButtons_s];
@@ -131,7 +137,8 @@
     //! Array of input events for every held mouse button
     std::string bindingsMouseButtonHold_   [numberOfMouseButtons_s];
+    //! Names of the mouse buttons as strings
+    std::string mouseButtonNames_[numberOfMouseButtons_s];
 
-    /** denotes the maximum number of different buttons there are in OIS.
-        32 should be ok. */
+    //! denotes the number of different joy stick buttons there are in OIS.
     static const int numberOfJoyStickButtons_s = 32;
     //! Array of input events for every pressed joy stick button
@@ -141,4 +148,6 @@
     //! Array of input events for every held joy stick button
     std::string bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
+    //! Names of the joy stick buttons as strings
+    std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
 
   };
Index: code/branches/input/src/core/InputManager.cc
===================================================================
--- code/branches/input/src/core/InputManager.cc	(revision 1210)
+++ code/branches/input/src/core/InputManager.cc	(revision 1213)
@@ -822,7 +822,11 @@
     {
       if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
+      }
     }
     _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -846,7 +850,9 @@
       {
         _getSingleton().activeKeyHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
       }
     }
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -942,7 +948,11 @@
     {
       if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
+      }
     }
     _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -966,7 +976,9 @@
       {
         _getSingleton().activeMouseHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
       }
     }
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -1071,7 +1083,11 @@
     {
       if ((*it) == (*handlerIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
+      }
     }
     _getSingleton().activeJoyStickHandlers_[id].push_back((*handlerIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -1101,7 +1117,9 @@
       {
         _getSingleton().activeJoyStickHandlers_[id].erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
       }
     }
+    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
Index: code/branches/input/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/input/src/orxonox/Orxonox.cc	(revision 1210)
+++ code/branches/input/src/orxonox/Orxonox.cc	(revision 1213)
@@ -398,5 +398,8 @@
           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
       abortImmediateForce();
-    InputManager::setInputState(InputManager::IS_NORMAL);
+    InputManager::setInputState(InputManager::IS_CUSTOM);
+    InputManager::enableKeyHandler("keybinder");
+    InputManager::enableMouseHandler("keybinder");
+    InputManager::enableJoyStickHandler("keybinder", 0);
   }
 
Index: code/branches/input/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1210)
+++ code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1213)
@@ -428,11 +428,9 @@
     void SpaceShip::tick(float dt)
     {
-      if (InputManager::getMouse()->getEventCallback() != this)
-        {
-            if (InputManager::getMouse())
-            {
-                InputManager::getMouse()->setEventCallback(this);
-                this->setMouseEventCallback_ = true;
-            }
+        if (!setMouseEventCallback_)
+        {
+          InputManager::addMouseHandler(this, "SpaceShip");
+          InputManager::enableMouseHandler("SpaceShip");
+          setMouseEventCallback_ = true;
         }
 
@@ -458,6 +456,4 @@
 
         OIS::Keyboard* mKeyboard = InputManager::getKeyboard();
-        //FIXME: variable never used
-        //OIS::Mouse* mMouse = InputManager::getSingleton().getMouse();
 
 
Index: code/branches/input/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/branches/input/src/orxonox/objects/SpaceShip.h	(revision 1210)
+++ code/branches/input/src/orxonox/objects/SpaceShip.h	(revision 1213)
@@ -34,5 +34,5 @@
 #include <OgrePrerequisites.h>
 
-#include "ois/OISMouse.h"
+#include "core/InputHandler.h"
 #include "Model.h"
 #include "../tools/BillboardSet.h"
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    class _OrxonoxExport SpaceShip : public Model, public OIS::MouseListener
+    class _OrxonoxExport SpaceShip : public Model, public MouseHandler
     {
         public:
@@ -68,4 +68,5 @@
             bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
             bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
+            bool mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
 
 
