Index: code/branches/input/src/core/CMakeLists.txt
===================================================================
--- code/branches/input/src/core/CMakeLists.txt	(revision 1196)
+++ code/branches/input/src/core/CMakeLists.txt	(revision 1203)
@@ -5,5 +5,5 @@
   Identifier.cc
   IdentifierDistributor.cc
-#  InputHandler.cc
+  InputHandler.cc
   InputManager.cc
 #  InputEventListener.cc
Index: code/branches/input/src/core/InputBuffer.h
===================================================================
--- code/branches/input/src/core/InputBuffer.h	(revision 1196)
+++ code/branches/input/src/core/InputBuffer.h	(revision 1203)
@@ -36,4 +36,5 @@
 
 #include "ois/OISKeyboard.h"
+#include "InputHandler.h"
 
 namespace orxonox
@@ -42,5 +43,5 @@
     {};
 
-    class _CoreExport InputBuffer : public OIS::KeyListener
+    class _CoreExport InputBuffer : public KeyHandler
     {
         struct InputBufferListenerTuple
@@ -110,4 +111,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/branches/input/src/core/InputHandler.cc
===================================================================
--- code/branches/input/src/core/InputHandler.cc	(revision 1196)
+++ code/branches/input/src/core/InputHandler.cc	(revision 1203)
@@ -35,7 +35,4 @@
 #include "Debug.h"
 #include "util/Convert.h"
-#include "InputEventListener.h"
-#include "InputEvent.h"
-#include "InputManager.h"
 #include "core/CommandExecutor.h"
 
@@ -43,12 +40,13 @@
 {
   // ###############################
-  // ###    InputHandlerGame     ###
+  // ######     KeyBinder     ######
   // ###############################
 
   /**
-    @brief standard constructor
-  */
-  InputHandlerGame::InputHandlerGame()
-  {
+    @brief Constructor that does as little as necessary.
+  */
+  KeyBinder::KeyBinder()
+  {
+    clearBindings();
   }
 
@@ -56,25 +54,53 @@
     @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 Overwrites all bindings with ""
+  */
+  void KeyBinder::clearBindings()
   {
     for (int i = 0; i < numberOfKeys_s; i++)
     {
-      // simply write the key number (i) in the string
-      this->bindingsKeyPress_[i] = "";
-      this->bindingsKeyRelease_[i] = "";
-    }
-    this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "setInputMode " + getConvertedValue<int, std::string>(IM_KEYBOARD);
-    this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit";
-    this->bindingsKeyHold_[OIS::KC_U] = "exec disco.txt";
-    return true;
-  }
+      bindingsKeyPress_  [i] = "";
+      bindingsKeyRelease_[i] = "";
+      bindingsKeyHold_   [i] = "";
+    }
+    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;
+
+    // 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";
+
+    COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
+    return true;
+  }
+
 
   /**
@@ -82,7 +108,6 @@
     @param e Event information
   */
-  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
-  {
-    this->keysDown_.push_back(e.key);
+  bool KeyBinder::keyPressed(const OIS::KeyEvent &e)
+  {
     // find the appropriate key binding
     std::string cmdStr = bindingsKeyPress_[int(e.key)];
@@ -92,4 +117,5 @@
       COUT(3) << "Executing command: " << cmdStr << std::endl;
     }
+    
     return true;
   }
@@ -99,16 +125,6 @@
     @param e Event information
   */
-  bool InputHandlerGame::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;
-      }
-    }
-
+  bool KeyBinder::keyReleased(const OIS::KeyEvent &e)
+  {
     // find the appropriate key binding
     std::string cmdStr = bindingsKeyRelease_[int(e.key)];
@@ -118,4 +134,22 @@
       COUT(3) << "Executing command: " << cmdStr << std::endl;
     }
+
+    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
+    std::string cmdStr = bindingsKeyHold_[int(e.key)];
+    if (cmdStr != "")
+    {
+      CommandExecutor::execute(cmdStr);
+      COUT(3) << "Executing command: " << cmdStr << std::endl;
+    }
+
     return true;
   }
@@ -125,5 +159,5 @@
     @param e Event information
   */
-  bool InputHandlerGame::mouseMoved(const OIS::MouseEvent &e)
+  bool KeyBinder::mouseMoved(const OIS::MouseEvent &e)
   {
     return true;
@@ -135,6 +169,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;
   }
@@ -145,123 +187,161 @@
     @param id The ID of the mouse button
   */
-  bool InputHandlerGame::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    return true;
-  }
-
-  /**
-    @brief Tick method to do additional calculations.
-    @param dt Delta time.
-  */
-  void InputHandlerGame::tick(float dt)
-  {
-    // iterate through all the pressed keys
-    for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
-    {
-      // find the appropriate key binding
-      std::string cmdStr = bindingsKeyHold_[*it];
-      if (cmdStr != "")
-      {
-        CommandExecutor::execute(cmdStr);
-        COUT(3) << "Executing command: " << cmdStr << std::endl;
-      }
-    }
-  }
-
-  /**
-    @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++;
-    }
-  }
+  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 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(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(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(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(const OIS::JoyStickEvent &arg, int axis)
+  {
+    return true;
+  }
+
+  bool KeyBinder::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    return true;
+  }
+
+  bool KeyBinder::povMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    return true;
+  }
+
 
 
   // ###############################
-  // ###     InputHandlerGUI     ###
+  // ###     GUIInputHandler     ###
   // ###############################
 
-  /**
-    @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.
-    @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;
-  }
-
-  /**
-    @brief Tick method to do additional calculations.
-    @param dt Delta time.
-  */
-  void InputHandlerGUI::tick(float dt)
-  {
-    
-  }
+  ///**
+  //  @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/branches/input/src/core/InputHandler.h
===================================================================
--- code/branches/input/src/core/InputHandler.h	(revision 1196)
+++ code/branches/input/src/core/InputHandler.h	(revision 1203)
@@ -38,8 +38,5 @@
 
 #include <string>
-#include <list>
-#include <OIS/OIS.h>
-
-#include "InputEvent.h"
+#include "ois/OIS.h"
 
 namespace orxonox
@@ -56,55 +53,92 @@
   }
 
-  class _CoreExport BaseInputHandler
-      : public OIS::KeyListener, public OIS::MouseListener
-  {
-    virtual void tick(float dt) = 0;
-  };
-    
   /**
-    @brief Captures mouse and keyboard input while in the actual game mode.
-    Manages the key bindings.
+    @brief Interface class used for key input listeners.
   */
-  class _CoreExport InputHandlerGame : public BaseInputHandler
+  class _CoreExport KeyHandler : public OIS::KeyListener
   {
   public:
-    InputHandlerGame ();
-    ~InputHandlerGame();
+    virtual bool keyHeld(const OIS::KeyEvent &arg) = 0;
+  };
+
+  /**
+    @brief Interface class used for mouse input listeners.
+  */
+  class _CoreExport MouseHandler : public OIS::MouseListener
+  {
+  public:
+    virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0;
+  };
+
+  /**
+    @brief Interface class used for joy stick input listeners.
+  */
+  class _CoreExport JoyStickHandler : public OIS::JoyStickListener
+  {
+  public:
+    virtual bool buttonHeld(const OIS::JoyStickEvent &arg, int button) = 0;
+  };
+ 
+
+  /**
+    @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:
+    KeyBinder ();
+    ~KeyBinder();
 
     bool loadBindings();
+    void clearBindings();
 
-  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);
+  private: // functions
 		bool keyPressed   (const OIS::KeyEvent   &arg);
 		bool keyReleased  (const OIS::KeyEvent   &arg);
+		bool keyHeld      (const OIS::KeyEvent   &arg);
 
-    void tick(float dt);
+    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);
 
-    // temporary hack
-    void callListeners(InputEvent &evt);
+		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);
 
-    //! Stores all the keys that are down
-    std::list<OIS::KeyCode> keysDown_;
-
+  private: // variables
     /** denotes the maximum number of different keys there are in OIS.
-        256 should be ok since the highest number in the enum is 237. */
+        256 should be ok since the highest number in the OIS enum is 237. */
     static const int numberOfKeys_s = 256;
     //! Array of input events for every pressed key
-    std::string bindingsKeyPress_[numberOfKeys_s];
+    std::string bindingsKeyPress_  [numberOfKeys_s];
     //! Array of input events for every released key
     std::string bindingsKeyRelease_[numberOfKeys_s];
-    //! Array of input events for every holding key
-    std::string bindingsKeyHold_[numberOfKeys_s];
+    //!Array of input events for every held key
+    std::string bindingsKeyHold_   [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];
+        16 should be ok since the highest number in the OIS enum is 7. */
+    static const int numberOfMouseButtons_s = 16;
+    //! 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];
+
+    /** denotes the maximum number of different buttons there are in OIS.
+        32 should be ok. */
+    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];
 
   };
@@ -115,20 +149,28 @@
     GUI.
   */
-  class _CoreExport InputHandlerGUI : public BaseInputHandler
-  {
-  public:
-    InputHandlerGUI ();
-    ~InputHandlerGUI();
+  //class _CoreExport GUIInputHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
+  //{
+  //public:
+  //  GUIInputHandler ();
+  //  ~GUIInputHandler();
 
-    void tick(float dt);
+  //private:
+  //  // input events
+		//bool keyPressed   (const OIS::KeyEvent   &arg);
+		//bool keyReleased  (const OIS::KeyEvent   &arg);
+		//bool keyHeld      (const OIS::KeyEvent   &arg);
 
-  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);
-  };
+  //  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/branches/input/src/core/InputManager.cc
===================================================================
--- code/branches/input/src/core/InputManager.cc	(revision 1196)
+++ code/branches/input/src/core/InputManager.cc	(revision 1203)
@@ -45,4 +45,5 @@
   // ###    Internal Methods     ###
   // ###############################
+  // ###############################
 
   /**
@@ -54,8 +55,4 @@
       state_(IS_UNINIT), stateRequest_(IS_UNINIT)
   {
-    // overwrite every key binding with ""
-    _clearBindings();
-    _setNumberOfJoysticks(0);
-
     RegisterObject(InputManager);
   }
@@ -76,5 +73,5 @@
   InputManager::~InputManager()
   {
-    this->_destroy();
+    _destroy();
   }
 
@@ -129,5 +126,5 @@
       setWindowExtents(windowWidth, windowHeight);
 
-      this->state_ = IS_NONE;
+      state_ = IS_NONE;
       CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
     }
@@ -140,7 +137,12 @@
     addKeyListener(new InputBuffer(), "buffer");
 
+    KeyBinder* binder = new KeyBinder();
+    binder->loadBindings();
+    addKeyListener(binder, "keybinder");
+    addMouseListener(binder, "keybinder");
+
     // Read all the key bindings and assign them
-    if (!_loadBindings())
-      return false;
+    //if (!_loadBindings())
+    //  return false;
 
     CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
@@ -150,7 +152,13 @@
   /**
     @brief Creates a keyboard and sets the event handler.
-  */
-  void InputManager::_initialiseKeyboard()
-  {
+    @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
     {
@@ -162,13 +170,19 @@
         // 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;
     }
   }
@@ -176,7 +190,13 @@
   /**
     @brief Creates a mouse and sets the event handler.
-  */
-  void InputManager::_initialiseMouse()
-  {
+    @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
     {
@@ -187,7 +207,11 @@
         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;
+      }
     }
     catch (OIS::Exception ex)
@@ -196,4 +220,5 @@
           << "OIS error message: \"" << ex.eText << "\"" << std::endl;
       mouse_ = 0;
+      return false;
     }
   }
@@ -201,102 +226,40 @@
   /**
     @brief Creates all joy sticks and sets the event handler.
-  */
-  void InputManager::_initialiseJoySticks()
-  {
+    @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)
     {
-      _setNumberOfJoysticks(inputSystem_->getNumberOfDevices(OIS::OISJoyStick));
-      for (std::vector<OIS::JoyStick*>::iterator it = joySticks_.begin(); it != joySticks_.end(); it++)
+      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
       {
         try
         {
-          *it = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
+          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
+          joySticks_[stig->getID()] = stig;
           // register our listener in OIS.
-          (*it)->setEventCallback(this);
-          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << (*it)->getID() << std::endl;
+          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 stick with ID" << (*it)->getID() << "\n"
+          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
               << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-          (*it) = 0;
         }
       }
     }
     else
+    {
       CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
-  }
-
-  /**
-    @brief Resizes all lists related to joy sticks and sets joy stick bindings to "".
-    @param size Number of joy sticks available.
-  */
-  void InputManager::_setNumberOfJoysticks(int size)
-  {
-    this->bindingsJoyStickButtonHold_   .resize(size);
-    this->bindingsJoyStickButtonPress_  .resize(size);
-    this->bindingsJoyStickButtonRelease_.resize(size);
-    this->bJoyStickButtonBindingsActive_.resize(size);
-    this->joyStickButtonsDown_          .resize(size);
-    this->joySticks_                    .resize(size);
-    for (int j = 0; j < size; j++)
-    {
-      bindingsJoyStickButtonPress_  [j].resize(numberOfJoyStickButtons_s);
-      bindingsJoyStickButtonRelease_[j].resize(numberOfJoyStickButtons_s);
-      bindingsJoyStickButtonHold_   [j].resize(numberOfJoyStickButtons_s);
-      for (int i = 0; i < numberOfJoyStickButtons_s; i++)
-      {
-        this->bindingsJoyStickButtonPress_  [j][i] = "";
-        this->bindingsJoyStickButtonRelease_[j][i] = "";
-        this->bindingsJoyStickButtonHold_   [j][i] = "";
-      }
-    }
-  }
-
-  /**
-    @brief Loads the key and button bindings.
-  */
-  bool InputManager::_loadBindings()
-  {
-    CCOUT(ORX_DEBUG) << "Loading key bindings..." << std::endl;
-
-    // clear all the bindings at first.
-    _clearBindings();
-
-    // TODO: Insert the code to load the bindings from file.
-    this->bindingsKeyPress_[OIS::KC_NUMPADENTER] = "activateConsole";
-    this->bindingsKeyPress_[OIS::KC_ESCAPE] = "exit";
-    this->bindingsKeyHold_[OIS::KC_U] = "exec disco.txt";
-
-    CCOUT(ORX_DEBUG) << "Loading key bindings done." << std::endl;
-    return true;
-  }
-
-  /**
-    @brief Overwrites all bindings with ""
-  */
-  void InputManager::_clearBindings()
-  {
-    for (int i = 0; i < numberOfKeys_s; i++)
-    {
-      this->bindingsKeyPress_  [i] = "";
-      this->bindingsKeyRelease_[i] = "";
-      this->bindingsKeyHold_   [i] = "";
-    }
-    for (int i = 0; i < numberOfMouseButtons_s; i++)
-    {
-      this->bindingsMouseButtonPress_  [i] = "";
-      this->bindingsMouseButtonRelease_[i] = "";
-      this->bindingsMouseButtonHold_   [i] = "";
-    }
-    for (unsigned int j = 0; j < joySticks_.size(); j++)
-    {
-      for (int i = 0; i < numberOfJoyStickButtons_s; i++)
-      {
-        this->bindingsJoyStickButtonPress_  [j][i] = "";
-        this->bindingsJoyStickButtonRelease_[j][i] = "";
-        this->bindingsJoyStickButtonHold_   [j][i] = "";
-      }
-    }
+      return false;
+    }
+    return success;
   }
 
@@ -310,42 +273,30 @@
     if (state_ != IS_UNINIT)
     {
-      this->listenersKeyActive_.clear();
-      this->listenersMouseActive_.clear();
-      this->listenersJoySticksActive_.clear();
-      this->listenersKey_.clear();
-      this->listenersMouse_.clear();
-      this->listenersJoySticks_.clear();
-
-      this->keysDown_.clear();
-      this->mouseButtonsDown_.clear();
-
-      _clearBindings();
-
-      if (keyboard_)
-        inputSystem_->destroyInputObject(keyboard_);
-      keyboard_ = 0;
-
-      if (mouse_)
-        inputSystem_->destroyInputObject(mouse_);
-      mouse_ = 0;
-
-      if (joySticks_.size() > 0)
-      {
-        for (unsigned int i = 0; i < joySticks_.size(); i++)
-        {
-          if (joySticks_[i] != 0)
-            inputSystem_->destroyInputObject(joySticks_[i]);
-        }
-        _setNumberOfJoysticks(0);
-      }
-
-      if (inputSystem_)
-        OIS::InputManager::destroyInputSystem(inputSystem_);
-      inputSystem_ = 0;
-
       if (listenersKey_.find("buffer") != listenersKey_.end())
         delete listenersKey_["buffer"];
 
-      this->state_ = IS_UNINIT;
+      if (listenersKey_.find("keybinder") != listenersKey_.end())
+        delete listenersKey_["keybinder"];
+
+      listenersKeyActive_.clear();
+      listenersMouseActive_.clear();
+      listenersJoySticksActive_.clear();
+      listenersKey_.clear();
+      listenersMouse_.clear();
+      listenersJoySticks_.clear();
+
+      keysDown_.clear();
+      mouseButtonsDown_.clear();
+      joySticksButtonsDown_.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
@@ -355,8 +306,51 @@
   }
 
-
-  // ###############################
-  // ###    Interface Methods    ###
-  // ###############################
+  /**
+    @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;
+    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;
+    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 (std::map<int, OIS::JoyStick*>::iterator itstick = joySticks_.begin(); itstick != joySticks_.end(); itstick++)
+      {
+        if ((*itstick).second != 0)
+          inputSystem_->destroyInputObject((*itstick).second);
+      }
+      joySticks_.clear();
+    }
+    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
+  }
+
+
+  // #################################
+  // ### Private Interface Methods ###
+  // #################################
+  // #################################
 
   /**
@@ -372,57 +366,59 @@
     if (state_ != stateRequest_)
     {
-      switch (stateRequest_)
-      {
-      case IS_NORMAL:
-        this->listenersKeyActive_.clear();
-        this->listenersMouseActive_.clear();
-        this->listenersJoySticksActive_.clear();
-        this->bKeyBindingsActive_            = true;
-        this->bMouseButtonBindingsActive_    = true;
-        for (unsigned int i = 0; i < joySticks_.size(); i++)
-          this->bJoyStickButtonBindingsActive_[i] = true;
-        break;
-
-      case IS_GUI:
-        // FIXME: do stuff
-        break;
-
-      case IS_CONSOLE:
-        this->listenersKeyActive_.clear();
-        this->listenersMouseActive_.clear();
-        this->listenersJoySticksActive_.clear();
-        this->bKeyBindingsActive_            = false;
-        this->bMouseButtonBindingsActive_    = true;
-        for (unsigned int i = 0; i < joySticks_.size(); i++)
-          this->bJoyStickButtonBindingsActive_[i] = true;
-        if (listenersKey_.find("buffer") != listenersKey_.end())
-          listenersKeyActive_.push_back(listenersKey_["buffer"]);
-        else
+      if (stateRequest_ != IS_CUSTOM)
+      {
+        listenersKeyActive_.clear();
+        listenersMouseActive_.clear();
+        listenersJoySticksActive_.clear();
+
+        switch (stateRequest_)
         {
-          // someone fiddled with the InputBuffer
-          CCOUT(2) << "Error: Cannot redirect input to console, InputBuffer instance missing." << std::endl;
-          this->bKeyBindingsActive_ = true;
+        case IS_NORMAL:
+          // normal play mode
+          if (listenersKey_.find("keybinder") != listenersKey_.end())
+            listenersKeyActive_.push_back(listenersKey_["keybinder"]);
+          if (listenersMouse_.find("keybinder") != listenersMouse_.end())
+            listenersMouseActive_.push_back(listenersMouse_["keybinder"]);
+          if (listenersJoySticks_.find("keybinder") != listenersJoySticks_.end())
+          {
+            for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
+                  it != joySticks_.end(); it++)
+              listenersJoySticksActive_[(*it).first].push_back(listenersJoySticks_["keybinder"]);
+          }
+          break;
+
+        case IS_GUI:
+          // FIXME: do stuff
+          break;
+
+        case IS_CONSOLE:
+          if (listenersMouse_.find("keybinder") != listenersMouse_.end())
+            listenersMouseActive_.push_back(listenersMouse_["keybinder"]);
+          if (listenersJoySticks_.find("keybinder") != listenersJoySticks_.end())
+          {
+            for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
+                  it != joySticks_.end(); it++)
+              listenersJoySticksActive_[(*it).first].push_back(listenersJoySticks_["keybinder"]);
+          }
+
+          if (listenersKey_.find("buffer") != listenersKey_.end())
+            listenersKeyActive_.push_back(listenersKey_["buffer"]);
+          else
+          {
+            // someone fiddled with the InputBuffer
+            CCOUT(2) << "Error: Cannot redirect input to console, InputBuffer instance missing." << std::endl;
+            if (listenersKey_.find("keybinder") != listenersKey_.end())
+              listenersKeyActive_.push_back(listenersKey_["keybinder"]);
+            else
+              // this is bad
+              CCOUT(2) << "Error: Cannot reactivate key binder: not found!" << std::endl;
+          }
+          break;
+
+        default:
+          break;
         }
-        break;
-
-      case IS_NONE:
-        this->listenersKeyActive_.clear();
-        this->listenersMouseActive_.clear();
-        this->listenersJoySticksActive_.clear();
-        this->bKeyBindingsActive_            = false;
-        this->bMouseButtonBindingsActive_    = false;
-        for (unsigned int i = 0; i < joySticks_.size(); i++)
-          this->bJoyStickButtonBindingsActive_[i] = false;
-        break;
-
-      case IS_CUSTOM:
-        // don't do anything
-        break;
-
-      case IS_UNINIT:
-        // this can't happen
-        break;
-      }
-      state_ = stateRequest_;
+        state_ = stateRequest_;
+      }
     }
 
@@ -432,15 +428,47 @@
     if (keyboard_)
       keyboard_->capture();
-  }
-
-  /*void InputManager::_setDefaultState()
-  {
-    this->listenersKeyActive_.clear();
-    this->listenersMouseActive_.clear();
-    this->listenersJoyStickActive_.clear();
-    this->bKeyBindingsActive_            = true;
-    this->bMouseButtonBindingsActive_    = true;
-    this->bJoyStickButtonBindingsActive_ = true;
-  }*/
+
+
+    // call all the listeners 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 (std::list<KeyHandler*>::const_iterator itKeyHandler = listenersKeyActive_.begin();
+            itKeyHandler != listenersKeyActive_.end(); itKeyHandler++)
+      {
+        (*itKeyHandler)->keyHeld(keyArg);
+      }
+    }
+
+    // call all the listeners 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 (std::list<MouseHandler*>::const_iterator itMouseHandler = listenersMouseActive_.begin();
+            itMouseHandler != listenersMouseActive_.end(); itMouseHandler++)
+      {
+        (*itMouseHandler)->mouseHeld(mouseButtonArg, *itMouseButton);
+      }
+    }
+
+    // call all the listeners for the held joy stick button events
+    for (std::map<int, std::list <int> >::const_iterator itJoyStick = joySticksButtonsDown_.begin();
+          itJoyStick != joySticksButtonsDown_.end(); itJoyStick++)
+    {
+      int id = (*itJoyStick).first;
+      for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
+            itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
+      {
+        OIS::JoyStickEvent joyStickButtonArg(joySticks_[id], joySticks_[id]->getJoyStickState());
+        for (std::list<JoyStickHandler*>::const_iterator itJoyStickHandler = listenersJoySticksActive_[id].begin();
+              itJoyStickHandler != listenersJoySticksActive_[id].end(); itJoyStickHandler++)
+        {
+          (*itJoyStickHandler)->buttonHeld(joyStickButtonArg, *itJoyStickButton);
+        }
+      }
+    }
+  }
 
 
@@ -451,21 +479,18 @@
   bool InputManager::keyPressed(const OIS::KeyEvent &e)
   {
-    this->keysDown_.push_back(e.key);
-
-    if (this->bKeyBindingsActive_)
-    {
-      // find the appropriate key binding
-      std::string cmdStr = bindingsKeyPress_[int(e.key)];
-      if (cmdStr != "")
-      {
-        CommandExecutor::execute(cmdStr);
-        COUT(3) << "Executing command: " << cmdStr << std::endl;
-      }
-    }
-    else
-    {
-      for (std::list<OIS::KeyListener*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++)
-        (*it)->keyPressed(e);
-    }
+    // check whether the key is already 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 (std::list<KeyHandler*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++)
+      (*it)->keyPressed(e);
+
     return true;
   }
@@ -487,19 +512,7 @@
     }
 
-    if (this->bKeyBindingsActive_)
-    {
-      // find the appropriate key binding
-      std::string cmdStr = bindingsKeyRelease_[int(e.key)];
-      if (cmdStr != "")
-      {
-        CommandExecutor::execute(cmdStr);
-        COUT(3) << "Executing command: " << cmdStr << std::endl;
-      }
-    }
-    else
-    {
-      for (std::list<OIS::KeyListener*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++)
-        (*it)->keyReleased(e);
-    }
+    for (std::list<KeyHandler*>::const_iterator it = listenersKeyActive_.begin(); it != listenersKeyActive_.end(); it++)
+      (*it)->keyReleased(e);
+
     return true;
   }
@@ -511,4 +524,7 @@
   bool InputManager::mouseMoved(const OIS::MouseEvent &e)
   {
+    for (std::list<MouseHandler*>::const_iterator it = listenersMouseActive_.begin(); it != listenersMouseActive_.end(); it++)
+      (*it)->mouseMoved(e);
+
     return true;
   }
@@ -521,4 +537,18 @@
   bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
   {
+    // check whether the button is already 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 (std::list<MouseHandler*>::const_iterator it = listenersMouseActive_.begin(); it != listenersMouseActive_.end(); it++)
+      (*it)->mousePressed(e, id);
+
     return true;
   }
@@ -531,4 +561,17 @@
   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 (std::list<MouseHandler*>::const_iterator it = listenersMouseActive_.begin(); it != listenersMouseActive_.end(); it++)
+      (*it)->mouseReleased(e, id);
+
     return true;
   }
@@ -536,4 +579,22 @@
   bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
   {
+    int devID = arg.device->getID();
+
+    // check whether the button is already in the list (can happen when focus was lost)
+    std::list<int>& buttonsDownList = joySticksButtonsDown_[devID];
+    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
+    {
+      if (*it == button)
+      {
+        buttonsDownList.erase(it);
+        break;
+      }
+    }
+    joySticksButtonsDown_[devID].push_back(button);
+
+    std::list<JoyStickHandler*>::iterator end = listenersJoySticksActive_[devID].end();
+    for (std::list<JoyStickHandler*>::const_iterator it = listenersJoySticksActive_[devID].begin(); it != end; it++)
+      (*it)->buttonPressed(arg, button);
+
     return true;
   }
@@ -541,4 +602,21 @@
   bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
   {
+    int devID = arg.device->getID();
+
+    // remove the button from the joySticksButtonsDown_ list
+    std::list<int>& buttonsDownList = joySticksButtonsDown_[devID];
+    for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
+    {
+      if (*it == button)
+      {
+        buttonsDownList.erase(it);
+        break;
+      }
+    }
+
+    std::list<JoyStickHandler*>::const_iterator end = listenersJoySticksActive_[devID].end();
+    for (std::list<JoyStickHandler*>::const_iterator it = listenersJoySticksActive_[devID].begin(); it != end; it++)
+      (*it)->buttonReleased(arg, button);
+
     return true;
   }
@@ -546,4 +624,9 @@
   bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
   {
+    int devID = arg.device->getID();
+    std::list<JoyStickHandler*>::const_iterator end = listenersJoySticksActive_[devID].end();
+    for (std::list<JoyStickHandler*>::const_iterator it = listenersJoySticksActive_[devID].begin(); it != end; it++)
+      (*it)->axisMoved(arg, axis);
+
     return true;
   }
@@ -551,4 +634,9 @@
   bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
   {
+    int devID = arg.device->getID();
+    std::list<JoyStickHandler*>::const_iterator end = listenersJoySticksActive_[devID].end();
+    for (std::list<JoyStickHandler*>::const_iterator it = listenersJoySticksActive_[devID].begin(); it != end; it++)
+      (*it)->sliderMoved(arg, id);
+
     return true;
   }
@@ -556,4 +644,9 @@
   bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
   {
+    int devID = arg.device->getID();
+    std::list<JoyStickHandler*>::const_iterator end = listenersJoySticksActive_[devID].end();
+    for (std::list<JoyStickHandler*>::const_iterator it = listenersJoySticksActive_[devID].begin(); it != end; it++)
+      (*it)->povMoved(arg, id);
+
     return true;
   }
@@ -563,4 +656,49 @@
   // ### Static Interface Methods ###
   // ################################
+  // ################################
+
+  bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight,
+    bool createKeyboard, bool createMouse, 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();
+  }
+
+
+  void InputManager::destroy()
+  {
+    _getSingleton()._destroy();
+  }
+
+  void InputManager::destroyKeyboard()
+  {
+    return _getSingleton()._destroyKeyboard();
+  }
+
+  void InputManager::destroyMouse()
+  {
+    return _getSingleton()._destroyMouse();
+  }
+
+  void InputManager::destroyJoySticks()
+  {
+    return _getSingleton()._destroyJoySticks();
+  }
+
 
   /**
@@ -600,29 +738,14 @@
   }
 
-  void InputManager::destroy()
-  {
-    _getSingleton()._destroy();
-  }
-
-  bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight,
-    bool createKeyboard, bool createMouse, bool createJoySticks)
-  {
-    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
-          createKeyboard, createMouse, createJoySticks);
-  }
-
-  /*bool InputManager::initialiseKeyboard()
-  {
-  }
-
-  bool InputManager::initialiseMouse()
-  {
-  }
-
-  bool InputManager::initialiseJoySticks()
-  {
-  }*/
-
-  bool InputManager::addKeyListener(OIS::KeyListener *listener, const std::string& name)
+
+  // ###### KeyHandler ######
+
+  /**
+    @brief Adds a new key listener.
+    @param listener Pointer to the listener object.
+    @param name Unique name of the listener.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addKeyListener(KeyHandler* listener, const std::string& name)
   {
     if (_getSingleton().listenersKey_.find(name) == _getSingleton().listenersKey_.end())
@@ -635,7 +758,13 @@
   }
 
+  /**
+    @brief Removes a Key Listener from the list.
+    @param name Unique name of the listener.
+    @return True if removal was successful, false if name was not found.
+  */
   bool InputManager::removeKeyListener(const std::string &name)
   {
-    std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton().listenersKey_.find(name);
+    disableKeyListener(name);
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().listenersKey_.find(name);
     if (it != _getSingleton().listenersKey_.end())
     {
@@ -647,7 +776,12 @@
   }
 
-  OIS::KeyListener* InputManager::getKeyListener(const std::string& name)
-  {
-    std::map<std::string, OIS::KeyListener*>::iterator it = _getSingleton().listenersKey_.find(name);
+  /**
+    @brief Returns the pointer to a listener.
+    @param name Unique name of the listener.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  KeyHandler* InputManager::getKeyListener(const std::string& name)
+  {
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().listenersKey_.find(name);
     if (it != _getSingleton().listenersKey_.end())
     {
@@ -658,3 +792,262 @@
   }
 
+  /**
+    @brief Enables a specific key listener that has already been added.
+    @param name Unique name of the listener.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableKeyListener(const std::string& name)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().listenersKey_.find(name);
+    if (mapIt == _getSingleton().listenersKey_.end())
+      return false;
+    // see whether the listener is already in the list
+    for (std::list<KeyHandler*>::iterator it = _getSingleton().listenersKeyActive_.begin();
+          it != _getSingleton().listenersKeyActive_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    _getSingleton().listenersKeyActive_.push_back((*mapIt).second);
+    return true;
+  }
+
+  /**
+    @brief Disables a specific key listener.
+    @param name Unique name of the listener.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableKeyListener(const std::string &name)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().listenersKey_.find(name);
+    if (mapIt == _getSingleton().listenersKey_.end())
+      return false;
+    // look for the listener in the list
+    for (std::list<KeyHandler*>::iterator it = _getSingleton().listenersKeyActive_.begin();
+          it != _getSingleton().listenersKeyActive_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().listenersKeyActive_.erase(it);
+        return true;
+      }
+    }
+    return true;
+  }
+
+
+  // ###### MouseHandler ######
+  /**
+    @brief Adds a new mouse listener.
+    @param listener Pointer to the listener object.
+    @param name Unique name of the listener.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addMouseListener(MouseHandler* listener, const std::string& name)
+  {
+    if (_getSingleton().listenersMouse_.find(name) == _getSingleton().listenersMouse_.end())
+    {
+      _getSingleton().listenersMouse_[name] = listener;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Mouse Listener from the list.
+    @param name Unique name of the listener.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeMouseListener(const std::string &name)
+  {
+    disableMouseListener(name);
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().listenersMouse_.find(name);
+    if (it != _getSingleton().listenersMouse_.end())
+    {
+      _getSingleton().listenersMouse_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a listener.
+    @param name Unique name of the listener.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  MouseHandler* InputManager::getMouseListener(const std::string& name)
+  {
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().listenersMouse_.find(name);
+    if (it != _getSingleton().listenersMouse_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific mouse listener that has already been added.
+    @param name Unique name of the listener.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableMouseListener(const std::string& name)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().listenersMouse_.find(name);
+    if (mapIt == _getSingleton().listenersMouse_.end())
+      return false;
+    // see whether the listener is already in the list
+    for (std::list<MouseHandler*>::iterator it = _getSingleton().listenersMouseActive_.begin();
+          it != _getSingleton().listenersMouseActive_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    _getSingleton().listenersMouseActive_.push_back((*mapIt).second);
+    return true;
+  }
+
+  /**
+    @brief Disables a specific mouse listener.
+    @param name Unique name of the listener.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableMouseListener(const std::string &name)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().listenersMouse_.find(name);
+    if (mapIt == _getSingleton().listenersMouse_.end())
+      return false;
+    // look for the listener in the list
+    for (std::list<MouseHandler*>::iterator it = _getSingleton().listenersMouseActive_.begin();
+          it != _getSingleton().listenersMouseActive_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().listenersMouseActive_.erase(it);
+        return true;
+      }
+    }
+    return true;
+  }
+
+
+  // ###### JoyStickHandler ######
+
+  /**
+    @brief Adds a new joy stick listener.
+    @param listener Pointer to the listener object.
+    @param name Unique name of the listener.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addJoyStickListener(JoyStickHandler* listener, const std::string& name)
+  {
+    if (_getSingleton().listenersJoySticks_.find(name) == _getSingleton().listenersJoySticks_.end())
+    {
+      _getSingleton().listenersJoySticks_[name] = listener;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a JoyStick Listener from the list.
+    @param name Unique name of the listener.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeJoyStickListener(const std::string &name)
+  {
+    for (std::map<int, OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin(); itstick != _getSingleton().joySticks_.end(); itstick++)
+      disableJoyStickListener(name, (*itstick).first);
+
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().listenersJoySticks_.find(name);
+    if (it != _getSingleton().listenersJoySticks_.end())
+    {
+      _getSingleton().listenersJoySticks_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a listener.
+    @param name Unique name of the listener.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  JoyStickHandler* InputManager::getJoyStickListener(const std::string& name)
+  {
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().listenersJoySticks_.find(name);
+    if (it != _getSingleton().listenersJoySticks_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific joy stick listener that has already been added.
+    @param name Unique name of the listener.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::enableJoyStickListener(const std::string& name, const int id)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, JoyStickHandler*>::const_iterator listenerIt = _getSingleton().listenersJoySticks_.find(name);
+    if (listenerIt == _getSingleton().listenersJoySticks_.end())
+      return false;
+
+    // check for existance of the ID
+    std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
+    if (joyStickIt == _getSingleton().joySticks_.end())
+      return false;
+
+    // see whether the listener is already in the list
+    for (std::list<JoyStickHandler*>::iterator it = _getSingleton().listenersJoySticksActive_[id].begin();
+          it != _getSingleton().listenersJoySticksActive_[id].end(); it++)
+    {
+      if ((*it) == (*listenerIt).second)
+        return true;
+    }
+    _getSingleton().listenersJoySticksActive_[id].push_back((*listenerIt).second);
+    return true;
+  }
+
+  /**
+    @brief Disables a specific joy stick listener.
+    @param name Unique name of the listener.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::disableJoyStickListener(const std::string &name, int id)
+  {
+    // get pointer from the map with all stored listeners
+    std::map<std::string, JoyStickHandler*>::const_iterator listenerIt = _getSingleton().listenersJoySticks_.find(name);
+    if (listenerIt == _getSingleton().listenersJoySticks_.end())
+      return false;
+
+    // check for existance of the ID
+    std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
+    if (joyStickIt == _getSingleton().joySticks_.end())
+      return false;
+
+    // look for the listener in the list
+    for (std::list<JoyStickHandler*>::iterator it = _getSingleton().listenersJoySticksActive_[id].begin();
+          it != _getSingleton().listenersJoySticksActive_[id].end(); it++)
+    {
+      if ((*it) == (*listenerIt).second)
+      {
+        _getSingleton().listenersJoySticksActive_[id].erase(it);
+        return true;
+      }
+    }
+    return true;
+  }
+
 }
Index: code/branches/input/src/core/InputManager.h
===================================================================
--- code/branches/input/src/core/InputManager.h	(revision 1196)
+++ code/branches/input/src/core/InputManager.h	(revision 1203)
@@ -43,8 +43,13 @@
 #include "ois/OIS.h"
 #include "Tickable.h"
-#include "InputEvent.h"
+//#include "InputEvent.h"
+#include "InputHandler.h"
 
 namespace orxonox
 {
+  class Mouse : public OIS::Mouse
+  {
+  };
+
   /**
     @brief Captures and distributes mouse and keyboard input.
@@ -70,10 +75,15 @@
     };
 
-  public: // functions
-    // METHODS OF THE STATIC INTERFACE
-
+  public: // static functions
     static bool initialise(size_t windowHnd, int windowWidth, int windowHeight,
           bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
+    static bool initialiseKeyboard();
+    static bool initialiseMouse();
+    static bool initialiseJoySticks();
+
     static void destroy();
+    static void destroyKeyboard();
+    static void destroyMouse();
+    static void destroyJoySticks();
 
     static void setWindowExtents(int width, int height);
@@ -85,24 +95,24 @@
     static void setJoyStickButtonBindingState(bool bActive);
 
-    static bool addKeyListener(OIS::KeyListener* listener, const std::string& name);
+    static bool addKeyListener(KeyHandler* listener, const std::string& name);
     static bool removeKeyListener  (const std::string& name);
     static bool enableKeyListener  (const std::string& name);
     static bool disableKeyListener (const std::string& name);
     static bool isKeyListenerActive(const std::string& name);
-    static OIS::KeyListener* getKeyListener(const std::string& name);
+    static KeyHandler* getKeyListener(const std::string& name);
 
-    static bool addMouseListener(OIS::MouseListener* listener, const std::string& name);
+    static bool addMouseListener(MouseHandler* listener, const std::string& name);
     static bool removeMouseListener  (const std::string& name);
     static bool enableMouseListener  (const std::string& name);
     static bool disableMouseListener (const std::string& name);
     static bool isMouseListenerActive(const std::string& name);
-    static OIS::MouseListener* getMouseListener(const std::string& name);
+    static MouseHandler* getMouseListener(const std::string& name);
 
-    static bool addJoyStickListener(OIS::JoyStickListener* listener, const std::string& name);
+    static bool addJoyStickListener(JoyStickHandler* listener, const std::string& name);
     static bool removeJoyStickListener  (const std::string& name);
-    static bool enableJoyStickListener  (const std::string& name);
-    static bool disableJoyStickListener (const std::string& name);
+    static bool enableJoyStickListener  (const std::string& name, const int id);
+    static bool disableJoyStickListener (const std::string& name, const int id);
     static bool isJoyStickListenerActive(const std::string& name);
-    static OIS::JoyStickListener* getJoyStickListener(const std::string& name);
+    static JoyStickHandler* getJoyStickListener(const std::string& name);
 
     // Temporary solutions. Will be removed soon!
@@ -118,12 +128,14 @@
     // Intenal methods
     bool _initialise(size_t, int, int, bool, bool, bool);
-    void _initialiseKeyboard();
-    void _initialiseMouse();
-    void _initialiseJoySticks();
+    bool _initialiseKeyboard();
+    bool _initialiseMouse();
+    bool _initialiseJoySticks();
+
     void _destroy();
-    //void _setDefaultState();
-    bool _loadBindings();
-    void _clearBindings();
-    void _setNumberOfJoysticks(int size);
+    void _destroyKeyboard();
+    void _destroyMouse();
+    void _destroyJoySticks();
+
+    //void _setNumberOfJoysticks(int size);
 
     void tick(float dt);
@@ -145,55 +157,23 @@
 
   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
+    OIS::InputManager* inputSystem_;            //!< OIS input manager
+    OIS::Keyboard*     keyboard_;               //!< OIS mouse
+    OIS::Mouse*        mouse_;                  //!< OIS keyboard
+    std::map<int, OIS::JoyStick*> joySticks_;   //!< OIS joy sticks
 
     InputState state_;
     InputState stateRequest_;
 
-    bool bKeyBindingsActive_;
-    bool bMouseButtonBindingsActive_;
-    std::vector<bool> bJoyStickButtonBindingsActive_;
+    std::map<std::string, KeyHandler*>      listenersKey_;
+    std::map<std::string, MouseHandler*>    listenersMouse_;
+    std::map<std::string, JoyStickHandler*> listenersJoySticks_;
 
-    std::map<std::string, OIS::KeyListener*>      listenersKey_;
-    std::map<std::string, OIS::MouseListener*>    listenersMouse_;
-    std::map<std::string, OIS::JoyStickListener*> listenersJoySticks_;
-
-    std::list<OIS::KeyListener*>      listenersKeyActive_;
-    std::list<OIS::MouseListener*>    listenersMouseActive_;
-    std::list<OIS::JoyStickListener*> listenersJoySticksActive_;
+    std::list<KeyHandler*>      listenersKeyActive_;
+    std::list<MouseHandler*>    listenersMouseActive_;
+    std::map< int, std::list<JoyStickHandler*> > listenersJoySticksActive_;
 
     std::list<OIS::KeyCode>         keysDown_;
     std::list<OIS::MouseButtonID>   mouseButtonsDown_;
-    std::vector< std::list<int> >   joyStickButtonsDown_;
-
-
-    /** 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;
-    //! 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
-    std::string bindingsKeyHold_   [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;
-    //! 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];
-
-    /** denotes the maximum number of different buttons there are in OIS.
-        32 should be ok. */
-    static const int numberOfJoyStickButtons_s = 32;
-    std::vector< std::vector< std::string > > bindingsJoyStickButtonPress_;
-    std::vector< std::vector< std::string > > bindingsJoyStickButtonRelease_;
-    std::vector< std::vector< std::string > > bindingsJoyStickButtonHold_;
+    std::map< int, std::list<int> > joySticksButtonsDown_;
 
   };
