Index: code/trunk/src/core/CMakeLists.txt
===================================================================
--- code/trunk/src/core/CMakeLists.txt	(revision 1217)
+++ code/trunk/src/core/CMakeLists.txt	(revision 1219)
@@ -7,5 +7,4 @@
   InputHandler.cc
   InputManager.cc
-  InputEventListener.cc
   MetaObjectList.cc
   ConfigFileManager.cc
@@ -52,8 +51,8 @@
   cpptcl
   ${Lua_LIBRARIES}
-  ${OIS_LIBRARIES}
   ${OGRE_LIBRARIES}
   tinyxml
   tolualib
+  ois
   util
 )
Index: code/trunk/src/core/CorePrereqs.h
===================================================================
--- code/trunk/src/core/CorePrereqs.h	(revision 1217)
+++ code/trunk/src/core/CorePrereqs.h	(revision 1219)
@@ -114,9 +114,4 @@
   class Identifier;
   class IdentifierDistributor;
-  class InputBuffer;
-  class InputBufferListener;
-  class InputHandlerGame;
-  class InputHandlerGUI;
-  class InputManager;
   template <class T>
   class Iterator;
@@ -147,4 +142,15 @@
   class XMLPortObjectContainer;
   class XMLPortParamContainer;
+
+  // input
+  class InputBuffer;
+  class InputBufferListener;
+  class InputManager;
+  class KeyBinder;
+  class GUIInputHandler;
+  class KeyHandler;
+  class MouseHandler;
+  class JoyStickHandler;
+
 }
 
Index: code/trunk/src/core/Debug.h
===================================================================
--- code/trunk/src/core/Debug.h	(revision 1217)
+++ code/trunk/src/core/Debug.h	(revision 1219)
@@ -264,4 +264,10 @@
 ///  CCOUT: Prints output with std::cout and adds the classname   ///
 /////////////////////////////////////////////////////////////////////
+#define CCOUTORX_NONE    CCOUT0
+#define CCOUTORX_ERROR   CCOUT1
+#define CCOUTORX_WARNING CCOUT2
+#define CCOUTORX_INFO    CCOUT3
+#define CCOUTORX_DEBUG   CCOUT4
+#define CCOUTORX_vDEBUG  CCOUT5
 
 #define CCOUT_EXEC(x) \
Index: code/trunk/src/core/InputBuffer.cc
===================================================================
--- code/trunk/src/core/InputBuffer.cc	(revision 1217)
+++ code/trunk/src/core/InputBuffer.cc	(revision 1219)
@@ -40,5 +40,5 @@
         //this->bActivated_ = false;
         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
-        this->keyboard_ = InputManager::getSingleton().getKeyboard();
+        this->keyboard_ = InputManager::getKeyboard();
         this->buffer_ = "";
 
Index: code/trunk/src/core/InputBuffer.h
===================================================================
--- code/trunk/src/core/InputBuffer.h	(revision 1217)
+++ code/trunk/src/core/InputBuffer.h	(revision 1219)
@@ -35,9 +35,6 @@
 #include <list>
 
-#ifdef WIN32
-#include <OIS/OISKeyboard.h>
-#else
-#include <OISKeyboard.h>
-#endif
+#include "ois/OISKeyboard.h"
+#include "InputHandler.h"
 
 namespace orxonox
@@ -46,5 +43,5 @@
     {};
 
-    class _CoreExport InputBuffer : public OIS::KeyListener
+    class _CoreExport InputBuffer : public KeyHandler
     {
         struct InputBufferListenerTuple
@@ -115,4 +112,5 @@
             bool keyPressed(const OIS::KeyEvent &e);
             bool keyReleased(const OIS::KeyEvent &e);
+            bool keyHeld(const OIS::KeyEvent &e) { return true; }
 
             OIS::Keyboard* keyboard_;
Index: code/trunk/src/core/InputEvent.h
===================================================================
--- code/trunk/src/core/InputEvent.h	(revision 1217)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-/**
- @file
- @brief InputEvent Structure declaration
- */
-
-#ifndef _InputEvent_H__
-#define _InputEvent_H__
-
-#include "CorePrereqs.h"
-
-namespace orxonox
-{
-  /**
-    @brief Interface that any class can use to get key independent input.
-  */
-  struct InputEvent
-  {
-    unsigned char id;      //!< Event ID
-    bool bStarted;         //!< Tells whether the Event started or ended (e.g. firing started)
-    int data1, data2;      //!< Two additional integer datafields, for instance for the mouse moved event
-    void* dataRef;         //!< Additional pointer to any further data
-  };
-}
-
-#endif /* _InputEvent_H__ */
Index: code/trunk/src/core/InputEventListener.cc
===================================================================
--- code/trunk/src/core/InputEventListener.cc	(revision 1217)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-/**
- @file
- @brief Core relevant parts of InputEventListener
- */
-
-#include "InputEventListener.h"
-#include "CoreIncludes.h"
-
-namespace orxonox
-{
-  /**
-    @brief standard constructor
-  */
-  InputEventListener::InputEventListener()
-  {
-    RegisterRootObject(InputEventListener);
-    this->bActive_ = true;
-  }
-
-  InputEventListener::~InputEventListener()
-  {
-  }
-
-}
Index: code/trunk/src/core/InputEventListener.h
===================================================================
--- code/trunk/src/core/InputEventListener.h	(revision 1217)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- *   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:
- *      ...
- *
- */
-
-/**
- @file
- @brief InputEventListener Interface declaration
- */
-
-#ifndef _InputEventListener_H__
-#define _InputEventListener_H__
-
-#include "CorePrereqs.h"
-
-#include "OrxonoxClass.h"
-#include "InputEvent.h"
-
-namespace orxonox
-{
-  /**
-    @brief Interface that any class can use to get key independent input.
-  */
-  class _CoreExport InputEventListener : virtual public OrxonoxClass
-  {
-    friend class InputHandlerGame;
-  public:
-    InputEventListener();
-    virtual ~InputEventListener();
-    /** Method is called every time an Input event occurs && bActive */
-    virtual void eventOccured(InputEvent &evt) = 0;
-
-  private:
-    bool bActive_;
-  };
-}
-
-#endif /* _InputEventListener_H__ */
Index: code/trunk/src/core/InputHandler.cc
===================================================================
--- code/trunk/src/core/InputHandler.cc	(revision 1217)
+++ code/trunk/src/core/InputHandler.cc	(revision 1219)
@@ -34,20 +34,207 @@
 #include "InputHandler.h"
 #include "Debug.h"
+#include "ConfigValueIncludes.h"
+#include "CoreIncludes.h"
 #include "util/Convert.h"
-#include "InputEventListener.h"
-#include "InputEvent.h"
-#include "InputManager.h"
+#include "core/CommandExecutor.h"
 
 namespace orxonox
 {
   // ###############################
-  // ###    InputHandlerGame     ###
+  // ######     KeyBinder     ######
   // ###############################
 
   /**
-    @brief standard constructor
-  */
-  InputHandlerGame::InputHandlerGame()
-  {
+    @brief Constructor that does as little as necessary.
+  */
+  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);
   }
 
@@ -55,22 +242,162 @@
     @brief Destructor
   */
-  InputHandlerGame::~InputHandlerGame()
-  {
-  }
-
-  /**
-    @brief Loads the key bindings from the ini file.
-    Currently, this is just a simple test routine that fills the list with numbers.
-  */
-  bool InputHandlerGame::loadBindings()
-  {
+  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++)
     {
-      // simply write the key number (i) in the string
-      this->bindingsKeyPressed_[i] = getConvertedValue<int, std::string>(i);
-      this->bindingsKeyReleased_[i] = getConvertedValue<int, std::string>(i);
-    }
-    return true;
-  }
+      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)
+        {
+          // note: the first element in the struct is the string, so the following pointer
+          //       arithmetic works.
+          case 0:
+            cont->getValue(&bindingsKeyPress_[i].commandStr);
+            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);
+        }
+      }
+    }
+  }
+
+  /**
+    @brief Overwrites all bindings with ""
+  */
+  void KeyBinder::clearBindings()
+  {
+    for (int i = 0; i < numberOfKeys_s; i++)
+    {
+      bindingsKeyPress_  [i].commandStr = "";
+      bindingsKeyRelease_[i].commandStr = "";
+      bindingsKeyHold_   [i].commandStr = "";
+    }
+    for (int i = 0; i < numberOfMouseButtons_s; i++)
+    {
+      bindingsMouseButtonPress_  [i] = "";
+      bindingsMouseButtonRelease_[i] = "";
+      bindingsMouseButtonHold_   [i] = "";
+    }
+    for (int i = 0; i < numberOfJoyStickButtons_s; i++)
+    {
+      bindingsJoyStickButtonPress_  [i] = "";
+      bindingsJoyStickButtonRelease_[i] = "";
+      bindingsJoyStickButtonHold_   [i] = "";
+    }
+  }
+
+  /**
+    @brief Loads the key and button bindings.
+    @return True if loading succeeded.
+  */
+  bool KeyBinder::loadBindings()
+  {
+    COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings..." << std::endl;
+
+    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
+    setConfigValues();
+
+    // evaluate the key bindings
+    // TODO: what if binding is invalid?
+    //for (int i = 0; i < numberOfKeys_s; i++)
+    //{
+    //  if (bindingsKeyPress_[i].commandStr != "")
+    //  {
+    //    bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
+    //    bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
+    //  }
+    //}
+
+    COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
+    return true;
+  }
+
+  bool KeyBinder::executeBinding(KeyBinding& binding)
+  {
+    if (binding.commandStr != "")
+    {
+      //if (binding.commandStr != binding.evaluation.getCommandString())
+      //{
+      //  // key binding has changed, reevaluate the command string.
+      //  binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
+      //  binding.commandStr = binding.evaluation.getCommandString();
+      //}
+      COUT(3) << "Executing command: " << binding.commandStr << std::endl;
+      CommandExecutor::execute(binding.commandStr);
+    }
+
+    return true;
+  }
+
 
   /**
@@ -78,21 +405,10 @@
     @param e Event information
   */
-  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
-  {
-    if (e.key == OIS::KC_ESCAPE)
-    {
-      InputEvent e = {1, true, 0, 0, 0};
-      InputHandlerGame::callListeners(e);
-    }
-    else if (e.key == OIS::KC_UNASSIGNED || e.key == OIS::KC_NUMPADENTER)
-    {
-      InputManager::getSingleton().setInputMode(IM_KEYBOARD);
-    }
-    else
-    {
-      // find the appropriate key binding
-      std::string cmdStr = bindingsKeyPressed_[int(e.key)];
-      //COUT(3) << cmdStr << " pressed" << std::endl;
-    }
+  bool KeyBinder::keyPressed(const OIS::KeyEvent &e)
+  {
+    COUT(3) << "Key: " << e.key << std::endl;
+    // find the appropriate key binding
+    executeBinding(bindingsKeyPress_[int(e.key)]);
+     
     return true;
   }
@@ -102,9 +418,21 @@
     @param e Event information
   */
-  bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e)
-  {
-    // find the appropriate key binding
-    std::string cmdStr = bindingsKeyReleased_[int(e.key)];
-    //COUT(3) << cmdStr << " released" << std::endl;
+  bool KeyBinder::keyReleased(const OIS::KeyEvent &e)
+  {
+    // find the appropriate key binding
+    executeBinding(bindingsKeyRelease_[int(e.key)]);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyHeld Event.
+    @param e Event information
+  */
+  bool KeyBinder::keyHeld(const OIS::KeyEvent &e)
+  {
+    // find the appropriate key binding
+    executeBinding(bindingsKeyHold_[int(e.key)]);
+
     return true;
   }
@@ -114,5 +442,5 @@
     @param e Event information
   */
-  bool InputHandlerGame::mouseMoved(const OIS::MouseEvent &e)
+  bool KeyBinder::mouseMoved(const OIS::MouseEvent &e)
   {
     return true;
@@ -124,6 +452,14 @@
     @param id The ID of the mouse button
   */
-  bool InputHandlerGame::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
+  bool KeyBinder::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsMouseButtonPress_[int(id)];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
     return true;
   }
@@ -134,95 +470,166 @@
     @param id The ID of the mouse button
   */
-  bool InputHandlerGame::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    return true;
-  }
-
-  /**
-    @brief Calls all the objects from classes that derive from InputEventListener.
-    @param evt The input event that occured.
-  */
-  inline void InputHandlerGame::callListeners(orxonox::InputEvent &evt)
-  {
-    for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; )
-    {
-      if (it->bActive_)
-        (it++)->eventOccured(evt);
-      else
-        it++;
-    }
-  }
-
-
-  // ###############################
-  // ###     InputHandlerGUI     ###
-  // ###############################
-
-  /**
-    @brief standard constructor
-  */
-  InputHandlerGUI::InputHandlerGUI()
-  {
-  }
-
-  /**
-    @brief Destructor
-  */
-  InputHandlerGUI::~InputHandlerGUI()
-  {
-  }
-
-  /**
-    @brief Event handler for the keyPressed Event.
-    @param e Event information
-  */
-  bool InputHandlerGUI::keyPressed(const OIS::KeyEvent &e)
-  {
-		//CEGUI::System::getSingleton().injectKeyDown( arg.key );
-		//CEGUI::System::getSingleton().injectChar( arg.text );
-    return true;
-  }
-
-  /**
-    @brief Event handler for the keyReleased Event.
-    @param e Event information
-  */
-  bool InputHandlerGUI::keyReleased(const OIS::KeyEvent &e)
-  {
-		//CEGUI::System::getSingleton().injectKeyUp( arg.key );
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mouseMoved Event.
-    @param e Event information
-  */
-  bool InputHandlerGUI::mouseMoved(const OIS::MouseEvent &e)
-  {
-		//CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mousePressed Event.
+  bool KeyBinder::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsMouseButtonRelease_[int(id)];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseHeld Event.
     @param e Event information
     @param id The ID of the mouse button
   */
-  bool InputHandlerGUI::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-		//CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mouseReleased Event.
-    @param e Event information
-    @param id The ID of the mouse button
-  */
-  bool InputHandlerGUI::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-		//CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
-    return true;
-  }
+  bool KeyBinder::mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsMouseButtonHold_[int(id)];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
+    return true;
+  }
+
+  bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsJoyStickButtonPress_[button];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
+    return true;
+  }
+
+  bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsJoyStickButtonRelease_[button];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
+    return true;
+  }
+
+  bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsJoyStickButtonHold_[button];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
+    return true;
+  }
+
+  bool KeyBinder::axisMoved(int joyStickID, const OIS::JoyStickEvent &arg, int axis)
+  {
+    return true;
+  }
+
+  bool KeyBinder::sliderMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
+  {
+    return true;
+  }
+
+  bool KeyBinder::povMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
+  {
+    return true;
+  }
+
+  bool KeyBinder::vector3Moved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
+  {
+    return true;
+  }
+
+
+
+  // ###############################
+  // ###     GUIInputHandler     ###
+  // ###############################
+
+  ///**
+  //  @brief standard constructor
+  //*/
+  //GUIInputHandler::GUIInputHandler()
+  //{
+  //}
+
+  ///**
+  //  @brief Destructor
+  //*/
+  //GUIInputHandler::~GUIInputHandler()
+  //{
+  //}
+
+  ///**
+  //  @brief Event handler for the keyPressed Event.
+  //  @param e Event information
+  //*/
+  //bool GUIInputHandler::keyPressed(const OIS::KeyEvent &e)
+  //{
+		////CEGUI::System::getSingleton().injectKeyDown( arg.key );
+		////CEGUI::System::getSingleton().injectChar( arg.text );
+  //  return true;
+  //}
+
+  ///**
+  //  @brief Event handler for the keyReleased Event.
+  //  @param e Event information
+  //*/
+  //bool GUIInputHandler::keyReleased(const OIS::KeyEvent &e)
+  //{
+		////CEGUI::System::getSingleton().injectKeyUp( arg.key );
+  //  return true;
+  //}
+
+  ///**
+  //  @brief Event handler for the mouseMoved Event.
+  //  @param e Event information
+  //*/
+  //bool GUIInputHandler::mouseMoved(const OIS::MouseEvent &e)
+  //{
+		////CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
+  //  return true;
+  //}
+
+  ///**
+  //  @brief Event handler for the mousePressed Event.
+  //  @param e Event information
+  //  @param id The ID of the mouse button
+  //*/
+  //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  //{
+		////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
+  //  return true;
+  //}
+
+  ///**
+  //  @brief Event handler for the mouseReleased Event.
+  //  @param e Event information
+  //  @param id The ID of the mouse button
+  //*/
+  //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  //{
+		////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
+  //  return true;
+  //}
 
 }
Index: code/trunk/src/core/InputHandler.h
===================================================================
--- code/trunk/src/core/InputHandler.h	(revision 1217)
+++ code/trunk/src/core/InputHandler.h	(revision 1219)
@@ -38,49 +38,136 @@
 
 #include <string>
-#include <OIS/OIS.h>
-
-#include "InputEvent.h"
+#include "ois/OIS.h"
+#include "OrxonoxClass.h"
+#include "CommandExecutor.h"
 
 namespace orxonox
 {
-  /**
-    @brief Captures mouse and keyboard input while in the actual game mode.
-    Manages the key bindings.
-  */
-  class _CoreExport InputHandlerGame
-        : public OIS::KeyListener, public OIS::MouseListener
-  {
-  public:
-    InputHandlerGame ();
-    ~InputHandlerGame();
+  namespace KeybindSetting
+  {
+    enum KeybindSetting
+    {
+      None,
+      OnPress,
+      OnRelease,
+      Continuous,
+    };
+  }
+
+  /**
+    @brief Interface class used for key input listeners.
+  */
+  class _CoreExport KeyHandler : public OIS::KeyListener
+  {
+  public:
+    virtual ~KeyHandler() { }
+    virtual bool keyHeld(const OIS::KeyEvent &arg) = 0;
+  };
+
+  /**
+    @brief Interface class used for mouse input listeners.
+  */
+  class _CoreExport MouseHandler : public OIS::MouseListener
+  {
+  public:
+    virtual ~MouseHandler() { }
+    virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0;
+  };
+
+  /**
+    @brief Interface class used for joy stick input listeners.
+  */
+  class _CoreExport JoyStickHandler
+  {
+  public:
+    virtual ~JoyStickHandler() { }
+		virtual bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
+		virtual bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
+    virtual bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
+		virtual bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis)   = 0;
+		virtual bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
+		virtual bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
+		virtual bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
+  };
+
+  struct _CoreExport KeyBinding
+  {
+    std::string commandStr;
+    CommandEvaluation evaluation;
+  };
+ 
+
+  /**
+    @brief Captures mouse, keyboard and joy stick input while in the actual game mode.
+           Manages the key bindings.
+  */
+  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
+  {
+  public:
+    KeyBinder ();
+    ~KeyBinder();
 
     bool loadBindings();
-
-  private:
-    // input events
-		bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-    bool mouseMoved   (const OIS::MouseEvent &arg);
+    void clearBindings();
+
+    void setConfigValues();
+
+    std::string testtest;
+
+  private: // functions
+
+    bool executeBinding(KeyBinding &binding);
+
 		bool keyPressed   (const OIS::KeyEvent   &arg);
 		bool keyReleased  (const OIS::KeyEvent   &arg);
-
-    // temporary hack
-    void callListeners(InputEvent &evt);
-
-    /** denotes the maximum number of different keys there are in OIS.
-        256 should be ok since the highest number in the enum is 237. */
-    static const int numberOfKeys_s = 256;
+		bool keyHeld      (const OIS::KeyEvent   &arg);
+
+    bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+    bool mouseMoved   (const OIS::MouseEvent &arg);
+
+		bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button);
+		bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button);
+		bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button);
+		bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis);
+		bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int id);
+		bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int id);
+		bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int id);
+
+  private: // variables
+
+    //! 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 bindingsKeyPressed_[numberOfKeys_s];
+    KeyBinding bindingsKeyPress_  [numberOfKeys_s];
     //! Array of input events for every released key
-    std::string bindingsKeyReleased_[numberOfKeys_s];
-
-    /** denotes the maximum number of different buttons there are in OIS.
-        16 should be ok since the highest number in the enum is 7. */
-    static const int numberOfButtons_s = 16;
-    //! Array of input events for every pressed key
-    std::string bindingsButtonPressed_[numberOfButtons_s];
-    //! Array of input events for every released key
-    std::string bindingsButtonReleased_[numberOfButtons_s];
+    KeyBinding bindingsKeyRelease_[numberOfKeys_s];
+    //! Array of input events for every held key
+    KeyBinding bindingsKeyHold_   [numberOfKeys_s];
+    //! Names of the keys as strings
+    std::string keyNames_[numberOfKeys_s];
+
+    //! 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];
+    //! Array of input events for every released mouse button
+    std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s];
+    //! 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 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
+    std::string bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
+    //! Array of input events for every released joy stick button
+    std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
+    //! 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];
 
   };
@@ -91,19 +178,28 @@
     GUI.
   */
-  class _CoreExport InputHandlerGUI
-        : public OIS::KeyListener, public OIS::MouseListener
-  {
-  public:
-    InputHandlerGUI ();
-    ~InputHandlerGUI();
-
-  private:
-    // input events
-		bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
-    bool mouseMoved   (const OIS::MouseEvent &arg);
-		bool keyPressed   (const OIS::KeyEvent   &arg);
-		bool keyReleased  (const OIS::KeyEvent   &arg);
-  };
+  //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
+  //{
+  //public:
+  //  GUIInputHandler ();
+  //  ~GUIInputHandler();
+
+  //private:
+  //  // input events
+		//bool keyPressed   (const OIS::KeyEvent   &arg);
+		//bool keyReleased  (const OIS::KeyEvent   &arg);
+		//bool keyHeld      (const OIS::KeyEvent   &arg);
+
+  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		//bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		//bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+  //  bool mouseMoved   (const OIS::MouseEvent &arg);
+
+		//bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+		//bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+		//bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
+		//bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+		//bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+		//bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+  //};
 
 }
Index: code/trunk/src/core/InputManager.cc
===================================================================
--- code/trunk/src/core/InputManager.cc	(revision 1217)
+++ code/trunk/src/core/InputManager.cc	(revision 1219)
@@ -28,7 +28,7 @@
 
 /**
- @file
- @brief Implementation of a little Input handler that distributes everything
-        coming from OIS.
+  @file
+  @brief Implementation of the InputManager that captures all the input from OIS
+         and redirects it to handlers if necessary.
  */
 
@@ -36,30 +36,28 @@
 #include "CoreIncludes.h"
 #include "Debug.h"
-#include "InputEventListener.h"
+#include "InputBuffer.h"
 #include "InputHandler.h"
-#include "InputBuffer.h"
-#include "ConsoleCommand.h"
 
 namespace orxonox
 {
-  ConsoleCommand(InputManager, setInputMode, AccessLevel::Admin, true).setDefaultValue(0, IM_INGAME);
-
-  /**
-    @brief Constructor only resets the pointer values to 0.
+  // ###############################
+  // ###    Internal Methods     ###
+  // ###############################
+  // ###############################
+
+  /**
+    @brief Constructor only sets member fields to initial zero values
+           and registers the class in the class hierarchy.
   */
   InputManager::InputManager() :
       inputSystem_(0), keyboard_(0), mouse_(0),
-      currentMode_(IM_UNINIT), setMode_(IM_UNINIT),
-      handlerGUI_(0), handlerBuffer_(0), handlerGame_(0)
+      state_(IS_UNINIT), stateRequest_(IS_UNINIT)
   {
     RegisterObject(InputManager);
-  }
-
-  /**
-    @brief Destructor only called at the end of the program
-  */
-  InputManager::~InputManager()
-  {
-    this->destroy();
+
+    this->joySticks_.reserve(5);
+    //this->activeJoyStickHandlers_.reserve(10);
+    this->activeKeyHandlers_.reserve(10);
+    this->activeMouseHandlers_.reserve(10);
   }
 
@@ -68,5 +66,5 @@
     @return A reference to the only instance of the InputManager
   */
-  InputManager& InputManager::getSingleton()
+  InputManager& InputManager::_getSingleton()
   {
     static InputManager theOnlyInstance;
@@ -75,15 +73,25 @@
 
   /**
-    @brief Creates the OIS::InputMananger, the keyboard and the mouse and
-           assigns the key bindings.
+    @brief Destructor only called at the end of the program, after main.
+  */
+  InputManager::~InputManager()
+  {
+    _destroy();
+  }
+
+  /**
+    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
+           the joysticks and assigns the key bindings.
     @param windowHnd The window handle of the render window
     @param windowWidth The width of the render window
     @param windowHeight The height of the render window
   */
-  bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight)
-  {
-    if (!this->inputSystem_)
-    {
-      // Setup basic variables
+  bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
+        const bool createKeyboard, const bool createMouse, const bool createJoySticks)
+  {
+    if (state_ == IS_UNINIT)
+    {
+      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
+
       OIS::ParamList paramList;
       std::ostringstream windowHndStr;
@@ -93,122 +101,612 @@
       paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
 
-#if defined OIS_LINUX_PLATFORM
-      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
-#endif
+//#if defined OIS_LINUX_PLATFORM
+//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+//#endif
 
       try
       {
-        // Create inputsystem
         inputSystem_ = OIS::InputManager::createInputSystem(paramList);
-        COUT(ORX_DEBUG) << "*** InputManager: Created OIS input system" << std::endl;
-
-        // create a keyboard. If none are available the exception is caught.
-        keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
-        COUT(ORX_DEBUG) << "*** InputManager: Created OIS mouse" << std::endl;
-
-        // create a mouse. If none are available the exception is caught.
+        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+      }
+      catch (OIS::Exception ex)
+      {
+        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
+            << "OIS message: \"" << ex.eText << "\"" << std::endl;
+        inputSystem_ = 0;
+        return false;
+      }
+
+      if (createKeyboard)
+        _initialiseKeyboard();
+
+      if (createMouse)
+        _initialiseMouse();
+
+      if (createJoySticks)
+        _initialiseJoySticks();
+
+      // Set mouse/joystick region
+      setWindowExtents(windowWidth, windowHeight);
+
+      state_ = IS_NONE;
+      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+    }
+
+    // InputManager holds the input buffer --> create one and add it.
+    addKeyHandler(new InputBuffer(), "buffer");
+
+    KeyBinder* binder = new KeyBinder();
+    binder->loadBindings();
+    addKeyHandler(binder, "keybinder");
+    addMouseHandler(binder, "keybinder");
+
+    // Read all the key bindings and assign them
+    //if (!_loadBindings())
+    //  return false;
+
+    CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
+    return true;
+  }
+
+  /**
+    @brief Creates a keyboard and sets the event handler.
+    @return False if keyboard stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseKeyboard()
+  {
+    if (keyboard_ != 0)
+    {
+      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+      {
+        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
+        // register our listener in OIS.
+        keyboard_->setEventCallback(this);
+        // note: OIS will not detect keys that have already been down when the keyboard was created.
+        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
+        return false;
+      }
+    }
+    catch (OIS::Exception ex)
+    {
+      // TODO: Test this output regarding formatting
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      keyboard_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates a mouse and sets the event handler.
+    @return False if mouse stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseMouse()
+  {
+    if (mouse_ != 0)
+    {
+      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+      {
         mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
-        COUT(ORX_DEBUG) << "*** InputManager: Created OIS keyboard" << std::endl;
-
-        // Set mouse region
-        this->setWindowExtents(windowWidth, windowHeight);
-      }
-      catch (OIS::Exception ex)
-      {
-        // something went wrong with the initialisation
-        COUT(ORX_ERROR) << "Error: Failed creating an input system/keyboard/mouse. Message: \"" << ex.eText << "\"" << std::endl;
-        this->inputSystem_ = 0;
+        // register our listener in OIS.
+        mouse_->setEventCallback(this);
+        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
         return false;
       }
     }
-
-    // create the handlers
-    this->handlerGUI_ = new InputHandlerGUI();
-    this->handlerGame_ = new InputHandlerGame();
-    //this->handlerBuffer_ = new InputBuffer();
-    this->handlerGame_->loadBindings();
-
-    /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl;
-    // load the key bindings
-    InputEvent empty = {0, false, 0, 0, 0};
-    for (int i = 0; i < this->numberOfKeys_; i++)
-      this->bindingsKeyPressed_[i] = empty;
-
-    //assign 'abort' to the escape key
-    this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1;
-    COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/
-
-    return true;
-  }
-
-  /**
-    @brief Destroys all the created input devices and handlers.
-  */
-  void InputManager::destroy()
-  {
-    COUT(ORX_DEBUG) << "*** InputManager: Destroying ..." << std::endl;
-    if (this->mouse_)
-      this->inputSystem_->destroyInputObject(mouse_);
-    if (this->keyboard_)
-      this->inputSystem_->destroyInputObject(keyboard_);
-    if (this->inputSystem_)
-      OIS::InputManager::destroyInputSystem(this->inputSystem_);
-
-    this->mouse_         = 0;
-    this->keyboard_      = 0;
-    this->inputSystem_   = 0;
-
-    if (this->handlerBuffer_)
-      delete this->handlerBuffer_;
-    if (this->handlerGame_)
-      delete this->handlerGame_;
-    if (this->handlerGUI_)
-      delete this->handlerGUI_;
-
-    this->handlerBuffer_ = 0;
-    this->handlerGame_   = 0;
-    this->handlerGUI_    = 0;
-
-    COUT(ORX_DEBUG) << "*** InputManager: Destroying done." << std::endl;
-  }
-
-  /**
-    @brief Updates the InputManager
+    catch (OIS::Exception ex)
+    {
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      mouse_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates all joy sticks and sets the event handler.
+    @return False joy stick stay uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseJoySticks()
+  {
+    if (joySticks_.size() > 0)
+    {
+      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
+      return true;
+    }
+    bool success = false;
+    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
+    {
+      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+      {
+        try
+        {
+          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
+          joySticks_.push_back(stig);
+          // register our listener in OIS.
+          stig->setEventCallback(this);
+          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
+          success = true;
+        }
+        catch (OIS::Exception ex)
+        {
+          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
+              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+        }
+      }
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
+      return false;
+    }
+    return success;
+  }
+
+  /**
+    @brief Destroys all the created input devices and sets the InputManager to construction state.
+  */
+  void InputManager::_destroy()
+  {
+    CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
+
+    if (state_ != IS_UNINIT)
+    {
+      if (keyHandlers_.find("buffer") != keyHandlers_.end())
+        delete keyHandlers_["buffer"];
+
+      if (keyHandlers_.find("keybinder") != keyHandlers_.end())
+        delete keyHandlers_["keybinder"];
+
+      keyHandlers_.clear();
+      mouseHandlers_.clear();
+      joyStickHandlers_.clear();
+
+      _destroyKeyboard();
+      _destroyMouse();
+      _destroyJoySticks();
+
+      // inputSystem_ can never be 0, or else the code is mistaken
+      OIS::InputManager::destroyInputSystem(inputSystem_);
+      inputSystem_ = 0;
+
+      state_ = IS_UNINIT;
+    }
+    else
+      CCOUT(ORX_WARNING) << "Warning: Cannot be destroyed, since not initialised." << std::endl;
+
+    CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
+  }
+
+  /**
+    @brief Destroys the keyboard and sets it to 0.
+  */
+  void InputManager::_destroyKeyboard()
+  {
+    if (keyboard_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(keyboard_);
+    keyboard_ = 0;
+    activeKeyHandlers_.clear();
+    keysDown_.clear();
+    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys the mouse and sets it to 0.
+  */
+  void InputManager::_destroyMouse()
+  {
+    if (mouse_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(mouse_);
+    mouse_ = 0;
+    activeMouseHandlers_.clear();
+    mouseButtonsDown_.clear();
+    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys all the joy sticks and resizes the lists to 0.
+  */
+  void InputManager::_destroyJoySticks()
+  {
+    if (joySticks_.size() > 0)
+    {
+      // note: inputSystem_ can never be 0, or else the code is mistaken
+      for (unsigned int i = 0; i < joySticks_.size(); i++)
+        if (joySticks_[i] != 0)
+          inputSystem_->destroyInputObject(joySticks_[i]);
+
+      joySticks_.clear();
+      activeJoyStickHandlers_.clear();
+      joyStickButtonsDown_.clear();
+    }
+    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
+  }
+
+
+  // #################################
+  // ### Private Interface Methods ###
+  // #################################
+  // #################################
+
+  /**
+    @brief Updates the InputManager. Tick is called by Orxonox.
     @param dt Delta time
   */
   void InputManager::tick(float dt)
   {
+    if (state_ == IS_UNINIT)
+      return;
+
     // reset the game if it has changed
-    if (this->currentMode_ != this->setMode_)
-    {
-      switch (this->setMode_)
-      {
-      case IM_GUI:
-        this->mouse_->setEventCallback(this->handlerGUI_);
-        this->keyboard_->setEventCallback(this->handlerGUI_);
-        break;
-      case IM_INGAME:
-        this->mouse_->setEventCallback(this->handlerGame_);
-        this->keyboard_->setEventCallback(this->handlerGame_);
-        break;
-      case IM_KEYBOARD:
-        this->mouse_->setEventCallback(this->handlerGame_);
-        this->keyboard_->setEventCallback(this->handlerBuffer_);
-        break;
-      case IM_UNINIT:
-        this->mouse_->setEventCallback(0);
-        this->keyboard_->setEventCallback(0);
-        break;
-      }
-      this->currentMode_ = this->setMode_;
-    }
-
-    // capture all the input. That calls the event handlers.
+    if (state_ != stateRequest_)
+    {
+      if (stateRequest_ != IS_CUSTOM)
+      {
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        activeJoyStickHandlers_.clear();
+
+        switch (stateRequest_)
+        {
+        case IS_NORMAL:
+          // normal play mode
+          // note: we assume that the handlers exist since otherwise, something's wrong anyway.
+          activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
+          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
+          activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
+          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
+                it != joySticks_.end(); it++)
+            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
+          break;
+
+        case IS_GUI:
+          // FIXME: do stuff
+          break;
+
+        case IS_CONSOLE:
+          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
+          for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
+                it != joySticks_.end(); it++)
+            activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
+
+          activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
+          break;
+
+        default:
+          break;
+        }
+        state_ = stateRequest_;
+      }
+    }
+
+    // Capture all the input. This calls the event handlers in InputManager.
     if (mouse_)
       mouse_->capture();
-
     if (keyboard_)
       keyboard_->capture();
-  }
+
+
+    // call all the handlers for the held key events
+    for (std::list<OIS::KeyCode>::const_iterator itKey = keysDown_.begin();
+          itKey != keysDown_.end(); itKey++)
+    {
+      OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
+      for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+        activeKeyHandlers_[i]->keyHeld(keyArg);
+    }
+
+    // call all the handlers for the held mouse button events
+    for (std::list<OIS::MouseButtonID>::const_iterator itMouseButton = mouseButtonsDown_.begin();
+          itMouseButton != mouseButtonsDown_.end(); itMouseButton++)
+    {
+      OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseHeld(mouseButtonArg, *itMouseButton);
+    }
+
+    // call all the handlers for the held joy stick button events
+    for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
+          itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
+    {
+      OIS::JoyStick* joyStick = (*itJoyStick).first;
+      for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
+            itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
+      {
+        OIS::JoyStickEvent joyStickButtonArg(joyStick, joyStick->getJoyStickState());
+        for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+          activeJoyStickHandlers_[joyStick][i]->buttonHeld(i, joyStickButtonArg, *itJoyStickButton);
+      }
+    }
+  }
+
+
+  // ###### Key Events ######
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputManager::keyPressed(const OIS::KeyEvent &e)
+  {
+    // check whether the key already is in the list (can happen when focus was lost)
+    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
+    {
+      if (*it == e.key)
+      {
+        keysDown_.erase(it);
+        break;
+      }
+    }
+    keysDown_.push_back(e.key);
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyPressed(e);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputManager::keyReleased(const OIS::KeyEvent &e)
+  {
+    // remove the key from the keysDown_ list
+    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
+    {
+      if (*it == e.key)
+      {
+        keysDown_.erase(it);
+        break;
+      }
+    }
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyReleased(e);
+
+    return true;
+  }
+
+
+  // ###### Mouse Events ######
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
+  {
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseMoved(e);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // check whether the button already is in the list (can happen when focus was lost)
+    for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
+    {
+      if (*it == id)
+      {
+        mouseButtonsDown_.erase(it);
+        break;
+      }
+    }
+    mouseButtonsDown_.push_back(id);
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mousePressed(e, id);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseReleased Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // remove the button from the keysDown_ list
+    for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
+    {
+      if (*it == id)
+      {
+        mouseButtonsDown_.erase(it);
+        break;
+      }
+    }
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseReleased(e, id);
+
+    return true;
+  }
+
+
+  // ###### Joy Stick Events ######
+
+  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+
+    // check whether the button already is in the list (can happen when focus was lost)
+    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
+    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
+    {
+      if (*it == button)
+      {
+        buttonsDownList.erase(it);
+        break;
+      }
+    }
+    joyStickButtonsDown_[joyStick].push_back(button);
+
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
+
+    return true;
+  }
+
+  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+
+    // remove the button from the joyStickButtonsDown_ list
+    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
+    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
+    {
+      if (*it == button)
+      {
+        buttonsDownList.erase(it);
+        break;
+      }
+    }
+
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
+
+    return true;
+  }
+
+  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->axisMoved(i, arg, axis);
+
+    return true;
+  }
+
+  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->sliderMoved(i, arg, id);
+
+    return true;
+  }
+
+  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->povMoved(i, arg, id);
+
+    return true;
+  }
+
+  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
+  {
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->vector3Moved(i, arg, id);
+
+    return true;
+  }
+
+
+  // ################################
+  // ### Static Interface Methods ###
+  // ################################
+  // ################################
+
+  bool InputManager::initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
+    const bool createKeyboard, const bool createMouse, const bool createJoySticks)
+  {
+    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
+          createKeyboard, createMouse, createJoySticks);
+  }
+
+  bool InputManager::initialiseKeyboard()
+  {
+    return _getSingleton()._initialiseKeyboard();
+  }
+
+  bool InputManager::initialiseMouse()
+  {
+    return _getSingleton()._initialiseMouse();
+  }
+
+  bool InputManager::initialiseJoySticks()
+  {
+    return _getSingleton()._initialiseJoySticks();
+  }
+
+  int InputManager::numberOfKeyboards()
+  {
+    if (_getSingleton().keyboard_ != 0)
+      return 1;
+    else
+      return 0;
+  }
+
+  int InputManager::numberOfMice()
+  {
+    if (_getSingleton().mouse_ != 0)
+      return 1;
+    else
+      return 0;
+  }
+
+  int InputManager::numberOfJoySticks()
+  {
+    return _getSingleton().joySticks_.size();
+  }
+
+
+  void InputManager::destroy()
+  {
+    _getSingleton()._destroy();
+  }
+
+  void InputManager::destroyKeyboard()
+  {
+    return _getSingleton()._destroyKeyboard();
+  }
+
+  void InputManager::destroyMouse()
+  {
+    return _getSingleton()._destroyMouse();
+  }
+
+  void InputManager::destroyJoySticks()
+  {
+    return _getSingleton()._destroyJoySticks();
+  }
+
 
   /**
@@ -218,10 +716,13 @@
     @param height the new height of the render window
   */
-  void InputManager::setWindowExtents(int width, int height)
-  {
-    // Set mouse region (if window resizes, we should alter this to reflect as well)
-    const OIS::MouseState &mouseState = mouse_->getMouseState();
-    mouseState.width  = width;
-    mouseState.height = height;
+  void InputManager::setWindowExtents(const int width, const int height)
+  {
+    if (_getSingleton().mouse_)
+    {
+      // Set mouse region (if window resizes, we should alter this to reflect as well)
+      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
+      mouseState.width  = width;
+      mouseState.height = height;
+    }
   }
 
@@ -231,8 +732,7 @@
     @remark Only has an affect if the mode actually changes
   */
-  void InputManager::setInputMode(int mode)
-  {
-    if (mode > 0 && mode < 4)
-      getSingleton().setMode_ = (InputMode)mode;
+  void InputManager::setInputState(const InputState state)
+  {
+    _getSingleton().stateRequest_ = state;
   }
 
@@ -241,14 +741,408 @@
     @return The current input mode.
   */
-  InputMode InputManager::getInputMode()
-  {
-    return this->currentMode_;
-  }
-
-  void InputManager::feedInputBuffer(InputBuffer* buffer)
-  {
-    this->handlerBuffer_ = buffer;
-  }
-
+  InputManager::InputState InputManager::getInputState()
+  {
+    return _getSingleton().state_;
+  }
+
+
+  // ###### KeyHandler ######
+
+  /**
+    @brief Adds a new key handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
+  {
+    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Key handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeKeyHandler(const std::string &name)
+  {
+    disableKeyHandler(name);
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  KeyHandler* InputManager::getKeyHandler(const std::string& name)
+  {
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific key handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableKeyHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    return true;
+  }
+
+  /**
+    @brief Disables a specific key handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableKeyHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeKeyHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    return true;
+  }
+
+  /**
+    @brief Checks whether a key handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isKeyHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### MouseHandler ######
+  /**
+    @brief Adds a new mouse handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
+  {
+    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Mouse handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeMouseHandler(const std::string &name)
+  {
+    disableMouseHandler(name);
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  MouseHandler* InputManager::getMouseHandler(const std::string& name)
+  {
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific mouse handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableMouseHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    return true;
+  }
+
+  /**
+    @brief Disables a specific mouse handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableMouseHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeMouseHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    return true;
+  }
+
+  /**
+    @brief Checks whether a mouse handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isMouseHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### JoyStickHandler ######
+
+  /**
+    @brief Adds a new joy stick handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
+  {
+    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a JoyStick handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeJoyStickHandler(const std::string &name)
+  {
+    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
+          itstick != _getSingleton().joySticks_.end(); itstick++)
+      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
+
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
+  {
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific joy stick handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::enableJoyStickHandler(const std::string& name, const int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
+      return false;
+    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
+          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    return true;
+  }
+
+  /**
+    @brief Disables a specific joy stick handler.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::disableJoyStickHandler(const std::string &name, int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
+      return false;
+    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+
+    // look for the handler in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
+          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a joy stick handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isJoyStickHandlerActive(const std::string& name, const int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if ((unsigned int)ID >= _getSingleton().joySticks_.size())
+      return false;
+    OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
+          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+        return true;
+    }
+    return false;
+  }
 
 }
Index: code/trunk/src/core/InputManager.h
===================================================================
--- code/trunk/src/core/InputManager.h	(revision 1217)
+++ code/trunk/src/core/InputManager.h	(revision 1219)
@@ -38,52 +38,83 @@
 #include "CorePrereqs.h"
 
-#include <OIS/OIS.h>
+#include <map>
+#include <list>
 
+#include "ois/OIS.h"
 #include "Tickable.h"
-#include "InputEvent.h"
 
 namespace orxonox
 {
-  /**
-    @brief Designates the way input is handled currently.
-    IM_GUI:      All the OIS input events are passed to CEGUI
-    IM_KEYBOARD: Only keyboard input is captured and passed to the InputBuffer
-    IM_INGAME:   Normal game mode. Key bindings and mouse are active.
-  */
-  enum InputMode
+  class Mouse : public OIS::Mouse
   {
-    IM_GUI      = 0,
-    IM_KEYBOARD = 1,
-    IM_INGAME   = 2,
-    IM_UNINIT   = 3,
   };
 
   /**
     @brief Captures and distributes mouse and keyboard input.
-    It resolves the key bindings to InputEvents which can be heard by
-    implementing the InputEventListener interface.
   */
   class _CoreExport InputManager
-        : public Tickable
+        : public Tickable,
+          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
   {
-  public:
-    bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
-    void destroy();
-    void tick(float dt);
-    void setWindowExtents(int width, int height);
-    InputMode getInputMode();
+  public: // enumerations
+    /**
+      @brief Designates the way input is handled and redirected.
+    */
+    enum InputState
+    {
+      IS_UNINIT,  //!< InputManager has not yet been initialised.
+      IS_NONE,    //!< Input is discarded.
+      IS_NORMAL,  //!< Normal play state. Key and button bindings are active.
+      IS_GUI,     //!< All OIS input events are passed to CEGUI.
+      IS_CONSOLE, //!< Keyboard input is redirected to the InputBuffer.
+      IS_CUSTOM   //!< Any possible configuration.
+    };
 
-    // temporary hack
-    void feedInputBuffer(InputBuffer* buffer);
+  public: // static functions
+    static bool initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
+          const bool createKeyboard = true, const bool createMouse = true, const bool createJoySticks = false);
+    static bool initialiseKeyboard();
+    static bool initialiseMouse();
+    static bool initialiseJoySticks();
+    static int  numberOfKeyboards();
+    static int  numberOfMice();
+    static int  numberOfJoySticks();
+
+    static void destroy();
+    static void destroyKeyboard();
+    static void destroyMouse();
+    static void destroyJoySticks();
+
+    static void setWindowExtents(const int width, const int height);
+
+    static void setInputState(const InputState state);
+    static InputState getInputState();
+
+    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
+    static bool removeKeyHandler              (const std::string& name);
+    static KeyHandler* getKeyHandler          (const std::string& name);
+    static bool enableKeyHandler              (const std::string& name);
+    static bool disableKeyHandler             (const std::string& name);
+    static bool isKeyHandlerActive            (const std::string& name);
+
+    static bool addMouseHandler               (MouseHandler* handler, const std::string& name);
+    static bool removeMouseHandler            (const std::string& name);
+    static MouseHandler* getMouseHandler      (const std::string& name);
+    static bool enableMouseHandler            (const std::string& name);
+    static bool disableMouseHandler           (const std::string& name);
+    static bool isMouseHandlerActive          (const std::string& name);
+
+    static bool addJoyStickHandler            (JoyStickHandler* handler, const std::string& name);
+    static bool removeJoyStickHandler         (const std::string& name);
+    static JoyStickHandler* getJoyStickHandler(const std::string& name);
+    static bool enableJoyStickHandler         (const std::string& name, const int id);
+    static bool disableJoyStickHandler        (const std::string& name, const int id);
+    static bool isJoyStickHandlerActive       (const std::string& name, const int id);
 
     // Temporary solutions. Will be removed soon!
-    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
-    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
+    static OIS::Mouse*    getMouse()    { return _getSingleton().mouse_   ; }
+    static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; }
 
-    static InputManager& getSingleton();
-    static InputManager* getSingletonPtr() { return &getSingleton(); }
-    static void setInputMode(int mode);
-
-  private:
+  private: // functions
     // don't mess with a Singleton
     InputManager ();
@@ -91,17 +122,56 @@
     ~InputManager();
 
-    OIS::InputManager *inputSystem_;    //!< OIS input manager
-    OIS::Keyboard     *keyboard_;       //!< OIS mouse
-    OIS::Mouse        *mouse_;          //!< OIS keyboard
+    // Intenal methods
+    bool _initialise(const size_t, const int, const int, const bool, const bool, const bool);
+    bool _initialiseKeyboard();
+    bool _initialiseMouse();
+    bool _initialiseJoySticks();
 
-    InputMode          currentMode_;    //!< Input mode currently used
-    InputMode          setMode_;        //!< Input mode that has been set lately
-    InputHandlerGUI   *handlerGUI_;     //!< Handles the input if in GUI mode
-    // FIXME: insert the InputBuffer once merged with core2
-    InputBuffer       *handlerBuffer_;  //!< Handles the input if in Buffer mode
-    InputHandlerGame  *handlerGame_;    //!< Handles the input if in Game mode
+    void _destroy();
+    void _destroyKeyboard();
+    void _destroyMouse();
+    void _destroyJoySticks();
 
-    //! Pointer to the instance of the singleton
-    //static InputManager *singletonRef_s;
+    //void _setNumberOfJoysticks(int size);
+
+    void tick(float dt);
+
+    // input events
+		bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+		bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    bool mouseMoved    (const OIS::MouseEvent    &arg);
+		bool keyPressed    (const OIS::KeyEvent      &arg);
+		bool keyReleased   (const OIS::KeyEvent      &arg);
+		bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+		bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+		bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+		bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+		bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+		bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
+
+    static InputManager& _getSingleton();
+    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
+
+  private: // variables
+    OIS::InputManager*                          inputSystem_; //!< OIS input manager
+    OIS::Keyboard*                              keyboard_;    //!< OIS mouse
+    OIS::Mouse*                                 mouse_;       //!< OIS keyboard
+    std::vector<OIS::JoyStick*>                 joySticks_;   //!< OIS joy sticks
+
+    InputState state_;
+    InputState stateRequest_;
+
+    std::map<std::string, KeyHandler*>          keyHandlers_;
+    std::map<std::string, MouseHandler*>        mouseHandlers_;
+    std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
+
+    std::vector<KeyHandler*>                    activeKeyHandlers_;
+    std::vector<MouseHandler*>                  activeMouseHandlers_;
+    std::map< OIS::JoyStick*, std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+
+    std::list<OIS::KeyCode>                     keysDown_;
+    std::list<OIS::MouseButtonID>               mouseButtonsDown_;
+    std::map< OIS::JoyStick*, std::list<int> >  joyStickButtonsDown_;
+
   };
 }
