Index: code/branches/input/src/core/InputHandler.cc
===================================================================
--- code/branches/input/src/core/InputHandler.cc	(revision 1213)
+++ code/branches/input/src/core/InputHandler.cc	(revision 1215)
@@ -267,6 +267,8 @@
         switch (j)
         {
+          // note: the first element in the struct is the string, so the following pointer
+          //       arithmetic works.
           case 0:
-            cont->getValue(bindingsKeyPress_ + i);
+            cont->getValue(&bindingsKeyPress_[i].commandStr);
             break;
           case 1:
@@ -337,7 +339,7 @@
     for (int i = 0; i < numberOfKeys_s; i++)
     {
-      bindingsKeyPress_  [i] = "";
-      bindingsKeyRelease_[i] = "";
-      bindingsKeyHold_   [i] = "";
+      bindingsKeyPress_  [i].commandStr = "";
+      bindingsKeyRelease_[i].commandStr = "";
+      bindingsKeyHold_   [i].commandStr = "";
     }
     for (int i = 0; i < numberOfMouseButtons_s; i++)
@@ -366,5 +368,33 @@
     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;
   }
@@ -379,11 +409,6 @@
     COUT(3) << "Key: " << e.key << std::endl;
     // find the appropriate key binding
-    std::string cmdStr = bindingsKeyPress_[int(e.key)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
-    
+    executeBinding(bindingsKeyPress_[int(e.key)]);
+     
     return true;
   }
@@ -396,10 +421,5 @@
   {
     // find the appropriate key binding
-    std::string cmdStr = bindingsKeyRelease_[int(e.key)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
+    executeBinding(bindingsKeyRelease_[int(e.key)]);
 
     return true;
@@ -413,10 +433,5 @@
   {
     // find the appropriate key binding
-    std::string cmdStr = bindingsKeyHold_[int(e.key)];
-    if (cmdStr != "")
-    {
-      CommandExecutor::execute(cmdStr);
-      COUT(3) << "Executing command: " << cmdStr << std::endl;
-    }
+    executeBinding(bindingsKeyHold_[int(e.key)]);
 
     return true;
@@ -486,5 +501,5 @@
   }
 
-  bool KeyBinder::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+  bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button)
   {
     // find the appropriate key binding
@@ -499,5 +514,5 @@
   }
 
-  bool KeyBinder::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+  bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button)
   {
     // find the appropriate key binding
@@ -512,5 +527,5 @@
   }
 
-  bool KeyBinder::buttonHeld(const OIS::JoyStickEvent &arg, int button)
+  bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button)
   {
     // find the appropriate key binding
@@ -525,15 +540,20 @@
   }
 
-  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)
+  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;
Index: code/branches/input/src/core/InputHandler.h
===================================================================
--- code/branches/input/src/core/InputHandler.h	(revision 1213)
+++ code/branches/input/src/core/InputHandler.h	(revision 1215)
@@ -40,4 +40,5 @@
 #include "ois/OIS.h"
 #include "OrxonoxClass.h"
+#include "CommandExecutor.h"
 
 namespace orxonox
@@ -60,4 +61,5 @@
   {
   public:
+    virtual ~KeyHandler() { }
     virtual bool keyHeld(const OIS::KeyEvent &arg) = 0;
   };
@@ -69,4 +71,5 @@
   {
   public:
+    virtual ~MouseHandler() { }
     virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0;
   };
@@ -75,8 +78,21 @@
     @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;
+  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;
   };
  
@@ -100,4 +116,7 @@
 
   private: // functions
+
+    bool executeBinding(KeyBinding &binding);
+
 		bool keyPressed   (const OIS::KeyEvent   &arg);
 		bool keyReleased  (const OIS::KeyEvent   &arg);
@@ -109,10 +128,11 @@
     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);
+		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
@@ -121,9 +141,9 @@
     static const int numberOfKeys_s = 0xEE;
     //! Array of input events for every pressed key
-    std::string bindingsKeyPress_  [numberOfKeys_s];
+    KeyBinding bindingsKeyPress_  [numberOfKeys_s];
     //! Array of input events for every released key
-    std::string bindingsKeyRelease_[numberOfKeys_s];
+    KeyBinding bindingsKeyRelease_[numberOfKeys_s];
     //! Array of input events for every held key
-    std::string bindingsKeyHold_   [numberOfKeys_s];
+    KeyBinding bindingsKeyHold_   [numberOfKeys_s];
     //! Names of the keys as strings
     std::string keyNames_[numberOfKeys_s];
Index: code/branches/input/src/core/InputManager.cc
===================================================================
--- code/branches/input/src/core/InputManager.cc	(revision 1213)
+++ code/branches/input/src/core/InputManager.cc	(revision 1215)
@@ -55,4 +55,9 @@
   {
     RegisterObject(InputManager);
+
+    this->joySticks_.reserve(5);
+    //this->activeJoyStickHandlers_.reserve(10);
+    this->activeKeyHandlers_.reserve(10);
+    this->activeMouseHandlers_.reserve(10);
   }
 
@@ -242,5 +247,5 @@
         {
           OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
-          joySticks_[stig->getID()] = stig;
+          joySticks_.push_back(stig);
           // register our listener in OIS.
           stig->setEventCallback(this);
@@ -278,14 +283,7 @@
         delete keyHandlers_["keybinder"];
 
-      activeKeyHandlers_.clear();
-      activeMouseHandlers_.clear();
-      activeJoyStickHandlers_.clear();
       keyHandlers_.clear();
       mouseHandlers_.clear();
       joyStickHandlers_.clear();
-
-      keysDown_.clear();
-      mouseButtonsDown_.clear();
-      joyStickButtonsDown_.clear();
 
       _destroyKeyboard();
@@ -314,4 +312,6 @@
       inputSystem_->destroyInputObject(keyboard_);
     keyboard_ = 0;
+    activeKeyHandlers_.clear();
+    keysDown_.clear();
     CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
   }
@@ -326,4 +326,6 @@
       inputSystem_->destroyInputObject(mouse_);
     mouse_ = 0;
+    activeMouseHandlers_.clear();
+    mouseButtonsDown_.clear();
     CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
   }
@@ -337,10 +339,11 @@
     {
       // 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);
-      }
+      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;
@@ -375,14 +378,11 @@
         case IS_NORMAL:
           // normal play mode
-          if (keyHandlers_.find("keybinder") != keyHandlers_.end())
-            activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
-          if (mouseHandlers_.find("keybinder") != mouseHandlers_.end())
-            activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
-          if (joyStickHandlers_.find("keybinder") != joyStickHandlers_.end())
-          {
-            for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
-                  it != joySticks_.end(); it++)
-              activeJoyStickHandlers_[(*it).first].push_back(joyStickHandlers_["keybinder"]);
-          }
+          // 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;
 
@@ -392,25 +392,10 @@
 
         case IS_CONSOLE:
-          if (mouseHandlers_.find("keybinder") != mouseHandlers_.end())
-            activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
-          if (joyStickHandlers_.find("keybinder") != joyStickHandlers_.end())
-          {
-            for (std::map<int, OIS::JoyStick*>::const_iterator it = joySticks_.begin();
-                  it != joySticks_.end(); it++)
-              activeJoyStickHandlers_[(*it).first].push_back(joyStickHandlers_["keybinder"]);
-          }
-
-          if (keyHandlers_.find("buffer") != keyHandlers_.end())
-            activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
-          else
-          {
-            // someone fiddled with the InputBuffer
-            CCOUT(2) << "Error: Cannot redirect input to console, InputBuffer instance missing." << std::endl;
-            if (keyHandlers_.find("keybinder") != keyHandlers_.end())
-              activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
-            else
-              // this is bad
-              CCOUT(2) << "Error: Cannot reactivate key binder: not found!" << std::endl;
-          }
+          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;
 
@@ -434,9 +419,6 @@
     {
       OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
-      for (std::list<KeyHandler*>::const_iterator itKeyHandler = activeKeyHandlers_.begin();
-            itKeyHandler != activeKeyHandlers_.end(); itKeyHandler++)
-      {
-        (*itKeyHandler)->keyHeld(keyArg);
-      }
+      for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+        activeKeyHandlers_[i]->keyHeld(keyArg);
     }
 
@@ -446,29 +428,25 @@
     {
       OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
-      for (std::list<MouseHandler*>::const_iterator itMouseHandler = activeMouseHandlers_.begin();
-            itMouseHandler != activeMouseHandlers_.end(); itMouseHandler++)
-      {
-        (*itMouseHandler)->mouseHeld(mouseButtonArg, *itMouseButton);
-      }
+      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<int, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
+    for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
           itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
     {
-      int id = (*itJoyStick).first;
+      OIS::JoyStick* joyStick = (*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 = activeJoyStickHandlers_[id].begin();
-              itJoyStickHandler != activeJoyStickHandlers_[id].end(); itJoyStickHandler++)
-        {
-          (*itJoyStickHandler)->buttonHeld(joyStickButtonArg, *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 ######
 
   /**
@@ -478,5 +456,5 @@
   bool InputManager::keyPressed(const OIS::KeyEvent &e)
   {
-    // check whether the key is already in the list (can happen when focus was lost)
+    // 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++)
     {
@@ -489,6 +467,6 @@
     keysDown_.push_back(e.key);
 
-    for (std::list<KeyHandler*>::const_iterator it = activeKeyHandlers_.begin(); it != activeKeyHandlers_.end(); it++)
-      (*it)->keyPressed(e);
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyPressed(e);
 
     return true;
@@ -511,9 +489,12 @@
     }
 
-    for (std::list<KeyHandler*>::const_iterator it = activeKeyHandlers_.begin(); it != activeKeyHandlers_.end(); it++)
-      (*it)->keyReleased(e);
-
-    return true;
-  }
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyReleased(e);
+
+    return true;
+  }
+
+
+  // ###### Mouse Events ######
 
   /**
@@ -523,6 +504,6 @@
   bool InputManager::mouseMoved(const OIS::MouseEvent &e)
   {
-    for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
-      (*it)->mouseMoved(e);
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseMoved(e);
 
     return true;
@@ -536,5 +517,5 @@
   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)
+    // 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++)
     {
@@ -547,6 +528,6 @@
     mouseButtonsDown_.push_back(id);
 
-    for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
-      (*it)->mousePressed(e, id);
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mousePressed(e, id);
 
     return true;
@@ -570,16 +551,19 @@
     }
 
-    for (std::list<MouseHandler*>::const_iterator it = activeMouseHandlers_.begin(); it != activeMouseHandlers_.end(); it++)
-      (*it)->mouseReleased(e, id);
-
-    return true;
-  }
+    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)
   {
-    int devID = arg.device->getID();
-
-    // check whether the button is already in the list (can happen when focus was lost)
-    std::list<int>& buttonsDownList = joyStickButtonsDown_[devID];
+    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++)
     {
@@ -590,9 +574,8 @@
       }
     }
-    joyStickButtonsDown_[devID].push_back(button);
-
-    std::list<JoyStickHandler*>::iterator end = activeJoyStickHandlers_[devID].end();
-    for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
-      (*it)->buttonPressed(arg, button);
+    joyStickButtonsDown_[joyStick].push_back(button);
+
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
 
     return true;
@@ -601,8 +584,8 @@
   bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
   {
-    int devID = arg.device->getID();
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
 
     // remove the button from the joyStickButtonsDown_ list
-    std::list<int>& buttonsDownList = joyStickButtonsDown_[devID];
+    std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
     for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
     {
@@ -614,7 +597,6 @@
     }
 
-    std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
-    for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
-      (*it)->buttonReleased(arg, button);
+    for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
+      activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
 
     return true;
@@ -623,8 +605,7 @@
   bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
   {
-    int devID = arg.device->getID();
-    std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
-    for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
-      (*it)->axisMoved(arg, 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;
@@ -633,8 +614,7 @@
   bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
   {
-    int devID = arg.device->getID();
-    std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
-    for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
-      (*it)->sliderMoved(arg, 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;
@@ -643,8 +623,16 @@
   bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
   {
-    int devID = arg.device->getID();
-    std::list<JoyStickHandler*>::const_iterator end = activeJoyStickHandlers_[devID].end();
-    for (std::list<JoyStickHandler*>::const_iterator it = activeJoyStickHandlers_[devID].begin(); it != end; it++)
-      (*it)->povMoved(arg, 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;
@@ -679,17 +667,23 @@
   }
 
-  bool InputManager::isKeyboardInitialised()
-  {
-    return (_getSingleton().keyboard_ != 0);
-  }
-
-  bool InputManager::isMouseInitialised()
-  {
-    return (_getSingleton().mouse_ != 0);
-  }
-
-  bool InputManager::areJoySticksInitialised()
-  {
-    return (_getSingleton().joySticks_.size() > 0);
+  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();
   }
 
@@ -817,6 +811,6 @@
     if (mapIt == _getSingleton().keyHandlers_.end())
       return false;
-    // see whether the handler is already in the list
-    for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
           it != _getSingleton().activeKeyHandlers_.end(); it++)
     {
@@ -844,5 +838,5 @@
       return false;
     // look for the handler in the list
-    for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
           it != _getSingleton().activeKeyHandlers_.end(); it++)
     {
@@ -869,6 +863,6 @@
     if (mapIt == _getSingleton().keyHandlers_.end())
       return false;
-    // see whether the handler is already in the list
-    for (std::list<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
           it != _getSingleton().activeKeyHandlers_.end(); it++)
     {
@@ -943,6 +937,6 @@
     if (mapIt == _getSingleton().mouseHandlers_.end())
       return false;
-    // see whether the handler is already in the list
-    for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
           it != _getSingleton().activeMouseHandlers_.end(); it++)
     {
@@ -970,5 +964,5 @@
       return false;
     // look for the handler in the list
-    for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
           it != _getSingleton().activeMouseHandlers_.end(); it++)
     {
@@ -995,6 +989,6 @@
     if (mapIt == _getSingleton().mouseHandlers_.end())
       return false;
-    // see whether the handler is already in the list
-    for (std::list<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
           it != _getSingleton().activeMouseHandlers_.end(); it++)
     {
@@ -1032,6 +1026,7 @@
   bool InputManager::removeJoyStickHandler(const std::string &name)
   {
-    for (std::map<int, OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin(); itstick != _getSingleton().joySticks_.end(); itstick++)
-      disableJoyStickHandler(name, (*itstick).first);
+    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);
@@ -1066,19 +1061,19 @@
     @return False if name or id was not found, true otherwise.
   */
-  bool InputManager::enableJoyStickHandler(const std::string& name, const int id)
-  {
-    // get pointer from the map with all stored handlers
+  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 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 handler is already in the list
-    for (std::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
-          it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
+    // 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)
@@ -1088,5 +1083,5 @@
       }
     }
-    _getSingleton().activeJoyStickHandlers_[id].push_back((*handlerIt).second);
+    _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
     _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
@@ -1098,28 +1093,27 @@
     @return False if name or id was not found, true otherwise.
   */
-  bool InputManager::disableJoyStickHandler(const std::string &name, int id)
-  {
-    // get pointer from the map with all stored handlers
+  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 existance of the ID
-    std::map<int, OIS::JoyStick*>::const_iterator joyStickIt = _getSingleton().joySticks_.find(id);
-    if (joyStickIt == _getSingleton().joySticks_.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::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
-          it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
+          it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     {
       if ((*it) == (*handlerIt).second)
       {
-        _getSingleton().activeJoyStickHandlers_[id].erase(it);
+        _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
         _getSingleton().stateRequest_ = IS_CUSTOM;
         return true;
       }
     }
-    _getSingleton().stateRequest_ = IS_CUSTOM;
     return true;
   }
@@ -1130,19 +1124,19 @@
     @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 pointer from the map with all stored handlers
+  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 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 handler is already in the list
-    for (std::list<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[id].begin();
-          it != _getSingleton().activeJoyStickHandlers_[id].end(); it++)
+    // 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)
Index: code/branches/input/src/core/InputManager.h
===================================================================
--- code/branches/input/src/core/InputManager.h	(revision 1213)
+++ code/branches/input/src/core/InputManager.h	(revision 1215)
@@ -77,7 +77,7 @@
     static bool initialiseMouse();
     static bool initialiseJoySticks();
-    static bool isKeyboardInitialised();
-    static bool isMouseInitialised();
-    static bool areJoySticksInitialised();
+    static int  numberOfKeyboards();
+    static int  numberOfMice();
+    static int  numberOfJoySticks();
 
     static void destroy();
@@ -148,4 +148,5 @@
 		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();
@@ -156,5 +157,5 @@
     OIS::Keyboard*                              keyboard_;    //!< OIS mouse
     OIS::Mouse*                                 mouse_;       //!< OIS keyboard
-    std::map<int, OIS::JoyStick*>               joySticks_;   //!< OIS joy sticks
+    std::vector<OIS::JoyStick*>                 joySticks_;   //!< OIS joy sticks
 
     InputState state_;
@@ -165,11 +166,11 @@
     std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
 
-    std::list<KeyHandler*>                      activeKeyHandlers_;
-    std::list<MouseHandler*>                    activeMouseHandlers_;
-    std::map<int, std::list<JoyStickHandler*> > activeJoyStickHandlers_;
+    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< int, std::list<int> >             joyStickButtonsDown_;
+    std::map< OIS::JoyStick*, std::list<int> >  joyStickButtonsDown_;
 
   };
Index: code/branches/input/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/input/src/orxonox/Orxonox.cc	(revision 1213)
+++ code/branches/input/src/orxonox/Orxonox.cc	(revision 1215)
@@ -398,8 +398,5 @@
           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
       abortImmediateForce();
-    InputManager::setInputState(InputManager::IS_CUSTOM);
-    InputManager::enableKeyHandler("keybinder");
-    InputManager::enableMouseHandler("keybinder");
-    InputManager::enableJoyStickHandler("keybinder", 0);
+    InputManager::setInputState(InputManager::IS_NORMAL);
   }
 
Index: code/branches/input/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1213)
+++ code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1215)
@@ -431,5 +431,4 @@
         {
           InputManager::addMouseHandler(this, "SpaceShip");
-          InputManager::enableMouseHandler("SpaceShip");
           setMouseEventCallback_ = true;
         }
