Index: code/branches/input/src/core/CMakeLists.txt
===================================================================
--- code/branches/input/src/core/CMakeLists.txt	(revision 1118)
+++ code/branches/input/src/core/CMakeLists.txt	(revision 1154)
@@ -1,6 +1,3 @@
-#get the created files
-AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES) 
-
-SET( CORE_SRC_FILES
+SET(CORE_SRC_FILES
   OrxonoxClass.cc
   BaseObject.cc
@@ -29,13 +26,30 @@
   Tickable.cc
   Script.cc
-  ${TOLUA_BIND_FILES}
+  tolua/tolua_bind.cc
+#tolua/tolua_bind.h
 )
 
-ADD_LIBRARY( core SHARED ${CORE_SRC_FILES})
+#SET_SOURCE_FILES_PROPERTIES(tolua/tolua_bind.h
+#  PROPERTIES
+#  OBJECT_DEPENDS tolua/tolua_bind.h
+#  OBJECT_DEPENDS tolua/tolua_bind.cc
+#  GENERATED true
+#  HEADER_FILE_ONLY true
+#)
 
-TARGET_LINK_LIBRARIES( core
+GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h
+  COMMAND ${TOLUA_EXE} -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg
+  DEPENDS tolua
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
+ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES(core
+  ${Lua_LIBRARIES}
+  ${OIS_LIBRARIES}
+  ${OGRE_LIBRARIES}
   util
-  ${Lua_LIBRARIES}
-  ${Lua_LIBRARY}
-  ${OIS_LIBRARIES}
 )
Index: code/branches/input/src/core/ConfigFileManager.h
===================================================================
--- code/branches/input/src/core/ConfigFileManager.h	(revision 1118)
+++ code/branches/input/src/core/ConfigFileManager.h	(revision 1154)
@@ -63,4 +63,5 @@
     {
         public:
+            virtual ~ConfigFileEntry() {};
             virtual void setValue(const std::string& value) = 0;
             virtual std::string getValue() const = 0;
Index: code/branches/input/src/core/InputManager.cc
===================================================================
--- code/branches/input/src/core/InputManager.cc	(revision 1118)
+++ code/branches/input/src/core/InputManager.cc	(revision 1154)
@@ -125,16 +125,8 @@
     // create the handlers
     this->handlerGUI_ = new InputHandlerGUI();
+    this->handlerGUI_->initialise();
     this->handlerGame_ = new InputHandlerGame();
-    //this->handlerBuffer_ = new InputBuffer();
-    this->handlerGame_->loadBindings();
-
-    /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl;
-    // load the key bindings
-    InputEvent empty = {0, false, 0, 0, 0};
-    for (int i = 0; i < this->numberOfKeys_; i++)
-      this->bindingsKeyPressed_[i] = empty;
-
-    //assign 'abort' to the escape key
-    this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1;
+    this->handlerGame_->initialise();
+
     COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/
 
@@ -159,6 +151,4 @@
     this->inputSystem_   = 0;
 
-    if (this->handlerBuffer_)
-      delete this->handlerBuffer_;
     if (this->handlerGame_)
       delete this->handlerGame_;
@@ -166,5 +156,4 @@
       delete this->handlerGUI_;
 
-    this->handlerBuffer_ = 0;
     this->handlerGame_   = 0;
     this->handlerGUI_    = 0;
@@ -192,8 +181,4 @@
         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);
@@ -211,4 +196,5 @@
 
     // Give the listeners the chance to do additional calculations
+    this->currentHandler_->tick(dt);
   }
 
Index: code/branches/input/src/core/InputManager.h
===================================================================
--- code/branches/input/src/core/InputManager.h	(revision 1118)
+++ code/branches/input/src/core/InputManager.h	(revision 1154)
@@ -51,11 +51,4 @@
     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,
-  };
 
   /**
@@ -83,5 +76,6 @@
     static InputManager& getSingleton();
     static InputManager* getSingletonPtr() { return &getSingleton(); }
-    static void setInputMode(int mode);
+
+    static void setInputHandler(std::string& name);
 
   private:
@@ -95,13 +89,9 @@
     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
-    InputBuffer       *handlerBuffer_;  //!< Handles the input if in Buffer mode
-    InputHandlerGame  *handlerGame_;    //!< Handles the input if in Game mode
+    BaseInputHandler* currentHandler_;
+    BaseInputHandler* switchToHandler_;
+    //! Maps the names of the input handlers to their instance
+    std::map<std::string, BaseInputHandler*> handlers_;
 
-    //! Pointer to the instance of the singleton
-    //static InputManager *singletonRef_s;
   };
 }
Index: code/branches/input/src/core/Loader.cc
===================================================================
--- code/branches/input/src/core/Loader.cc	(revision 1118)
+++ code/branches/input/src/core/Loader.cc	(revision 1154)
@@ -115,7 +115,7 @@
         Script::init(Script::getLuaState());
         Script::run();*/
-        //Script* lua = Script::getInstance();
-        //lua->loadFile(level->getFile(), true);
-        //lua->run();
+        Script* lua = Script::getInstance();
+        lua->loadFile(level->getFile(), true);
+        lua->run();
 
         try
@@ -124,10 +124,10 @@
             COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
 
-            ticpp::Document xmlfile(level->getFile());
-            xmlfile.LoadFile();
+            //ticpp::Document xmlfile(level->getFile());
+            //xmlfile.LoadFile();
             //ticpp::Element myelement(*Script::getFileString());
-            //ticpp::Document xmlfile;
-            xmlfile.ToDocument();
-            //xmlfile.Parse(lua->getLuaOutput(), true);
+            ticpp::Document xmlfile;
+            //xmlfile.ToDocument();
+            xmlfile.Parse(lua->getLuaOutput(), true);
 
             ticpp::Element rootElement;
Index: code/branches/input/src/core/Script.cc
===================================================================
--- code/branches/input/src/core/Script.cc	(revision 1118)
+++ code/branches/input/src/core/Script.cc	(revision 1154)
@@ -60,5 +60,5 @@
     luaopen_debug(luaState_);
 #endif
-    tolua_orxonox_open(luaState_);
+    tolua_core_open(luaState_);
     output_ = "";
   }
@@ -102,4 +102,14 @@
   }
 
+#if LUA_VERSION_NUM != 501
+  const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size)
+  {
+    LoadS* ls = ((LoadS*)data);
+    if (ls->size == 0) return NULL;
+    *size = ls->size;
+    ls->size = 0;
+    return ls->s;
+  }
+#endif
   void Script::run()
   {
@@ -110,5 +120,8 @@
     error = luaL_loadstring(luaState_, init.c_str());
 #else
-    error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, (void*)init.c_str(), "init");
+    LoadS ls;
+    ls.s = init.c_str();
+    ls.size = init.size();
+    error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str());
 #endif
     if (error == 0)
Index: code/branches/input/src/core/Script.h
===================================================================
--- code/branches/input/src/core/Script.h	(revision 1118)
+++ code/branches/input/src/core/Script.h	(revision 1154)
@@ -50,4 +50,9 @@
   class _CoreExport Script // tolua_export
   { // tolua_export
+    struct LoadS {
+      const char *s;
+      size_t size;
+    };
+
     public:
       inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
@@ -61,5 +66,5 @@
 
 #if LUA_VERSION_NUM != 501
-    inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
+    static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
 #endif
 
