Index: code/trunk/src/orxonox/core/ArgReader.cc
===================================================================
--- code/trunk/src/orxonox/core/ArgReader.cc	(revision 1021)
+++ 	(revision )
@@ -1,113 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file  ArgReader.cc
- @brief Argument Reader
- */
-
-#include <iostream>
-
-#include "ArgReader.h"
-
-namespace orxonox {
-
-  ArgReader::ArgReader(int argc, char** argv)
-  {
-    counter_ = argc;
-    arguments_ = argv;
-    fail_ = false;
-    errorStr_ = "";
-  }
-
-  void ArgReader::checkArgument(std::string option, std::string &string, bool must)
-  {
-    int argpos = checkOption(option) + 1;
-    if(argpos != 0)
-    {
-      string = arguments_[argpos];
-    }
-    else
-    {
-      if(must) {
-        errorStr_ = errorStr_ + "Cannot find mandatory argument \"" + option + "\"\n";
-        fail_ = true;
-      }
-    }
-
-  }
-
-  void ArgReader::checkArgument(std::string option, int &integer, bool must)
-  {
-    int argpos = checkOption(option) + 1;
-    if(argpos != 0)
-    {
-      integer = atoi(arguments_[argpos]);
-    }
-    else
-    {
-      if(must) {
-        errorStr_ = errorStr_ + "Cannot find mandatory argument \"" + option + "\"\n";
-        fail_ = true;
-      }
-    }
-  }
-
-  void ArgReader::checkArgument(std::string option, float &floating, bool must)
-  {
-    int argpos = checkOption(option) + 1;
-    if(argpos != 0)
-    {
-      floating = (float)atof(arguments_[argpos]);
-    }
-    else
-    {
-      if(must) {
-        errorStr_ = errorStr_ + "Cannot find mandatory argument \"" + option + "\"\n";
-        fail_ = true;
-      }
-    }
-  }
-
-  int ArgReader::checkOption(std::string option)
-  {
-    for(int i = 1; i < counter_; i++)
-    {
-      if(arguments_[i] == "--" + option)
-          return i;
-    }
-    return -1;
-  }
-
-  bool ArgReader::errorHandling()
-  {
-    if(fail_)
-      std::cout << errorStr_;
-    return fail_;
-  }
-}
-
Index: code/trunk/src/orxonox/core/ArgReader.h
===================================================================
--- code/trunk/src/orxonox/core/ArgReader.h	(revision 1021)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Benjamin Knecht <beni_at_orxonox.net>
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file  Argreader.h
- @brief reads arguments
- @author Benjamin Knecht <beni_at_orxonox.net>
- */
-
-#ifndef _ArgReader_H__
-#define _ArgReader_H__
-
-#include <string>
-
-#include "CorePrereqs.h"
-
-namespace orxonox {
-
-  class _CoreExport ArgReader
-  {
-    public:
-      ArgReader(int argc, char **argv);
-      void checkArgument(std::string option, std::string& string, bool must=false);
-      void checkArgument(std::string option, int& integer, bool must=false);
-      void checkArgument(std::string option, float& floating, bool must=false);
-      bool errorHandling();
-    private:
-      int checkOption(std::string option);
-
-    private:
-      int counter_;
-      char **arguments_;
-      bool fail_;
-      std::string errorStr_;
-  };
-
-}
-#endif /* _ArgReader_H__ */
Index: code/trunk/src/orxonox/core/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/core/CMakeLists.txt	(revision 1021)
+++ code/trunk/src/orxonox/core/CMakeLists.txt	(revision 1024)
@@ -5,9 +5,10 @@
   Identifier.cc
   IdentifierDistributor.cc
+  InputHandler.cc
+  InputManager.cc
   MetaObjectList.cc
   ConfigValueContainer.cc
   Error.cc
   SignalHandler.cc
-  ArgReader.cc
   DebugLevel.cc
   OutputHandler.cc
Index: code/trunk/src/orxonox/core/CorePrereqs.h
===================================================================
--- code/trunk/src/orxonox/core/CorePrereqs.h	(revision 1021)
+++ code/trunk/src/orxonox/core/CorePrereqs.h	(revision 1024)
@@ -27,6 +27,6 @@
 
 /**
-    @file  CorePrereq.h
-    @brief Contains all the necessary forward declarations for all classes, structs and enums.
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
 */
 
@@ -36,5 +36,5 @@
 #include <string>
 
-#include "orxonox/OrxonoxPlatform.h"
+#include "OrxonoxPlatform.h"
 
 //-----------------------------------------------------------------------
@@ -67,7 +67,7 @@
   typedef std::string LanguageEntryLabel;
 
-  class ArgReader;
   class BaseFactory;
   class BaseMetaObjectListElement;
+  class BaseObject;
   template <class T>
   class ClassFactory;
@@ -86,4 +86,7 @@
   class Identifier;
   class IdentifierDistributor;
+  class InputHandlerGame;
+  class InputHandlerGUI;
+  class InputManager;
   template <class T>
   class Iterator;
@@ -103,4 +106,5 @@
   template <class T>
   class SubclassIdentifier;
+  class Tickable;
   template <class T, class O>
   class XMLPortClassObjectContainer;
Index: code/trunk/src/orxonox/core/Factory.h
===================================================================
--- code/trunk/src/orxonox/core/Factory.h	(revision 1021)
+++ code/trunk/src/orxonox/core/Factory.h	(revision 1024)
@@ -51,6 +51,4 @@
 namespace orxonox
 {
-    class BaseObject; // Forward declaration
-
     // ###############################
     // ###         Factory         ###
Index: code/trunk/src/orxonox/core/Identifier.h
===================================================================
--- code/trunk/src/orxonox/core/Identifier.h	(revision 1021)
+++ code/trunk/src/orxonox/core/Identifier.h	(revision 1024)
@@ -33,5 +33,5 @@
      - the name
      - a list with all objects
-     - parents and childs
+     - parents and children
      - the factory (if available)
      - the networkID that can be synchronised with the server
@@ -65,7 +65,4 @@
 namespace orxonox
 {
-    class BaseFactory; // Forward declaration
-    class BaseObject;  // Forward declaration
-
     // ###############################
     // ###       Identifier        ###
Index: code/trunk/src/orxonox/core/InputEvent.h
===================================================================
--- code/trunk/src/orxonox/core/InputEvent.h	(revision 1024)
+++ code/trunk/src/orxonox/core/InputEvent.h	(revision 1024)
@@ -0,0 +1,52 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEvent Structure declaration
+ */
+
+#ifndef _InputEvent_H__
+#define _InputEvent_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  struct InputEvent
+  {
+    unsigned char id;      //!< Event ID
+    bool bStarted;         //!< Tells whether the Event started or ended (e.g. firing started)
+    int data1, data2;      //!< Two additional integer datafields, for instance for the mouse moved event
+    void* dataRef;         //!< Additional pointer to any further data
+  };
+}
+
+#endif /* _InputEvent_H__ */
Index: code/trunk/src/orxonox/core/InputEventListener.cc
===================================================================
--- code/trunk/src/orxonox/core/InputEventListener.cc	(revision 1024)
+++ code/trunk/src/orxonox/core/InputEventListener.cc	(revision 1024)
@@ -0,0 +1,51 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Core relevant parts of InputEventListener
+ */
+
+#include "core/CoreIncludes.h"
+#include "InputEventListener.h"
+
+namespace orxonox
+{
+  /**
+    @brief standard constructor
+  */
+  InputEventListener::InputEventListener()
+  {
+    RegisterRootObject(InputEventListener);
+    this->bActive_ = true;
+  }
+
+  InputEventListener::~InputEventListener()
+  {
+  }
+
+}
Index: code/trunk/src/orxonox/core/InputEventListener.h
===================================================================
--- code/trunk/src/orxonox/core/InputEventListener.h	(revision 1024)
+++ code/trunk/src/orxonox/core/InputEventListener.h	(revision 1024)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief InputEventListener Interface declaration
+ */
+
+#ifndef _InputEventListener_H__
+#define _InputEventListener_H__
+
+#include "CorePrereqs.h"
+
+#include "core/OrxonoxClass.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Interface that any class can use to get key independent input.
+  */
+  class _CoreExport InputEventListener : virtual public OrxonoxClass
+  {
+    friend class InputHandlerGame;
+  public:
+    InputEventListener();
+    virtual ~InputEventListener();
+    /** Method is called every time an Input event occurs && bActive */
+    virtual void eventOccured(InputEvent &evt) = 0;
+
+  private:
+    bool bActive_;
+  };
+}
+
+#endif /* _InputEventListener_H__ */
Index: code/trunk/src/orxonox/core/InputHandler.cc
===================================================================
--- code/trunk/src/orxonox/core/InputHandler.cc	(revision 1024)
+++ code/trunk/src/orxonox/core/InputHandler.cc	(revision 1024)
@@ -0,0 +1,222 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the different input handlers.
+ */
+
+#include "Debug.h"
+#include "util/Convert.h"
+#include "InputEventListener.h"
+#include "InputEvent.h"
+#include "InputHandler.h"
+
+namespace orxonox
+{
+  // ###############################
+  // ###    InputHandlerGame     ###
+  // ###############################
+
+  /**
+    @brief standard constructor
+  */
+  InputHandlerGame::InputHandlerGame()
+  {
+  }
+
+  /**
+    @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()
+  {
+    for (int i = 0; i < numberOfKeys_s; i++)
+    {
+      // simply write the key number (i) in the string
+      this->bindingsKeyPressed_[i] = ConvertValueAndReturn<int, std::string>(i);
+      this->bindingsKeyReleased_[i] = ConvertValueAndReturn<int, std::string>(i);
+    }
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
+  {
+    if (e.key == OIS::KC_ESCAPE)
+    {
+      InputEvent e = {1, true, 0, 0, 0};
+      InputHandlerGame::callListeners(e);
+    }
+    else
+    {
+      // find the appropriate key binding
+      std::string cmdStr = bindingsKeyPressed_[int(e.key)];
+      //COUT(3) << cmdStr << " pressed" << std::endl;
+    }
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e)
+  {
+    // find the appropriate key binding
+    std::string cmdStr = bindingsKeyReleased_[int(e.key)];
+    //COUT(3) << cmdStr << " released" << std::endl;
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputHandlerGame::mouseMoved(const OIS::MouseEvent &e)
+  {
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputHandlerGame::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseReleased Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputHandlerGame::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    return true;
+  }
+
+  /**
+    @brief Calls all the objects from classes that derive from InputEventListener.
+    @param evt The input event that occured.
+  */
+  inline void InputHandlerGame::callListeners(orxonox::InputEvent &evt)
+  {
+    for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; )
+    {
+      if (it->bActive_)
+        (it++)->eventOccured(evt);
+      else
+        it++;
+    }
+  }
+
+
+  // ###############################
+  // ###     InputHandlerGUI     ###
+  // ###############################
+
+  /**
+    @brief standard constructor
+  */
+  InputHandlerGUI::InputHandlerGUI()
+  {
+  }
+
+  /**
+    @brief Destructor
+  */
+  InputHandlerGUI::~InputHandlerGUI()
+  {
+  }
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputHandlerGUI::keyPressed(const OIS::KeyEvent &e)
+  {
+		//CEGUI::System::getSingleton().injectKeyDown( arg.key );
+		//CEGUI::System::getSingleton().injectChar( arg.text );
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputHandlerGUI::keyReleased(const OIS::KeyEvent &e)
+  {
+		//CEGUI::System::getSingleton().injectKeyUp( arg.key );
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputHandlerGUI::mouseMoved(const OIS::MouseEvent &e)
+  {
+		//CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @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;
+  }
+
+}
Index: code/trunk/src/orxonox/core/InputHandler.h
===================================================================
--- code/trunk/src/orxonox/core/InputHandler.h	(revision 1024)
+++ code/trunk/src/orxonox/core/InputHandler.h	(revision 1024)
@@ -0,0 +1,110 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Different definitions of input processing.
+ */
+
+#ifndef _InputHandler_H__
+#define _InputHandler_H__
+
+#include <string>
+
+#include <OIS/OIS.h>
+
+#include "CorePrereqs.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Captures mouse and keyboard input while in the actual game mode.
+    Manages the key bindings.
+  */
+  class _CoreExport InputHandlerGame
+        : public OIS::KeyListener, public OIS::MouseListener
+  {
+  public:
+    InputHandlerGame ();
+    ~InputHandlerGame();
+
+    bool loadBindings();
+
+  private:
+    // input events
+		bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+    bool mouseMoved   (const OIS::MouseEvent &arg);
+		bool keyPressed   (const OIS::KeyEvent   &arg);
+		bool keyReleased  (const OIS::KeyEvent   &arg);
+
+    // temporary hack
+    void callListeners(InputEvent &evt);
+
+    /** denotes the maximum number of different keys there are in OIS.
+        256 should be ok since the highest number in the enum is 237. */
+    static const int numberOfKeys_s = 256;
+    //! Array of input events for every pressed key
+    std::string bindingsKeyPressed_[numberOfKeys_s];
+    //! Array of input events for every released key
+    std::string bindingsKeyReleased_[numberOfKeys_s];
+
+    /** denotes the maximum number of different buttons there are in OIS.
+        16 should be ok since the highest number in the enum is 7. */
+    static const int numberOfButtons_s = 16;
+    //! Array of input events for every pressed key
+    std::string bindingsButtonPressed_[numberOfButtons_s];
+    //! Array of input events for every released key
+    std::string bindingsButtonReleased_[numberOfButtons_s];
+
+  };
+
+
+  /**
+    @brief Captures mouse and keyboard input and distributes it to the
+    GUI.
+  */
+  class _CoreExport InputHandlerGUI
+        : public OIS::KeyListener, public OIS::MouseListener
+  {
+  public:
+    InputHandlerGUI ();
+    ~InputHandlerGUI();
+
+  private:
+    // input events
+		bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+		bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
+    bool mouseMoved   (const OIS::MouseEvent &arg);
+		bool keyPressed   (const OIS::KeyEvent   &arg);
+		bool keyReleased  (const OIS::KeyEvent   &arg);
+  };
+
+}
+
+#endif /* _InputHandler_H__ */
Index: code/trunk/src/orxonox/core/InputManager.cc
===================================================================
--- code/trunk/src/orxonox/core/InputManager.cc	(revision 1024)
+++ code/trunk/src/orxonox/core/InputManager.cc	(revision 1024)
@@ -0,0 +1,244 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of a little Input handler that distributes everything
+        coming from OIS.
+ */
+
+#include "core/CoreIncludes.h"
+#include "core/Debug.h"
+#include "InputEventListener.h"
+#include "InputHandler.h"
+#include "InputManager.h"
+
+namespace orxonox
+{
+  /**
+    @brief The reference to the singleton
+  */
+  InputManager* InputManager::singletonRef_s = 0;
+
+  /**
+    @brief Constructor only resets the pointer values to 0.
+  */
+  InputManager::InputManager() :
+      mouse_(0), keyboard_(0), inputSystem_(0),
+      currentMode_(IM_UNINIT), setMode_(IM_UNINIT),
+      handlerGUI_(0), handlerGame_(0), handlerBuffer_(0)
+  {
+  }
+
+  /**
+    @brief Destructor only called at the end of the program
+  */
+  InputManager::~InputManager()
+  {
+    this->destroyDevices();
+  }
+
+  /**
+    @brief The one instance of the InputManager is stored in this function.
+    @return The pointer to the only instance of the InputManager
+  */
+  InputManager *InputManager::getSingleton()
+  {
+    if (!singletonRef_s)
+      singletonRef_s = new InputManager();
+    return singletonRef_s;
+  }
+
+  /**
+    @brief Creates the OIS::InputMananger, the keyboard and the mouse and
+           assigns the key bindings.
+    @param windowHnd The window handle of the render window
+    @param windowWidth The width of the render window
+    @param windowHeight The height of the render window
+  */
+  bool InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight)
+  {
+    if (!this->inputSystem_)
+    {
+      // Setup basic variables
+      OIS::ParamList paramList;
+      std::ostringstream windowHndStr;
+
+      // Fill parameter list
+      windowHndStr << (unsigned int)windowHnd;
+      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+
+#if defined OIS_LINUX_PLATFORM
+      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+#endif
+
+      try
+      {
+        // Create inputsystem
+        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+        COUT(ORX_DEBUG) << "*** InputManager: Created OIS input system" << std::endl;
+
+        // create a keyboard. If none are available the exception is caught.
+        keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
+        COUT(ORX_DEBUG) << "*** InputManager: Created OIS mouse" << std::endl;
+
+        // create a mouse. If none are available the exception is caught.
+        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+        COUT(ORX_DEBUG) << "*** InputManager: Created OIS keyboard" << std::endl;
+
+        // Set mouse region
+        this->setWindowExtents(windowWidth, windowHeight);
+      }
+      catch (OIS::Exception ex)
+      {
+        // something went wrong with the initialisation
+        COUT(ORX_ERROR) << "Error: Failed creating an input system/keyboard/mouse. Message: \"" << ex.eText << "\"" << std::endl;
+        this->inputSystem_ = 0;
+        return false;
+      }
+    }
+
+    // create the handlers
+    this->handlerGUI_ = new InputHandlerGUI();
+    this->handlerGame_ = new InputHandlerGame();
+    this->handlerGame_->loadBindings();
+
+    /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl;
+    // load the key bindings
+    InputEvent empty = {0, false, 0, 0, 0};
+    for (int i = 0; i < this->numberOfKeys_; i++)
+      this->bindingsKeyPressed_[i] = empty;
+
+    //assign 'abort' to the escape key
+    this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1;
+    COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/
+
+    return true;
+  }
+
+  /**
+    @brief Destroys all the created input devices.
+  */
+  void InputManager::destroyDevices()
+  {
+    COUT(ORX_DEBUG) << "*** InputManager: Destroying InputManager..." << std::endl;
+    if (this->mouse_)
+      this->inputSystem_->destroyInputObject(mouse_);
+    if (this->keyboard_)
+      this->inputSystem_->destroyInputObject(keyboard_);
+    if (this->inputSystem_)
+      OIS::InputManager::destroyInputSystem(this->inputSystem_);
+
+    this->mouse_         = 0;
+    this->keyboard_      = 0;
+    this->inputSystem_   = 0;
+    COUT(ORX_DEBUG) << "*** InputManager: Destroying done." << std::endl;
+  }
+
+  /**
+    @brief Destroys the singleton.
+  */
+  void InputManager::destroySingleton()
+  {
+    if (singletonRef_s)
+      delete singletonRef_s;
+    singletonRef_s = 0;
+  }
+
+  /**
+    @brief Updates the InputManager
+    @param dt Delta time
+  */
+  void InputManager::tick(float dt)
+  {
+    // reset the game if it has changed
+    if (this->currentMode_ != this->setMode_)
+    {
+      switch (this->setMode_)
+      {
+      case IM_GUI:
+        this->mouse_->setEventCallback(this->handlerGUI_);
+        this->keyboard_->setEventCallback(this->handlerGUI_);
+        break;
+      case IM_INGAME:
+        this->mouse_->setEventCallback(this->handlerGame_);
+        this->keyboard_->setEventCallback(this->handlerGame_);
+        break;
+      case IM_KEYBOARD:
+        this->mouse_->setEventCallback(this->handlerGame_);
+        this->keyboard_->setEventCallback(this->handlerBuffer_);
+        break;
+      case IM_UNINIT:
+        this->mouse_->setEventCallback(0);
+        this->keyboard_->setEventCallback(0);
+        break;
+      }
+      this->currentMode_ = this->setMode_;
+    }
+
+    // capture all the input. That calls the event handlers.
+    if (mouse_)
+      mouse_->capture();
+
+    if (keyboard_)
+      keyboard_->capture();
+  }
+
+  /**
+    @brief Adjusts the mouse window metrics.
+    This method has to be called every time the size of the window changes.
+    @param width The new width of the render window
+    @param height the new height of the render window
+  */
+  void InputManager::setWindowExtents(int width, int height)
+  {
+    // Set mouse region (if window resizes, we should alter this to reflect as well)
+    const OIS::MouseState &mouseState = mouse_->getMouseState();
+    mouseState.width  = width;
+    mouseState.height = height;
+  }
+
+  /**
+    @brief Sets the input mode to either GUI, inGame or Buffer
+    @param mode The new input mode
+    @remark Only has an affect if the mode actually changes
+  */
+  void InputManager::setInputMode(InputMode mode)
+  {
+    this->setMode_ = mode;
+  }
+
+  /**
+    @brief Returns the current input handling method
+    @return The current input mode.
+  */
+  InputMode InputManager::getInputMode()
+  {
+    return this->currentMode_;
+  }
+
+}
Index: code/trunk/src/orxonox/core/InputManager.h
===================================================================
--- code/trunk/src/orxonox/core/InputManager.h	(revision 1024)
+++ code/trunk/src/orxonox/core/InputManager.h	(revision 1024)
@@ -0,0 +1,105 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of a little Input handler that distributes everything
+        coming from OIS.
+ */
+
+#ifndef _InputManager_H__
+#define _InputManager_H__
+
+#include <OIS/OIS.h>
+
+#include "CorePrereqs.h"
+#include "core/Tickable.h"
+#include "InputEvent.h"
+
+namespace orxonox
+{
+  /**
+    @brief Designates the way input is handled currently.
+    IM_GUI:      All the OIS input events are passed to CEGUI
+    IM_KEYBOARD: Only keyboard input is captured and passed to the InputBuffer
+    IM_INGAME:   Normal game mode. Key bindings and mouse are active.
+  */
+  enum InputMode
+  {
+    IM_GUI      = 0,
+    IM_KEYBOARD = 1,
+    IM_INGAME   = 2,
+    IM_UNINIT   = 3,
+  };
+
+  /**
+    @brief Captures and distributes mouse and keyboard input.
+    It resolves the key bindings to InputEvents which can be heard by
+    implementing the InputEventListener interface.
+  */
+  class _CoreExport InputManager
+        : public Tickable
+  {
+  public:
+    bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
+    void destroyDevices();
+    void tick(float dt);
+    void setWindowExtents(int width, int height);
+    void setInputMode(InputMode mode);
+    InputMode getInputMode();
+
+    // Temporary solutions. Will be removed soon!
+    OIS::Mouse    *getMouse()    { return this->mouse_   ; }
+    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
+
+    static InputManager* getSingleton();
+    static void destroySingleton();
+
+  private:
+    // don't mess with a Singleton
+    InputManager ();
+    InputManager (const InputManager&);
+    InputManager& operator=(const InputManager& instance);
+    ~InputManager();
+
+    OIS::InputManager *inputSystem_;    //!< OIS input manager
+    OIS::Keyboard     *keyboard_;       //!< OIS mouse
+    OIS::Mouse        *mouse_;          //!< OIS keyboard
+
+    InputMode          currentMode_;    //!< Input mode currently used
+    InputMode          setMode_;        //!< Input mode that has been set lately
+    InputHandlerGUI   *handlerGUI_;     //!< Handles the input if in GUI mode
+    // FIXME: insert the InputBuffer once merged with core2
+    InputHandlerGUI   *handlerBuffer_;  //!< Handles the input if in Buffer mode
+    InputHandlerGame  *handlerGame_;    //!< Handles the input if in Game mode
+
+    //! Pointer to the instance of the singleton
+    static InputManager *singletonRef_s;
+  };
+}
+
+#endif /* _InputManager_H__ */
Index: code/trunk/src/orxonox/core/MetaObjectList.h
===================================================================
--- code/trunk/src/orxonox/core/MetaObjectList.h	(revision 1021)
+++ code/trunk/src/orxonox/core/MetaObjectList.h	(revision 1024)
@@ -113,5 +113,5 @@
         This allows much faster deletion of objects because no iteration is needed.
     */
-    class MetaObjectList
+    class _CoreExport MetaObjectList
     {
         public:
Index: code/trunk/src/orxonox/core/Script.cc
===================================================================
--- code/trunk/src/orxonox/core/Script.cc	(revision 1021)
+++ code/trunk/src/orxonox/core/Script.cc	(revision 1024)
@@ -38,6 +38,6 @@
 }
 
-#include "tolua++.h"
-#include "../../util/tolua/tolua_bind.h"
+#include "util/tolua/tolua++.h"
+#include "util/tolua/tolua_bind.h"
 
 namespace orxonox
@@ -57,5 +57,5 @@
   {
     output_ += str;
-    COUT(0) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
+    COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
   }
 
@@ -89,5 +89,5 @@
 
     if (luaTags) luaSource_ = replaceLuaTags(levelString);
-    COUT(0) << "ParsedSourceCode: " << luaSource_ << std::endl;
+    COUT(4) << "ParsedSourceCode: " << luaSource_ << std::endl;
   }
 
@@ -100,5 +100,5 @@
     if (error == 0)
       error = lua_pcall(luaState_, 0, 0, 0);
-    if (error != 0) COUT(0) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl;
+    if (error != 0) COUT(2) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl;
   }
 
Index: code/trunk/src/orxonox/core/Tickable.h
===================================================================
--- code/trunk/src/orxonox/core/Tickable.h	(revision 1021)
+++ code/trunk/src/orxonox/core/Tickable.h	(revision 1024)
@@ -46,6 +46,4 @@
 namespace orxonox
 {
-    //class TickFrameListener; // Forward declaration
-
     //! The Tickable interface provides a tick(dt) function, that gets called every frame.
     class _CoreExport Tickable : virtual public OrxonoxClass
