Index: code/branches/input/src/core/CMakeLists.txt
===================================================================
--- code/branches/input/src/core/CMakeLists.txt	(revision 1510)
+++ code/branches/input/src/core/CMakeLists.txt	(revision 1519)
@@ -10,8 +10,5 @@
   Identifier.cc
   IdentifierDistributor.cc
-  InputManager.cc
-  KeyBinder.cc
   OutputBuffer.cc
-  InputBuffer.cc
   Shell.cc
   CommandExecutor.cc
@@ -34,4 +31,7 @@
   TclThreadManager.cc
   IRC.cc
+  input/InputBuffer.cc
+  input/InputManager.cc
+  input/KeyBinder.cc
   tolua/tolua_bind.cc
 )
Index: code/branches/input/src/core/InputBuffer.cc
===================================================================
--- code/branches/input/src/core/InputBuffer.cc	(revision 1510)
+++ 	(revision )
@@ -1,257 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Reto Grieder
- *
- */
-
-#include "InputBuffer.h"
-
-#include <iostream>
-
-#include "util/Clipboard.h"
-#include "CoreIncludes.h"
-#include "ConfigValueIncludes.h"
-
-namespace orxonox
-{
-    InputBuffer::InputBuffer()
-    {
-        RegisterObject(InputBuffer);
-
-        this->buffer_ = "";
-        this->cursor_ = 0;
-        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
-                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
-                               äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
-                               0123456789 \
-                               \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
-
-        this->lastKey_ = KeyCode::Unassigned;
-        this->timeSinceKeyPressed_ = 0.0f;
-        this->timeSinceKeyRepeated_ = 0.0f;
-        this->keysToRepeat_ = 0;
-
-        setConfigValues();
-    }
-
-    InputBuffer::InputBuffer(const std::string allowedChars)
-    {
-        RegisterObject(InputBuffer);
-
-        this->allowedChars_ = allowedChars;
-        this->buffer_ = "";
-        this->cursor_ = 0;
-
-        this->lastKey_ = KeyCode::Unassigned;
-        this->timeSinceKeyPressed_ = 0.0f;
-        this->timeSinceKeyRepeated_ = 0.0f;
-        this->keysToRepeat_ = 0;
-
-        setConfigValues();
-    }
-
-    void InputBuffer::setConfigValues()
-    {
-        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
-        SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
-
-        if (keyRepeatDeleay_ < 0.0)
-        {
-            ResetConfigValue(keyRepeatDeleay_);
-        }
-        if (keyRepeatTime_ < 0.0)
-        {
-            ResetConfigValue(keyRepeatTime_);
-        }
-    }
-
-    void InputBuffer::set(const std::string& input, bool update)
-    {
-        this->clear(false);
-        this->insert(input, update);
-    }
-
-    void InputBuffer::insert(const std::string& input, bool update)
-    {
-        for (unsigned int i = 0; i < input.size(); ++i)
-        {
-            this->insert(input[i], false);
-
-            if (update)
-                this->updated(input[i], false);
-        }
-
-        if (update)
-            this->updated();
-    }
-
-    void InputBuffer::insert(const char& input, bool update)
-    {
-        if (this->charIsAllowed(input))
-        {
-            this->buffer_.insert(this->cursor_, 1, input);
-            ++this->cursor_;
-        }
-
-        if (update)
-            this->updated(input, true);
-    }
-
-    void InputBuffer::clear(bool update)
-    {
-        this->buffer_ = "";
-        this->cursor_ = 0;
-
-        if (update)
-            this->updated();
-    }
-
-    void InputBuffer::removeBehindCursor(bool update)
-    {
-        if (this->cursor_ > 0)
-        {
-            --this->cursor_;
-            this->buffer_.erase(this->cursor_, 1);
-
-            if (update)
-                this->updated();
-        }
-    }
-
-    void InputBuffer::removeAtCursor(bool update)
-    {
-        if (this->cursor_ < this->buffer_.size())
-        {
-            this->buffer_.erase(this->cursor_, 1);
-
-            if (update)
-                this->updated();
-        }
-    }
-
-    void InputBuffer::updated()
-    {
-        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->bListenToAllChanges_)
-                (*it)->callFunction();
-        }
-    }
-
-    void InputBuffer::updated(const char& update, bool bSingleInput)
-    {
-        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))
-                (*it)->callFunction();
-        }
-    }
-
-    bool InputBuffer::charIsAllowed(const char& input)
-    {
-        if (this->allowedChars_ == "")
-            return true;
-        else
-            return (this->allowedChars_.find(input) != std::string::npos);
-    }
-
-
-    void InputBuffer::processKey(const KeyEvent &evt)
-    {
-        if (evt.isModifierDown(KeyboardModifier::Alt) && evt.key == KeyCode::Tab)
-            return;
-
-        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-        {
-            if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key))
-                (*it)->callFunction();
-        }
-
-        if (evt.isModifierDown(KeyboardModifier::Ctrl))
-        {
-            if (evt.key == KeyCode::V)
-                this->insert(fromClipboard());
-            else if (evt.key == KeyCode::C)
-                toClipboard(this->buffer_);
-            else if (evt.key == KeyCode::X)
-            {
-                toClipboard(this->buffer_);
-                this->clear();
-            }
-        }
-        else if (evt.isModifierDown(KeyboardModifier::Shift))
-        {
-            if (evt.key == KeyCode::Insert)
-                this->insert(fromClipboard());
-            else if (evt.key == KeyCode::Delete)
-            {
-                toClipboard(this->buffer_);
-                this->clear();
-            }
-        }
-
-        this->insert((char)evt.text);
-    }
-
-    /**
-        @brief This tick() function is called by the InputManager if the InputBuffer is active.
-        @param dt Delta time
-    */
-    void InputBuffer::tickInput(float dt, const HandlerState& state)
-    {
-        timeSinceKeyPressed_ += dt;
-        if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
-        {
-            // initial time out has gone by, start repeating keys
-            while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
-            {
-                timeSinceKeyRepeated_ += keyRepeatTime_;
-                keysToRepeat_++;
-            }
-        }
-    }
-
-    void InputBuffer::keyPressed(const KeyEvent &evt)
-    {
-        lastKey_ = evt.key;
-        timeSinceKeyPressed_ = 0.0;
-        timeSinceKeyRepeated_ = keyRepeatDeleay_;
-        keysToRepeat_ = 0;
-
-        processKey(evt);
-    }
-
-    void InputBuffer::keyHeld(const KeyEvent& evt)
-    {
-        if (evt.key == lastKey_)
-        {
-            while (keysToRepeat_)
-            {
-                processKey(evt);
-                keysToRepeat_--;
-            }
-        }
-    }
-}
Index: code/branches/input/src/core/InputBuffer.h
===================================================================
--- code/branches/input/src/core/InputBuffer.h	(revision 1510)
+++ 	(revision )
@@ -1,189 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      Reto Grieder
- *
- */
-
-#ifndef _InputBuffer_H__
-#define _InputBuffer_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include <list>
-
-#include "InputInterfaces.h"
-#include "OrxonoxClass.h"
-
-namespace orxonox
-{
-    class BaseInputBufferListenerTuple
-    {
-    public:
-        BaseInputBufferListenerTuple(bool bListenToAllChanges, bool bOnlySingleInput,
-            bool trueKeyFalseChar, char _char, KeyCode::Enum key)
-            : bListenToAllChanges_(bListenToAllChanges), bOnlySingleInput_(bOnlySingleInput),
-              trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key)
-        { }
-        virtual ~BaseInputBufferListenerTuple() { }
-        virtual void callFunction() = 0;
-        bool bListenToAllChanges_;
-        bool bOnlySingleInput_;
-        bool trueKeyFalseChar_;
-        char char_;
-        KeyCode::Enum key_;
-    };
-
-    template <class T>
-    class InputBufferListenerTuple : public BaseInputBufferListenerTuple
-    {
-    public:
-        InputBufferListenerTuple(T* listener, void (T::*function)(), bool bListenToAllChanges,
-            bool bOnlySingleInput, bool trueKeyFalseChar, char _char, KeyCode::Enum key)
-            : BaseInputBufferListenerTuple(bListenToAllChanges, bOnlySingleInput, trueKeyFalseChar, _char, key),
-              listener_(listener), function_(function)
-        { }
-        virtual ~InputBufferListenerTuple() { }
-        void callFunction()
-        {
-            (listener_->*function_)();
-        }
-        T* listener_;
-        void (T::*function_)();
-    };
-
-    class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
-    {
-        public:
-            InputBuffer();
-            InputBuffer(const std::string allowedChars);
-
-            void setConfigValues();
-
-            template <class T>
-            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-
-            template <class T>
-            void registerListener(T* listener, void (T::*function)(), KeyCode::Enum key)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-            template <class T>
-            void registerListener(T* listener, void (T::*function)() const, KeyCode::Enum key)
-            {
-                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
-                this->listeners_.insert(this->listeners_.end(), newTuple);
-            }
-
-            template <class T>
-            void unregisterListener(T* listener)
-            {
-                for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
-                {
-                    InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
-                    if (refListener && refListener->listener_ == listener)
-                        this->listeners_.erase(it++);
-                    else
-                        it++;
-                }
-            }
-
-            void set(const std::string& input, bool update = true);
-            void insert(const std::string& input, bool update = true);
-            void insert(const char& input, bool update = true);
-            void clear(bool update = true);
-            void removeAtCursor(bool update = true);
-            void removeBehindCursor(bool update = true);
-
-            void updated();
-            void updated(const char& update, bool bSingleInput);
-
-            inline std::string get() const
-                { return this->buffer_; }
-            inline unsigned int getSize() const
-                { return this->buffer_.size(); }
-
-            inline unsigned int getCursorPosition() const
-                { return this->cursor_; }
-            inline void setCursorPosition(unsigned int cursor)
-                { if (cursor <= this->buffer_.size()) { this->cursor_ = cursor; } }
-            inline void setCursorToEnd()
-                { this->cursor_ = this->buffer_.size(); }
-            inline void setCursorToBegin()
-                { this->cursor_ = 0; }
-            inline void increaseCursor()
-                { if (this->cursor_ < this->buffer_.size()) { ++this->cursor_; } }
-            inline void decreaseCursor()
-                { if (this->cursor_ > 0) { --this->cursor_; } }
-
-        private:
-            bool charIsAllowed(const char& input);
-
-            void keyPressed (const KeyEvent& evt);
-            void keyReleased(const KeyEvent& evt) { }
-            void keyHeld    (const KeyEvent& evt);
-            void processKey (const KeyEvent &e);
-
-            void tickInput(float dt, const HandlerState& state);
-
-            std::string buffer_;
-            std::list<BaseInputBufferListenerTuple*> listeners_;
-            std::string allowedChars_;
-            unsigned int cursor_;
-
-            KeyCode::Enum lastKey_;
-            float timeSinceKeyPressed_;
-            float timeSinceKeyRepeated_;
-            int keysToRepeat_;
-
-            float keyRepeatDeleay_;
-            float keyRepeatTime_;
-    };
-}
-
-#endif /* _InputBuffer_H__ */
Index: code/branches/input/src/core/InputInterfaces.h
===================================================================
--- code/branches/input/src/core/InputInterfaces.h	(revision 1510)
+++ 	(revision )
@@ -1,322 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- @brief Declarations of various interface classes for the input management.
-*/
-
-#ifndef _InputInterfaces_H__
-#define _InputInterfaces_H__
-
-#include "CorePrereqs.h"
-
-#include "ois/OIS.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
-  namespace KeyCode
-  {
-    // note: KeyCode comments were directly taken from OISKeyboard.h
-    enum Enum
-    {
-      Unassigned    = OIS::KC_UNASSIGNED,  
-      Escape        = OIS::KC_ESCAPE,      
-      NumRow1       = OIS::KC_1,           
-      NumRow2       = OIS::KC_2,           
-      NumRow3       = OIS::KC_3,           
-      NumRow4       = OIS::KC_4,           
-      NumRow5       = OIS::KC_5,           
-      NumRow6       = OIS::KC_6,           
-      NumRow7       = OIS::KC_7,           
-      NumRow8       = OIS::KC_8,           
-      NumRow9       = OIS::KC_9,           
-      NumRow0       = OIS::KC_0,           
-      Minus         = OIS::KC_MINUS,           // - on main keyboard
-      Equals        = OIS::KC_EQUALS,      
-      Back          = OIS::KC_BACK,            // backspace
-      Tab           = OIS::KC_TAB,         
-      Q             = OIS::KC_Q,           
-      W             = OIS::KC_W,           
-      E             = OIS::KC_E,           
-      R             = OIS::KC_R,           
-      T             = OIS::KC_T,           
-      Y             = OIS::KC_Y,           
-      U             = OIS::KC_U,           
-      I             = OIS::KC_I,           
-      O             = OIS::KC_O,           
-      P             = OIS::KC_P,           
-      LeftBracket   = OIS::KC_LBRACKET,    
-      RightBracket  = OIS::KC_RBRACKET,    
-      Return        = OIS::KC_RETURN,          // Enter on main keyboard
-      LeftControl   = OIS::KC_LCONTROL,    
-      A             = OIS::KC_A,           
-      S             = OIS::KC_S,           
-      D             = OIS::KC_D,           
-      F             = OIS::KC_F,           
-      G             = OIS::KC_G,           
-      H             = OIS::KC_H,           
-      J             = OIS::KC_J,           
-      K             = OIS::KC_K,           
-      L             = OIS::KC_L,           
-      Semicolon     = OIS::KC_SEMICOLON,   
-      Apostrophe    = OIS::KC_APOSTROPHE,  
-      Grave         = OIS::KC_GRAVE,           // accent
-      LeftShift     = OIS::KC_LSHIFT,      
-      Backslash     = OIS::KC_BACKSLASH,   
-      Z             = OIS::KC_Z,           
-      X             = OIS::KC_X,           
-      C             = OIS::KC_C,           
-      V             = OIS::KC_V,           
-      B             = OIS::KC_B,           
-      N             = OIS::KC_N,           
-      M             = OIS::KC_M,           
-      Comma         = OIS::KC_COMMA,       
-      Period        = OIS::KC_PERIOD,          // . on main keyboard
-      Slash         = OIS::KC_SLASH,           // / on main keyboard
-      RightShift    = OIS::KC_RSHIFT,      
-      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
-      LeftAlt       = OIS::KC_LMENU,           // left Alt
-      Space         = OIS::KC_SPACE,       
-      CapsLock      = OIS::KC_CAPITAL,     
-      F1            = OIS::KC_F1,          
-      F2            = OIS::KC_F2,          
-      F3            = OIS::KC_F3,          
-      F4            = OIS::KC_F4,          
-      F5            = OIS::KC_F5,          
-      F6            = OIS::KC_F6,          
-      F7            = OIS::KC_F7,          
-      F8            = OIS::KC_F8,          
-      F9            = OIS::KC_F9,          
-      F10           = OIS::KC_F10,         
-      Numlock       = OIS::KC_NUMLOCK,     
-      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
-      Numpad7       = OIS::KC_NUMPAD7,     
-      Numpad8       = OIS::KC_NUMPAD8,     
-      Numpad9       = OIS::KC_NUMPAD9,     
-      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
-      Numpad4       = OIS::KC_NUMPAD4,     
-      Numpad5       = OIS::KC_NUMPAD5,     
-      Numpad6       = OIS::KC_NUMPAD6,     
-      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
-      Numpad1       = OIS::KC_NUMPAD1,     
-      Numpad2       = OIS::KC_NUMPAD2,     
-      Numpad3       = OIS::KC_NUMPAD3,     
-      Numpad0       = OIS::KC_NUMPAD0,     
-      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
-      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
-      F11           = OIS::KC_F11,         
-      F12           = OIS::KC_F12,         
-      F13           = OIS::KC_F13,             //                     (NEC PC98)
-      F14           = OIS::KC_F14,             //                     (NEC PC98)
-      F15           = OIS::KC_F15,             //                     (NEC PC98)
-      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
-      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
-      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
-      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
-      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
-      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
-      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
-      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
-      AT            = OIS::KC_AT,              //                     (NEC PC98)
-      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
-      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
-      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
-      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
-      AX            = OIS::KC_AX,              //                     (Japan AX)
-      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
-      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
-      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
-      RightControl  = OIS::KC_RCONTROL,    
-      Mute          = OIS::KC_MUTE,            // Mute
-      Calculator    = OIS::KC_CALCULATOR,      // Calculator
-      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
-      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
-      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
-      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
-      WebHome       = OIS::KC_WEBHOME,         // Web home
-      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
-      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
-      SYSRQ         = OIS::KC_SYSRQ,       
-      RightAlt      = OIS::KC_RMENU,           // right Alt
-      Pause         = OIS::KC_PAUSE,           // Pause
-      Home          = OIS::KC_HOME,            // Home on arrow keypad
-      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
-      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
-      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
-      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
-      End           = OIS::KC_END,             // End on arrow keypad
-      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
-      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
-      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
-      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
-      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
-      RightWindows  = OIS::KC_RWIN,            // Right Windows key
-      Apps          = OIS::KC_APPS,            // AppMenu key
-      Power         = OIS::KC_POWER,           // System Power
-      Sleep         = OIS::KC_SLEEP,           // System Sleep
-      Wake          = OIS::KC_WAKE,            // System Wake
-      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
-      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
-      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
-      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
-      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
-      WebBack       = OIS::KC_WEBBACK,         // Web Back
-      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
-      Mail          = OIS::KC_MAIL,            // Mail
-      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
-    };
-  }
-
-  namespace MouseButton
-  {
-    enum Enum
-    {
-      Left    = OIS::MB_Left,
-      Right   = OIS::MB_Right,
-      Middle  = OIS::MB_Middle,
-      Button3 = OIS::MB_Button3,
-      Button4 = OIS::MB_Button4,
-      Button5 = OIS::MB_Button5,
-      Button6 = OIS::MB_Button6,
-      Button7 = OIS::MB_Button7
-    };
-  }
-
-  namespace KeyboardModifier
-  {
-    enum Enum
-    {
-      Shift = 0x0000001,
-      Ctrl  = 0x0000010,
-      Alt   = 0x0000100
-    };
-  }
-
-  struct _CoreExport Key
-  {
-    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
-    KeyCode::Enum key;
-    unsigned int text;
-  };
-
-  class _CoreExport KeyEvent
-  {
-  public:
-    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
-    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
-    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
-    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
-
-    const KeyCode::Enum key;
-    unsigned int text;
-    unsigned int modifiers;
-  };
-
-  //typedef OIS::MouseState MouseState;
-
-  /*class _CoreExport JoyStickState
-  {
-  public:
-    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
-    JoyStickState() { clear(); }
-    int mJoyStickID;
-		JoyStickState() { clear(); }
-
-		std::vector<bool> mButtons;
-		int axes[16];
-		std::vector<Vector3> mVectors;
-  };*/
-  
-  /**
-  * Helper struct to determine which handlers of an object (can implement
-  * multiple handlers) are active.
-  */
-  struct HandlerState
-  {
-    HandlerState() : key(false), mouse(false), joyStick(false) { }
-    bool key;
-    bool mouse;
-    bool joyStick;
-  };
-
-  class _CoreExport InputTickable
-  {
-  public:
-    virtual ~InputTickable() { }
-    virtual void tickInput(float dt, const HandlerState& state) = 0;
-  };
-
-  /**
-    @brief Interface class used for key input listeners.
-  */
-  class _CoreExport KeyHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~KeyHandler() { }
-    virtual void keyPressed (const KeyEvent& evt) = 0;
-    virtual void keyReleased(const KeyEvent& evt) = 0;
-    virtual void keyHeld    (const KeyEvent& evt) = 0;
-    //virtual void tickKey    (float dt) { }
-  };
-
-  /**
-    @brief Interface class used for mouse input listeners.
-  */
-  class _CoreExport MouseHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~MouseHandler() { }
-    virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
-    virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
-    virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
-    virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
-    virtual void mouseScrolled      (int abs, int rel)     = 0;
-    //virtual void tickMouse          (float dt) { }
-  };
-
-
-  /**
-    @brief Interface class used for joy stick input listeners.
-  */
-  class _CoreExport JoyStickHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~JoyStickHandler() { }
-    virtual void joyStickButtonPressed (int joyStickID, int button) = 0;
-    virtual void joyStickButtonReleased(int joyStickID, int button) = 0;
-    virtual void joyStickButtonHeld    (int joyStickID, int button) = 0;
-    virtual void joyStickAxisMoved     (int joyStickID, int axis, float value) = 0;
-    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
-    //virtual void tickJoyStick          (float dt) { }
-  };
-
-}
-
-#endif /* _InputInterfaces_H__ */
Index: code/branches/input/src/core/InputManager.cc
===================================================================
--- code/branches/input/src/core/InputManager.cc	(revision 1510)
+++ 	(revision )
@@ -1,1543 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-  @file
-  @brief Implementation of the InputManager that captures all the input from OIS
-         and redirects it to handlers.
- */
-
-#include "InputManager.h"
-#include "util/Convert.h"
-#include "CoreIncludes.h"
-#include "ConfigValueIncludes.h"
-#include "Debug.h"
-#include "InputBuffer.h"
-#include "KeyBinder.h"
-#include "CommandExecutor.h"
-#include "ConsoleCommand.h"
-#include "Shell.h"
-
-namespace orxonox
-{
-  SetConsoleCommandShortcut(InputManager, keyBind);
-  SetConsoleCommandShortcut(InputManager, storeKeyStroke);
-  SetConsoleCommandShortcut(InputManager, calibrate);
-
-  // ###############################
-  // ###    Internal Methods     ###
-  // ###############################
-  // ###############################
-
-  /**
-    @brief Constructor only sets member fields to initial zero values
-           and registers the class in the class hierarchy.
-  */
-  InputManager::InputManager() :
-      inputSystem_(0), keyboard_(0), mouse_(0),
-      joySticksSize_(0),
-      keyBinder_(0), keyDetector_(0), buffer_(0), calibratorCallback_(0),
-      state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT),
-      keyboardModifiers_(0)
-  {
-    RegisterObject(InputManager);
-  }
-
-  /**
-    @brief The one instance of the InputManager is stored in this function.
-    @return A reference to the only instance of the InputManager
-  */
-  InputManager& InputManager::_getSingleton()
-  {
-    static InputManager theOnlyInstance;
-    return theOnlyInstance;
-  }
-
-  /**
-    @brief Destructor only called at the end of the program, after main.
-  */
-  InputManager::~InputManager()
-  {
-    _destroy();
-  }
-
-  /**
-    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
-           the joysticks and assigns the key bindings.
-    @param windowHnd The window handle of the render window
-    @param windowWidth The width of the render window
-    @param windowHeight The height of the render window
-  */
-  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
-        bool createKeyboard, bool createMouse, bool createJoySticks)
-  {
-    if (state_ == IS_UNINIT)
-    {
-      CCOUT(3) << "Initialising Input System..." << std::endl;
-      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
-
-      OIS::ParamList paramList;
-      std::ostringstream windowHndStr;
-
-      // Fill parameter list
-      windowHndStr << (unsigned int)windowHnd;
-      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
-      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
-      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
-//#if defined OIS_LINUX_PLATFORM
-//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
-//#endif
-
-      try
-      {
-        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
-        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
-      }
-      catch (OIS::Exception ex)
-      {
-        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
-            << "OIS message: \"" << ex.eText << "\"" << std::endl;
-        inputSystem_ = 0;
-        return false;
-      }
-
-      if (createKeyboard)
-        _initialiseKeyboard();
-
-      if (createMouse)
-        _initialiseMouse();
-
-      if (createJoySticks)
-        _initialiseJoySticks();
-
-      // Set mouse/joystick region
-      if (mouse_)
-      {
-        setWindowExtents(windowWidth, windowHeight);
-      }
-
-      state_ = IS_NONE;
-      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
-
-      // InputManager holds the input buffer --> create one and add it.
-      buffer_ = new InputBuffer();
-      addKeyHandler(buffer_, "buffer");
-      Shell::getInstance().setInputBuffer(buffer_);
-
-      keyBinder_ = new KeyBinder();
-      keyBinder_->loadBindings();
-      addKeyHandler(keyBinder_, "keybinder");
-      addMouseHandler(keyBinder_, "keybinder");
-      addJoyStickHandler(keyBinder_, "keybinder");
-
-      keyDetector_ = new KeyDetector();
-      keyDetector_->loadBindings();
-      addKeyHandler(keyDetector_, "keydetector");
-      addMouseHandler(keyDetector_, "keydetector");
-      addJoyStickHandler(keyDetector_, "keydetector");
-
-      calibratorCallback_ = new CalibratorCallback();
-      addKeyHandler(calibratorCallback_, "calibratorcallback");
-
-      setConfigValues();
-
-      CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
-    }
-    else
-    {
-      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
-    }
-    return true;
-  }
-
-  /**
-    @brief Creates a keyboard and sets the event handler.
-    @return False if keyboard stays uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseKeyboard()
-  {
-    if (keyboard_ != 0)
-    {
-      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
-      return true;
-    }
-    try
-    {
-      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
-      {
-        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
-        // register our listener in OIS.
-        keyboard_->setEventCallback(this);
-        // note: OIS will not detect keys that have already been down when the keyboard was created.
-        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
-        return true;
-      }
-      else
-      {
-        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
-        return false;
-      }
-    }
-    catch (OIS::Exception ex)
-    {
-      // TODO: Test this output regarding formatting
-      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
-          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-      keyboard_ = 0;
-      return false;
-    }
-  }
-
-  /**
-    @brief Creates a mouse and sets the event handler.
-    @return False if mouse stays uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseMouse()
-  {
-    if (mouse_ != 0)
-    {
-      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
-      return true;
-    }
-    try
-    {
-      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
-      {
-        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
-        // register our listener in OIS.
-        mouse_->setEventCallback(this);
-        CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
-        return true;
-      }
-      else
-      {
-        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
-        return false;
-      }
-    }
-    catch (OIS::Exception ex)
-    {
-      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
-          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-      mouse_ = 0;
-      return false;
-    }
-  }
-
-  /**
-    @brief Creates all joy sticks and sets the event handler.
-    @return False joy stick stay uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseJoySticks()
-  {
-    if (joySticksSize_ > 0)
-    {
-      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
-      return true;
-    }
-    bool success = false;
-    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
-    {
-      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
-      {
-        try
-        {
-          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
-          joySticks_.push_back(stig);
-          // register our listener in OIS.
-          stig->setEventCallback(this);
-          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
-          success = true;
-        }
-        catch (OIS::Exception ex)
-        {
-          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
-              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-        }
-      }
-    }
-    else
-    {
-      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
-      return false;
-    }
-    joySticksSize_ = joySticks_.size();
-    activeJoyStickHandlers_.resize(joySticksSize_);
-    joyStickButtonsDown_.resize(joySticksSize_);
-    povStates_.resize(joySticksSize_);
-    sliderStates_.resize(joySticksSize_);
-    joySticksCalibration_.resize(joySticksSize_);
-    for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
-    {
-      // reset the calibration with default values
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
-        joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
-        joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
-      }
-    }
-    return success;
-  }
-
-  /**
-    @brief Sets the configurable values. Use keybindings.ini as file..
-  */
-  void InputManager::setConfigValues()
-  {
-    if (joySticksSize_)
-    {
-      std::vector<MultiTypeMath> coeffPos;
-      std::vector<MultiTypeMath> coeffNeg;
-      std::vector<MultiTypeMath> zero;
-      coeffPos.resize(24);
-      coeffNeg.resize(24);
-      zero.resize(24);
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        coeffPos[i] =  1.0f/32767.0f;
-        coeffNeg[i] =  1.0f/32768.0f;
-        zero[i]     =  0;
-      }
-
-      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffPos", coeffPos);
-          getIdentifier()->addConfigValueContainer("CoeffPos", cont);
-      }
-      cont->getValue(&coeffPos);
-
-      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffNeg", coeffNeg);
-          getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
-      }
-      cont->getValue(&coeffNeg);
-
-      cont = getIdentifier()->getConfigValueContainer("Zero");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "Zero", zero);
-          getIdentifier()->addConfigValueContainer("Zero", cont);
-      }
-      cont->getValue(&zero);
-
-      // copy values to our own variables
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
-        joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
-        joySticksCalibration_[0].zeroStates[i]    = zero[i];
-      }
-    }
-  }
-
-  /**
-    @brief Destroys all the created input devices and sets the InputManager to construction state.
-  */
-  void InputManager::_destroy()
-  {
-    if (state_ != IS_UNINIT)
-    {
-      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
-
-      if (buffer_)
-        delete buffer_;
-
-      if (keyBinder_)
-        delete keyBinder_;
-
-      if (keyDetector_)
-        delete keyDetector_;
-
-      if (calibratorCallback_)
-        delete calibratorCallback_;
-
-      keyHandlers_.clear();
-      mouseHandlers_.clear();
-      joyStickHandlers_.clear();
-
-      _destroyKeyboard();
-      _destroyMouse();
-      _destroyJoySticks();
-
-      activeHandlers_.clear();
-
-      // inputSystem_ can never be 0, or else the code is mistaken
-      OIS::InputManager::destroyInputSystem(inputSystem_);
-      inputSystem_ = 0;
-
-      state_ = IS_UNINIT;
-      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
-    }
-  }
-
-  /**
-    @brief Destroys the keyboard and sets it to 0.
-  */
-  void InputManager::_destroyKeyboard()
-  {
-    if (keyboard_)
-      // inputSystem_ can never be 0, or else the code is mistaken
-      inputSystem_->destroyInputObject(keyboard_);
-    keyboard_ = 0;
-    activeKeyHandlers_.clear();
-    keysDown_.clear();
-    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
-  }
-
-  /**
-    @brief Destroys the mouse and sets it to 0.
-  */
-  void InputManager::_destroyMouse()
-  {
-    if (mouse_)
-      // inputSystem_ can never be 0, or else the code is mistaken
-      inputSystem_->destroyInputObject(mouse_);
-    mouse_ = 0;
-    activeMouseHandlers_.clear();
-    mouseButtonsDown_.clear();
-    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
-  }
-
-  /**
-    @brief Destroys all the joy sticks and resizes the lists to 0.
-  */
-  void InputManager::_destroyJoySticks()
-  {
-    if (joySticksSize_ > 0)
-    {
-      // note: inputSystem_ can never be 0, or else the code is mistaken
-      for (unsigned int i = 0; i < joySticksSize_; i++)
-        if (joySticks_[i] != 0)
-          inputSystem_->destroyInputObject(joySticks_[i]);
-
-      joySticks_.clear();
-      joySticksSize_ = 0;
-      activeJoyStickHandlers_.clear();
-      joyStickButtonsDown_.clear();
-      povStates_.clear();
-      sliderStates_.clear();
-      joySticksCalibration_.clear();
-    }
-    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
-  }
-
-  void InputManager::_saveState()
-  {
-    savedHandlers_.activeHandlers_ = activeHandlers_;
-    savedHandlers_.activeJoyStickHandlers_ = activeJoyStickHandlers_;
-    savedHandlers_.activeKeyHandlers_ = activeKeyHandlers_;
-    savedHandlers_.activeMouseHandlers_ = activeMouseHandlers_;
-  }
-
-  void InputManager::_restoreState()
-  {
-    activeHandlers_ = savedHandlers_.activeHandlers_;
-    activeJoyStickHandlers_ = savedHandlers_.activeJoyStickHandlers_;
-    activeKeyHandlers_ = savedHandlers_.activeKeyHandlers_;
-    activeMouseHandlers_ = savedHandlers_.activeMouseHandlers_;
-  }
-
-  void InputManager::_updateTickables()
-  {
-    // we can use a map to have a list of unique pointers (an object can implement all 3 handlers)
-    std::map<InputTickable*, HandlerState> tempSet;
-    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
-      tempSet[activeKeyHandlers_[iHandler]].joyStick = true;
-    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
-      tempSet[activeMouseHandlers_[iHandler]].mouse = true;
-    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
-      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-        tempSet[activeJoyStickHandlers_[iJoyStick][iHandler]].joyStick = true;
-
-    // copy the content of the map back to the actual vector
-    activeHandlers_.clear();
-    for (std::map<InputTickable*, HandlerState>::const_iterator itHandler = tempSet.begin();
-        itHandler != tempSet.end(); itHandler++)
-      activeHandlers_.push_back(std::pair<InputTickable*, HandlerState>((*itHandler).first, (*itHandler).second));
-  }
-
-
-  // #################################
-  // ### Private Interface Methods ###
-  // #################################
-  // #################################
-
-  /**
-    @brief Updates the InputManager. Tick is called by Orxonox.
-    @param dt Delta time
-  */
-  void InputManager::tick(float dt)
-  {
-    if (state_ == IS_UNINIT)
-      return;
-
-    if (state_ != stateRequest_)
-    {
-      InputState sr = stateRequest_;
-      switch (sr)
-      {
-      case IS_NORMAL:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        // normal play mode
-        // note: we assume that the handlers exist since otherwise, something's wrong anyway.
-        enableKeyHandler("keybinder");
-        enableMouseHandler("keybinder");
-        enableJoyStickHandler("keybinder", 0);
-        stateRequest_ = IS_NORMAL;
-        state_ = IS_NORMAL;
-        break;
-
-      case IS_GUI:
-        state_ = IS_GUI;
-        break;
-
-      case IS_CONSOLE:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        enableMouseHandler("keybinder");
-        enableJoyStickHandler("keybinder", 0);
-        enableKeyHandler("buffer");
-        stateRequest_ = IS_CONSOLE;
-        state_ = IS_CONSOLE;
-        break;
-
-      case IS_DETECT:
-        savedState_ = state_;
-        _saveState();
-
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        enableKeyHandler("keydetector");
-        enableMouseHandler("keydetector");
-        enableJoyStickHandler("keydetector", 0);
-
-        stateRequest_ = IS_DETECT;
-        state_ = IS_DETECT;
-        break;
-
-      case IS_NODETECT:
-        _restoreState();
-        keysDown_.clear();
-        mouseButtonsDown_.clear();
-        joyStickButtonsDown_[0].clear();
-        state_ = IS_NODETECT;
-        stateRequest_ = savedState_;
-        break;
-
-      case IS_CALIBRATE:
-        if (joySticksSize_)
-        {
-          savedState_ = _getSingleton().state_;
-          for (unsigned int i = 0; i < 24; i++)
-          {
-            marginalsMax_[i] = INT_MIN;
-            marginalsMin_[i] = INT_MAX;
-          }
-          COUT(0) << "Move all joy stick axes in all directions a few times. "
-            << "Then put all axes in zero state and hit enter." << std::endl;
-
-          savedState_ = state_;
-          _saveState();
-
-          activeKeyHandlers_.clear();
-          activeMouseHandlers_.clear();
-          for (unsigned int i = 0; i < joySticksSize_; i++)
-            activeJoyStickHandlers_[i].clear();
-
-          enableKeyHandler("calibratorcallback");
-          stateRequest_ = IS_CALIBRATE;
-          state_ = IS_CALIBRATE;
-        }
-        else
-        {
-          COUT(3) << "Connot calibrate, no joy stick found!" << std::endl;
-          stateRequest_ = state_;
-        }
-        break;
-
-      case IS_NOCALIBRATE:
-        _completeCalibration();
-        _restoreState();
-        keyBinder_->resetJoyStickAxes();
-        state_ = IS_NOCALIBRATE;
-        stateRequest_ = savedState_;
-        break;
-
-      case IS_NONE:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-        state_ = IS_NONE;
-
-      default:
-        break;
-      }
-    }
-
-    // Capture all the input. This calls the event handlers in InputManager.
-    if (mouse_)
-      mouse_->capture();
-    if (keyboard_)
-      keyboard_->capture();
-    for (unsigned  int i = 0; i < joySticksSize_; i++)
-      joySticks_[i]->capture();
-
-    if (state_ != IS_CALIBRATE)
-    {
-      // call all the handlers for the held key events
-      for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
-        for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
-          activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
-
-      // call all the handlers for the held mouse button events
-      for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
-        for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
-          activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
-
-      // call all the handlers for the held joy stick button events
-      for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
-        for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
-          for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-            activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
-    }
-
-    // call the ticks for the handlers (need to be treated specially)
-    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
-      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
-  }
-
-  void InputManager::_completeCalibration()
-  {
-    for (unsigned int i = 0; i < 24; i++)
-    {
-      // positive coefficient
-      if (marginalsMax_[i] == INT_MIN)
-        marginalsMax_[i] =  32767;
-      // coefficients
-      if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
-        joySticksCalibration_[0].positiveCoeff[i] =  1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
-      else
-        joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
-
-      // config value
-      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
-
-      // negative coefficient
-      if (marginalsMin_[i] == INT_MAX)
-        marginalsMin_[i] = -32768;
-      // coefficients
-      if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
-        joySticksCalibration_[0].negativeCoeff[i] = -1.0f/(marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
-      else
-        joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
-      // config value
-      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
-
-      // zero states
-      if (i < 8)
-      {
-        if (!(i & 1))
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
-        else
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
-      }
-      else
-      {
-        if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
-        else
-          joySticksCalibration_[0].zeroStates[i] = 0;
-      }
-      // config value
-      cont = getIdentifier()->getConfigValueContainer("Zero");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].zeroStates[i]);
-    }
-  }
-
-  // ###### Key Events ######
-
-  /**
-    @brief Event handler for the keyPressed Event.
-    @param e Event information
-  */
-  bool InputManager::keyPressed(const OIS::KeyEvent &e)
-  {
-    // check whether the key already is in the list (can happen when focus was lost)
-    unsigned int iKey = 0;
-    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
-      iKey++;
-    if (iKey == keysDown_.size())
-      keysDown_.push_back(Key(e));
-
-    // update modifiers
-    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
-      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
-    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
-      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
-    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
-      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
-
-    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the keyReleased Event.
-    @param e Event information
-  */
-  bool InputManager::keyReleased(const OIS::KeyEvent &e)
-  {
-    // remove the key from the keysDown_ list
-    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
-    {
-      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
-      {
-        keysDown_.erase(keysDown_.begin() + iKey);
-        break;
-      }
-    }
-
-    // update modifiers
-    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
-      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
-    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
-      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
-    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
-      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
-
-    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
-
-    return true;
-  }
-
-
-  // ###### Mouse Events ######
-
-  /**
-    @brief Event handler for the mouseMoved Event.
-    @param e Event information
-  */
-  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
-  {
-    // check for actual moved event
-    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
-    {
-      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
-            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
-    }
-
-    // check for mouse scrolled event
-    if (e.state.Z.rel != 0)
-    {
-      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
-    }
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mousePressed Event.
-    @param e Event information
-    @param id The ID of the mouse button
-  */
-  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // check whether the button already is in the list (can happen when focus was lost)
-    unsigned int iButton = 0;
-    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
-      iButton++;
-    if (iButton == mouseButtonsDown_.size())
-      mouseButtonsDown_.push_back((MouseButton::Enum)id);
-
-    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mouseReleased Event.
-    @param e Event information
-    @param id The ID of the mouse button
-  */
-  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // remove the button from the keysDown_ list
-    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
-    {
-      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
-      {
-        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
-        break;
-      }
-    }
-
-    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
-
-    return true;
-  }
-
-
-  // ###### Joy Stick Events ######
-
-  inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
-  {
-    // use the device to identify which one called the method
-    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    unsigned int iJoyStick = 0;
-    while (joySticks_[iJoyStick] != joyStick)
-    {
-      iJoyStick++;
-      if (iJoyStick == joySticksSize_)
-      {
-        CCOUT(3) << "Unknown joystick fired an event. This means there is a bug somewhere! Aborting." << std::endl;
-        abort();
-      }
-    }
-    return iJoyStick;
-  }
-
-  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // check whether the button already is in the list (can happen when focus was lost)
-    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
-    unsigned int iButton = 0;
-    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
-      iButton++;
-    if (iButton == buttonsDown.size())
-      buttonsDown.push_back(button);
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
-
-    return true;
-  }
-
-  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // remove the button from the joyStickButtonsDown_ list
-    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
-    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
-    {
-      if (buttonsDown[iButton] == button)
-      {
-        buttonsDown.erase(buttonsDown.begin() + iButton);
-        break;
-      }
-    }
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
-
-    return true;
-  }
-
-  void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
-  {
-    if (state_ == IS_CALIBRATE)
-    {
-      if (value > marginalsMax_[axis])
-        marginalsMax_[axis] = value;
-      if (value < marginalsMin_[axis])
-        marginalsMin_[axis] = value;
-    }
-    else
-    {
-      float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
-      if (fValue > 0.0f)
-        fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
-      else
-        fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
-
-      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis, fValue);
-    }
-  }
-
-  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
-  {
-    //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000)
-    //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;}
-
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // keep in mind that the first 8 axes are reserved for the sliders
-    _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
-
-    return true;
-  }
-
-  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
-  {
-    //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000)
-    //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;}
-    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
-
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
-      _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
-    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
-      _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
-
-    return true;
-  }
-
-  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // translate the POV into 8 simple buttons
-    int lastState = povStates_[iJoyStick][id];
-    if (lastState & OIS::Pov::North)
-      buttonReleased(arg, 32 + id * 4 + 0);
-    if (lastState & OIS::Pov::South)
-      buttonReleased(arg, 32 + id * 4 + 1);
-    if (lastState & OIS::Pov::East)
-      buttonReleased(arg, 32 + id * 4 + 2);
-    if (lastState & OIS::Pov::West)
-      buttonReleased(arg, 32 + id * 4 + 3);
-
-    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
-
-    int currentState = povStates_[iJoyStick][id];
-    if (currentState & OIS::Pov::North)
-      buttonPressed(arg, 32 + id * 4 + 0);
-    if (currentState & OIS::Pov::South)
-      buttonPressed(arg, 32 + id * 4 + 1);
-    if (currentState & OIS::Pov::East)
-      buttonPressed(arg, 32 + id * 4 + 2);
-    if (currentState & OIS::Pov::West)
-      buttonPressed(arg, 32 + id * 4 + 3);
-
-    return true;
-  }
-
-  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
-
-    return true;
-  }*/
-
-
-  // ################################
-  // ### Static Interface Methods ###
-  // ################################
-  // ################################
-
-  std::string InputManager::bindingCommmandString_s = "";
-
-  bool InputManager::initialise(const 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();
-  }
-
-  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().joySticksSize_;
-  }
-
-  /*bool InputManager::isKeyDown(KeyCode::Enum key)
-  {
-    if (_getSingleton().keyboard_)
-      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
-    else
-      return false;
-  }*/
-
-  /*bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
-  {
-    if (_getSingleton().keyboard_)
-      return isModifierDown(modifier);
-    else
-      return false;
-  }*/
-
-  /*const MouseState InputManager::getMouseState()
-  {
-    if (_getSingleton().mouse_)
-      return _getSingleton().mouse_->getMouseState();
-    else
-      return MouseState();
-  }*/
-
-  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
-  {
-    if (ID < _getSingleton().joySticksSize_)
-      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
-    else
-      return JoyStickState();
-  }*/
-
-  void InputManager::destroy()
-  {
-    _getSingleton()._destroy();
-  }
-
-  void InputManager::destroyKeyboard()
-  {
-    return _getSingleton()._destroyKeyboard();
-  }
-
-  void InputManager::destroyMouse()
-  {
-    return _getSingleton()._destroyMouse();
-  }
-
-  void InputManager::destroyJoySticks()
-  {
-    return _getSingleton()._destroyJoySticks();
-  }
-
-
-  /**
-    @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(const int width, const int height)
-  {
-    if (_getSingleton().mouse_)
-    {
-      // Set mouse region (if window resizes, we should alter this to reflect as well)
-      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
-      mouseState.width  = width;
-      mouseState.height = height;
-    }
-  }
-
-  /**
-    @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::setInputState(const InputState state)
-  {
-    _getSingleton().stateRequest_ = state;
-  }
-
-  /**
-    @brief Returns the current input handling method
-    @return The current input mode.
-  */
-  InputManager::InputState InputManager::getInputState()
-  {
-    return _getSingleton().state_;
-  }
-
-  void InputManager::storeKeyStroke(const std::string& name)
-  {
-    setInputState(IS_NODETECT);
-    COUT(0) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
-    CommandExecutor::execute("config KeyBinder " + name + " " + bindingCommmandString_s, false);
-  }
-
-  void InputManager::keyBind(const std::string& command)
-  {
-    bindingCommmandString_s = command;
-    setInputState(IS_DETECT);
-    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-  }
-
-  void InputManager::calibrate()
-  {
-    _getSingleton().setInputState(IS_CALIBRATE);
-  }
-
-  // ###### KeyHandler ######
-
-  /**
-    @brief Adds a new key handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
-    {
-      _getSingleton().keyHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a Key handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeKeyHandler(const std::string &name)
-  {
-    disableKeyHandler(name);
-    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
-    if (it != _getSingleton().keyHandlers_.end())
-    {
-      _getSingleton().keyHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  KeyHandler* InputManager::getKeyHandler(const std::string& name)
-  {
-    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
-    if (it != _getSingleton().keyHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific key handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::enableKeyHandler(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific key handler.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::disableKeyHandler(const std::string &name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // look for the handler in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        _getSingleton().activeKeyHandlers_.erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a key handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isKeyHandlerActive(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-        return true;
-    }
-    return false;
-  }
-
-
-  // ###### MouseHandler ######
-  /**
-    @brief Adds a new mouse handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
-    {
-      _getSingleton().mouseHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a Mouse handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeMouseHandler(const std::string &name)
-  {
-    disableMouseHandler(name);
-    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
-    if (it != _getSingleton().mouseHandlers_.end())
-    {
-      _getSingleton().mouseHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  MouseHandler* InputManager::getMouseHandler(const std::string& name)
-  {
-    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
-    if (it != _getSingleton().mouseHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific mouse handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::enableMouseHandler(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific mouse handler.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::disableMouseHandler(const std::string &name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // look for the handler in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        _getSingleton().activeMouseHandlers_.erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a mouse handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isMouseHandlerActive(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-        return true;
-    }
-    return false;
-  }
-
-
-  // ###### JoyStickHandler ######
-
-  /**
-    @brief Adds a new joy stick handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
-    {
-      _getSingleton().joyStickHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a JoyStick handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeJoyStickHandler(const std::string &name)
-  {
-    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
-          itstick != _getSingleton().joySticks_.end(); itstick++)
-      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
-
-    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
-    if (it != _getSingleton().joyStickHandlers_.end())
-    {
-      _getSingleton().joyStickHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
-  {
-    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
-    if (it != _getSingleton().joyStickHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific joy stick handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name or id was not found, true otherwise.
-  */
-  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific joy stick handler.
-    @param name Unique name of the handler.
-    @return False if name or id was not found, true otherwise.
-  */
-  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // look for the handler in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-      {
-        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a joy stick handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-        return true;
-    }
-    return false;
-  }
-
-}
Index: code/branches/input/src/core/InputManager.h
===================================================================
--- code/branches/input/src/core/InputManager.h	(revision 1510)
+++ 	(revision )
@@ -1,260 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- @brief Implementation of a little Input handler that distributes everything
-        coming from OIS.
- */
-
-#ifndef _InputManager_H__
-#define _InputManager_H__
-
-#include "CorePrereqs.h"
-
-#include <map>
-#include <vector>
-
-#include "ois/OIS.h"
-#include "util/Math.h"
-#include "Tickable.h"
-#include "InputInterfaces.h"
-
-namespace orxonox
-{
-  /**
-  * Helper class to realise a vector<int[4]>
-  */
-  class POVStates
-  {
-  public:
-    int operator[](unsigned int index) { return povStates[index]; }
-    int povStates[4];
-  };
-
-  /**
-  * Helper class to realise a vector< {int[4], int[4]} >
-  */
-  class SliderStates
-  {
-  public:
-    IntVector2 sliderStates[4];
-  };
-
-  /**
-  * Struct for storing a custom input state
-  */
-  struct StoredState
-  {
-    std::vector<KeyHandler*>                    activeKeyHandlers_;
-    std::vector<MouseHandler*>                  activeMouseHandlers_;
-    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
-    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
-  };
-
-  struct JoyStickCalibration
-  {
-    int zeroStates[24];
-    float positiveCoeff[24];
-    float negativeCoeff[24];
-  };
-
-  /**
-    @brief Captures and distributes mouse and keyboard input.
-  */
-  class _CoreExport InputManager
-        : public TickableReal,
-          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
-  {
-  public: // enumerations
-    /**
-      @brief Designates the way input is handled and redirected.
-    */
-    enum InputState
-    {
-      IS_UNINIT,    //!< InputManager has not yet been initialised.
-      IS_NONE,      //!< Input is discarded.
-      IS_NORMAL,    //!< Normal play state. Key and button bindings are active.
-      IS_GUI,       //!< All OIS input events are passed to CEGUI.
-      IS_CONSOLE,   //!< Keyboard input is redirected to the InputBuffer.
-      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
-      IS_NODETECT,  //!< remove KeyDetector
-      IS_NOCALIBRATE,
-      IS_CALIBRATE,
-      IS_CUSTOM     //!< Any possible configuration.
-    };
-
-  public: // member functions
-    void setConfigValues();
-
-  public: // static functions
-    static bool initialise(const 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 int  numberOfKeyboards();
-    static int  numberOfMice();
-    static int  numberOfJoySticks();
-
-    static void destroy();
-    static void destroyKeyboard();
-    static void destroyMouse();
-    static void destroyJoySticks();
-
-    //static bool isModifierDown(KeyboardModifier::Enum modifier);
-    //static bool isKeyDown(KeyCode::Enum key);
-    //static const MouseState getMouseState();
-    //static const JoyStickState getJoyStickState(unsigned int ID);
-
-    static void setWindowExtents(const int width, const int height);
-
-    static void setInputState(const InputState state);
-    static InputState getInputState();
-
-    static void storeKeyStroke(const std::string& name);
-    static void keyBind(const std::string& command);
-
-    static void calibrate();
-
-    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
-    static bool removeKeyHandler              (const std::string& name);
-    static KeyHandler* getKeyHandler          (const std::string& name);
-    static bool enableKeyHandler              (const std::string& name);
-    static bool disableKeyHandler             (const std::string& name);
-    static bool isKeyHandlerActive            (const std::string& name);
-
-    static bool addMouseHandler               (MouseHandler* handler, const std::string& name);
-    static bool removeMouseHandler            (const std::string& name);
-    static MouseHandler* getMouseHandler      (const std::string& name);
-    static bool enableMouseHandler            (const std::string& name);
-    static bool disableMouseHandler           (const std::string& name);
-    static bool isMouseHandlerActive          (const std::string& name);
-
-    static bool addJoyStickHandler            (JoyStickHandler* handler, const std::string& name);
-    static bool removeJoyStickHandler         (const std::string& name);
-    static JoyStickHandler* getJoyStickHandler(const std::string& name);
-    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
-    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
-    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
-
-  private: // functions
-    // don't mess with a Singleton
-    InputManager ();
-    InputManager (const InputManager&);
-    ~InputManager();
-
-    // Intenal methods
-    bool _initialise(const size_t, int, int, bool, bool, bool);
-    bool _initialiseKeyboard();
-    bool _initialiseMouse();
-    bool _initialiseJoySticks();
-
-    void _destroy();
-    void _destroyKeyboard();
-    void _destroyMouse();
-    void _destroyJoySticks();
-
-    void _updateTickables();
-
-    void _saveState();
-    void _restoreState();
-
-    void _completeCalibration();
-
-    void _fireAxis(unsigned int iJoyStick, int axis, int value);
-    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
-
-    void tick(float dt);
-
-    // input events
-    bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
-    bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
-    bool mouseMoved    (const OIS::MouseEvent    &arg);
-    bool keyPressed    (const OIS::KeyEvent      &arg);
-    bool keyReleased   (const OIS::KeyEvent      &arg);
-    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
-    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
-    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
-    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
-    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
-    //bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
-
-    static InputManager& _getSingleton();
-    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
-
-  private: // variables
-    OIS::InputManager*                          inputSystem_;     //!< OIS input manager
-    OIS::Keyboard*                              keyboard_;        //!< OIS mouse
-    OIS::Mouse*                                 mouse_;           //!< OIS keyboard
-    std::vector<OIS::JoyStick*>                 joySticks_;       //!< OIS joy sticks
-    unsigned int                                joySticksSize_;
-
-    KeyBinder*                                  keyBinder_;       //!< KeyBinder instance
-    KeyDetector*                                keyDetector_;     //!< KeyDetector instance
-    InputBuffer*                                buffer_;          //!< InputBuffer instance
-    CalibratorCallback*                         calibratorCallback_;
-
-    InputState state_;
-    InputState stateRequest_;
-    InputState savedState_;
-    unsigned int keyboardModifiers_;
-    StoredState savedHandlers_;
-
-    // joystick calibration
-    //std::vector<int> marginalsMaxConfig_;
-    //std::vector<int> marginalsMinConfig_;
-    int marginalsMax_[24];
-    int marginalsMin_[24];
-    bool bCalibrated_;
-
-    //! Keeps track of the joy stick POV states
-    std::vector<POVStates>                      povStates_;
-    //! Keeps track of the possibly two slider axes
-    std::vector<SliderStates>                   sliderStates_;
-    std::vector<JoyStickCalibration>            joySticksCalibration_;
-
-    std::map<std::string, KeyHandler*>          keyHandlers_;
-    std::map<std::string, MouseHandler*>        mouseHandlers_;
-    std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
-
-    std::vector<KeyHandler*>                    activeKeyHandlers_;
-    std::vector<MouseHandler*>                  activeMouseHandlers_;
-    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
-    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
-
-    std::vector<Key>                            keysDown_;
-    std::vector<MouseButton::Enum>              mouseButtonsDown_;
-    std::vector<std::vector<int> >              joyStickButtonsDown_;
-
-    static std::string                          bindingCommmandString_s;
-  };
-
-}
-
-#endif /* _InputManager_H__ */
Index: code/branches/input/src/core/KeyBinder.cc
===================================================================
--- code/branches/input/src/core/KeyBinder.cc	(revision 1510)
+++ 	(revision )
@@ -1,908 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- @brief Implementation of the different input handlers.
- */
-
-#include "KeyBinder.h"
-#include <fstream>
-#include <limits.h>
-#include "util/Convert.h"
-#include "util/SubString.h"
-#include "util/String.h"
-#include "Debug.h"
-#include "ConfigValueIncludes.h"
-#include "CoreIncludes.h"
-#include "CommandExecutor.h"
-#include "ConsoleCommand.h"
-#include "Executor.h"
-// TODO: only needed by the CalibratorCallback class; move to new file
-#include "InputManager.h"
-
-namespace orxonox
-{
-  // ###############################
-  // ###  BufferedParamCommand   ###
-  // ###############################
-
-  /**
-  * Executes a buffered command. This is used for commands with additional
-  * parameters.
-  * @return True if command execution was successful or value was zero.
-  */
-  bool BufferedParamCommand::execute()
-  {
-    if (nValuesAdded_)
-    {
-      BufferedParamCommand& cmd = *this;
-      cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
-      // reset
-      cmd.nValuesAdded_ = 0;
-      cmd.value_ = 0;
-      return cmd.evaluation_.execute();
-    }
-    else
-      return true;
-  }
-
-  // ###############################
-  // #####    SimpleCommand    #####
-  // ###############################
-
-  /**
-  * Executes a simple command with no additional paramters.
-  * @return True if command execution was successful, false otherwise.
-  */
-  bool SimpleCommand::execute(float abs, float rel)
-  {
-    return evaluation_.execute();
-  }
-
-  // ###############################
-  // #####    ParamCommand     #####
-  // ###############################
-
-  /**
-  * Executes a parameter command. The commmand string is not directly executed,
-  * but instead stored in a buffer list so that values can be combined.
-  * @return Always true.
-  */
-  bool ParamCommand::execute(float abs, float rel)
-  {
-    BufferedParamCommand& cmd = *paramCommand_;
-    // command has an additional parameter
-    if (bRelative_)
-    {
-      if (rel != 0.0f)
-      {
-        // we have to calculate a relative movement.
-        // paramModifier_ says how much one keystroke is
-        cmd.value_ += paramModifier_ * rel;
-      }
-    }
-    else if (abs != 0.0f)
-    {
-      // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
-      // and normally this is caught in tickInput(), but that threshold cannot be to high
-      // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
-      // Someone only uses buttons with an active joystick. The joy stick value could then
-      // be 0.05 for instance and the the key value 1. Without handling the problem, the final
-      // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
-      float absQ = abs * abs;
-      float valueQ = cmd.value_ * cmd.value_;
-      if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
-      {
-        cmd.value_ = abs * paramModifier_;
-        cmd.nValuesAdded_ = 1;
-      }
-      else if (absQ * 50.0f < valueQ)
-      {
-        // abs is too small, we just don't do anything
-      }
-      else
-      {
-        // we have to calculate the absolute position of the axis.
-        // Since there might be another axis that is affected, we have to wait and
-        // store the result in a temporary place
-        cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
-      }
-    }
-    return true;
-  }
-
-  // ###############################
-  // #####       Button        #####
-  // ###############################
-
-  void Button::clear()
-  {
-    for (unsigned int j = 0; j < 3; j++)
-    {
-      if (nCommands_[j])
-      {
-        // delete all commands and the command pointer array
-        for (unsigned int i = 0; i < nCommands_[j]; i++)
-          delete commands_[j][i];
-        delete[] commands_[j];
-        commands_[j] = 0;
-        nCommands_[j] = 0;
-      }
-      else
-      {
-        commands_[j] = 0;
-      }
-    }
-  }
-
-  void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer)
-  {
-    if (isEmpty(bindingString_))
-    {
-      clear();
-      return;
-    }
-
-    // use std::vector for a temporary dynamic array
-    std::vector<BaseCommand*> commands[3];
-
-
-    // separate the commands
-    SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
-        '\\', false, '"', false, '(', ')', false, '\0');
-
-    for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
-    {
-      if (commandStrings[iCommand] != "")
-      {
-        SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
-            '\\', false, '"', false, '(', ')', false, '\0');
-
-        unsigned int iToken = 0;
-
-        // for real axes, we can feed a ButtonThreshold argument as entire command
-        if (getLowercase(tokens[0]) == "buttonthreshold")
-        {
-          if (tokens.size() == 1)
-            continue;
-          // may fail, but doesn't matter
-          convertValue(&buttonThreshold_, tokens[1]);
-          continue;
-        }
-
-        // first argument can be OnPress, OnHold OnRelease or nothing
-        KeybindMode::Enum mode = KeybindMode::None;
-        if (getLowercase(tokens[iToken]) == "onpress")
-          mode = KeybindMode::OnPress,   iToken++;
-        if (getLowercase(tokens[iToken]) == "onrelease")
-          mode = KeybindMode::OnRelease, iToken++;
-        if (getLowercase(tokens[iToken]) == "onhold")
-          mode = KeybindMode::OnHold,    iToken++;
-
-        if (iToken == tokens.size())
-          continue;
-
-        // second argument can be the amplitude for the case it as an axis command
-        // default amplitude is 1.0f
-        float paramModifier = 1.0f;
-        if (getLowercase(tokens[iToken]) == "scale")
-        {
-          iToken++;
-          if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
-          {
-            COUT(2) << "Error while parsing key binding " << name_
-                << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
-            if (iToken == tokens.size())
-              continue;
-          }
-          iToken++;
-        }
-
-        // no more arguments expected except for the actual command
-        if (iToken == tokens.size())
-          continue;
-
-        std::string commandStr;
-        while (iToken != tokens.size())
-          commandStr += tokens[iToken++] + " ";
-
-        // evaluate the command
-        CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
-        if (!eval.isValid())
-          continue;
-
-        // check for param command
-        int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
-        if (paramIndex >= 0)
-        {
-          // parameter supported command
-          ParamCommand* cmd = new ParamCommand();
-          cmd->paramModifier_ = paramModifier;
-          cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
-
-          // add command to the buffer if not yet existing
-          for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
-          {
-            if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())
-                == getLowercase(commandStr))
-            {
-              // already in list
-              cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
-              break;
-            }
-          }
-          if (cmd->paramCommand_ == 0)
-          {
-            cmd->paramCommand_ = new BufferedParamCommand();
-            paramCommandBuffer.push_back(cmd->paramCommand_);
-            cmd->paramCommand_->evaluation_ = eval;
-            cmd->paramCommand_->paramIndex_ = paramIndex;
-          }
-
-
-          // we don't know whether this is an actual axis or just a button
-          if (mode == KeybindMode::None)
-          {
-            if (!addParamCommand(cmd))
-            {
-              mode = eval.getConsoleCommand()->getKeybindMode();
-              commands[mode].push_back(cmd);
-            }
-          }
-        }
-        else
-        {
-          SimpleCommand* cmd = new SimpleCommand();
-          cmd->evaluation_ = eval;
-
-          if (mode == KeybindMode::None)
-            mode = eval.getConsoleCommand()->getKeybindMode();
-
-          commands[mode].push_back(cmd);
-        }
-      }
-    }
-
-    for (unsigned int j = 0; j < 3; j++)
-    {
-      nCommands_[j] = commands[j].size();
-      if (nCommands_[j])
-      {
-        commands_[j] = new BaseCommand*[nCommands_[j]];
-        for (unsigned int i = 0; i < commands[j].size(); i++)
-          commands_[j][i] = commands[j][i];
-      }
-      else
-        commands_[j] = 0;
-    }
-  }
-
-  bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
-  {
-    // execute all the parsed commands in the string
-    for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
-      commands_[mode][iCommand]->execute(abs, rel);
-    return true;
-  }
-
-  // ###############################
-  // #####      HalfAxis       #####
-  // ###############################
-
-  void HalfAxis::clear()
-  {
-    Button::clear();
-    if (nParamCommands_)
-    {
-      // delete all commands and the command pointer array
-      for (unsigned int i = 0; i < nParamCommands_; i++)
-        delete paramCommands_[i];
-      delete[] paramCommands_;
-      nParamCommands_ = 0;
-    }
-    else
-    {
-      nParamCommands_ = 0; nParamCommands_ = 0;
-    }
-  }
-
-  bool HalfAxis::addParamCommand(ParamCommand* command)
-  {
-    ParamCommand** cmds = paramCommands_;
-    paramCommands_ = new ParamCommand*[++nParamCommands_];
-    unsigned int i;
-    for (i = 0; i < nParamCommands_ - 1; i++)
-      paramCommands_[i] = cmds[i];
-    paramCommands_[i] = command;
-    if (nParamCommands_ > 1)
-      delete[] cmds;
-    return true;
-  }
-
-  bool HalfAxis::execute()
-  {
-    bool success = true;
-    for (unsigned int i = 0; i < nParamCommands_; i++)
-      success = success && paramCommands_[i]->execute(absVal_, relVal_);
-    return success;
-  }
-
-
-  // ###############################
-  // ######     KeyBinder     ######
-  // ###############################
-
-  /**
-    @brief Constructor that does as little as necessary.
-  */
-  KeyBinder::KeyBinder() : deriveTime_(0.0f)
-  {
-    mouseRelative_[0] = 0;
-    mouseRelative_[1] = 0;
-    mousePosition_[0] = 0;
-    mousePosition_[1] = 0;
-
-    RegisterObject(KeyBinder);
-
-    // keys
-    std::string keyNames[] = {
-      "UNASSIGNED",
-      "ESCAPE",
-      "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
-      "MINUS", "EQUALS", "BACK", "TAB",
-      "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
-      "LBRACKET", "RBRACKET",
-      "RETURN", "LCONTROL",
-      "A", "S", "D", "F", "G", "H", "J", "K", "L",
-      "SEMICOLON", "APOSTROPHE", "GRAVE",
-      "LSHIFT", "BACKSLASH",
-      "Z", "X", "C", "V", "B", "N", "M",
-      "COMMA", "PERIOD", "SLASH",
-      "RSHIFT",
-      "MULTIPLY",
-      "LMENU",
-      "SPACE",
-      "CAPITAL",
-      "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
-      "NUMLOCK", "SCROLL",
-      "NUMPAD7", "NUMPAD8", "NUMPAD9",
-      "SUBTRACT",
-      "NUMPAD4", "NUMPAD5", "NUMPAD6",
-      "ADD",
-      "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0",
-      "DECIMAL",
-      "","",
-      "OEM_102",
-      "F11", "F12",
-      "","","","","","","","","","","",
-      "F13", "F14", "F15",
-      "","","","","","","","","","",
-      "KANA",
-      "","",
-      "ABNT_C1",
-      "","","","","",
-      "CONVERT",
-      "",
-      "NOCONVERT",
-      "",
-      "YEN",
-      "ABNT_C2",
-      "","","","","","","","","","","","","","",
-      "NUMPADEQUALS",
-      "","",
-      "PREVTRACK",
-      "AT",
-      "COLON", "UNDERLINE",
-      "KANJI",
-      "STOP",
-      "AX",
-      "UNLABELED",
-      "NEXTTRACK",
-      "","",
-      "NUMPADENTER",
-      "RCONTROL",
-      "","",
-      "MUTE",
-      "CALCULATOR",
-      "PLAYPAUSE",
-      "",
-      "MEDIASTOP",
-      "","","","","","","","","",
-      "VOLUMEDOWN",
-      "",
-      "VOLUMEUP",
-      "",
-      "WEBHOME",
-      "NUMPADCOMMA",
-      "",
-      "DIVIDE",
-      "",
-      "SYSRQ",
-      "RMENU",
-      "","","","","","","","","","","","",
-      "PAUSE",
-      "",
-      "HOME",
-      "UP",
-      "PGUP",
-      "",
-      "LEFT",
-      "",
-      "RIGHT",
-      "",
-      "END", "DOWN", "PGDOWN", "INSERT", "DELETE",
-      "","","","","","","",
-      "LWIN", "RWIN", "APPS",
-      "POWER", "SLEEP",
-      "","","",
-      "WAKE",
-      "",
-      "WEBSEARCH", "WEBFAVORITES", "WEBREFRESH", "WEBSTOP", "WEBFORWARD", "WEBBACK",
-      "MYCOMPUTER", "MAIL", "MEDIASELECT"
-    };
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      keys_[i].name_ = "Key" + keyNames[i];
-
-    // mouse buttons
-    std::string mouseButtonNames[] = {
-      "MouseLeft", "MouseRight", "MouseMiddle",
-      "MouseButton3", "MouseButton4", "MouseButton5",
-      "MouseButton6", "MouseButton7",
-      "MouseWheel1Up", "MouseWheel1Down",
-      "MouseWheel2Up", "MouseWheel2Down" };
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      mouseButtons_[i].name_ = mouseButtonNames[i];
-
-    // joy stick buttons
-    for (unsigned int i = 0; i < 32; i++)
-      joyStickButtons_[i].name_ = "JoyButton" + getConvertedValue<int, std::string>(i);
-    for (unsigned int i = 32; i < nJoyStickButtons_s; i += 4)
-    {
-		  joyStickButtons_[i + 0].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
-		  joyStickButtons_[i + 1].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
-		  joyStickButtons_[i + 2].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
-		  joyStickButtons_[i + 3].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
-    }
-
-    // half axes
-    std::string rawNames[nHalfAxes_s/2];
-    rawNames[0] = "MouseX";
-    rawNames[1] = "MouseY";
-    rawNames[2] = "Empty1";
-    rawNames[3] = "Empty2";
-    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
-      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
-    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
-    {
-      halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
-      halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
-    }
-
-    for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
-      halfAxes_[i].buttonThreshold_ = buttonThreshold_;
-  }
-
-  /**
-    @brief Destructor
-  */
-  KeyBinder::~KeyBinder()
-  {
-    // almost no destructors required because most of the arrays are static.
-    clearBindings(); // does some destruction work
-  }
-
-  /**
-    @brief Loads the key and button bindings.
-    @return True if loading succeeded.
-  */
-  void KeyBinder::loadBindings()
-  {
-    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
-
-    clearBindings();
-
-    std::ifstream infile;
-    infile.open("keybindings.ini");
-    if (!infile.is_open())
-    {
-      ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "def_keybindings.ini");
-      ConfigFileManager::getSingleton()->save(CFT_Keybindings, "keybindings.ini");
-    }
-    infile.close();
-    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
-
-    // parse key bindings
-    setConfigValues();
-
-    COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
-  }
-
-  /**
-    @brief Loader for the key bindings, managed by config values.
-  */
-  void KeyBinder::setConfigValues()
-  {
-    SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.01f)  .description("Threshold for analog axes until which the state is 0.");
-    SetConfigValueGeneric(KeyBinder, mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
-    SetConfigValueGeneric(KeyBinder, bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
-    SetConfigValueGeneric(KeyBinder, derivePeriod_, 0.5f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
-    SetConfigValueGeneric(KeyBinder, mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
-    SetConfigValueGeneric(KeyBinder, bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
-
-    float oldThresh = buttonThreshold_;
-    SetConfigValueGeneric(KeyBinder, buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
-    if (oldThresh != buttonThreshold_)
-      for (unsigned int i = 0; i < nHalfAxes_s; i++)
-        if (halfAxes_[i].buttonThreshold_ == oldThresh)
-          halfAxes_[i].buttonThreshold_ = buttonThreshold_;
-
-    // keys
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      readTrigger(keys_[i]);
-    // mouse buttons
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      readTrigger(mouseButtons_[i]);
-    // joy stick buttons
-    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
-      readTrigger(joyStickButtons_[i]);
-    // half axes
-    for (unsigned int i = 0; i < nHalfAxes_s; i++)
-      readTrigger(halfAxes_[i]);
-  }
-
-  void KeyBinder::readTrigger(Button& button)
-  {
-    // config value stuff
-    ConfigValueContainer* cont = ClassManager<KeyBinder>::getIdentifier()->getConfigValueContainer(button.name_);
-    if (!cont)
-    {
-      cont = new ConfigValueContainer(CFT_Keybindings, ClassManager<KeyBinder>::getIdentifier(), button.name_, "");
-      ClassManager<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
-    }
-    std::string old = button.bindingString_;
-    cont->getValue(&button.bindingString_);
-
-    // keybinder stuff
-    if (old != button.bindingString_)
-    {
-      // clear everything so we don't get old axis ParamCommands mixed up
-      button.clear();
-
-      // binding has changed
-      button.parse(paramCommandBuffer_);
-    }
-  }
-
-  /**
-    @brief Overwrites all bindings with ""
-  */
-  void KeyBinder::clearBindings()
-  {
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      keys_[i].clear();
-
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      mouseButtons_[i].clear();
-
-    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
-      joyStickButtons_[i].clear();
-
-    for (unsigned int i = 0; i < nHalfAxes_s; i++)
-      halfAxes_[i].clear();
-
-    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
-      delete paramCommandBuffer_[i];
-    paramCommandBuffer_.clear();
-  }
-
-  void KeyBinder::resetJoyStickAxes()
-  {
-    for (unsigned int i = 8; i < nHalfAxes_s; i++)
-    {
-      halfAxes_[i].absVal_ = 0.0f;
-      halfAxes_[i].relVal_ = 0.0f;
-    }
-  }
-
-  void KeyBinder::tickInput(float dt, const HandlerState& state)
-  {
-    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
-    unsigned int iBegin = 8;
-    unsigned int iEnd   = 8;
-    if (state.joyStick)
-      iEnd = nHalfAxes_s;
-    if (state.mouse)
-      iBegin = 0;
-    for (unsigned int i = iBegin; i < iEnd; i++)
-    {
-      if (halfAxes_[i].hasChanged_)
-      {
-        if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
-        {
-          halfAxes_[i].wasDown_ = true;
-          if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
-            halfAxes_[i].execute(KeybindMode::OnPress);
-        }
-        else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
-        {
-          halfAxes_[i].wasDown_ = false;
-          if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
-            halfAxes_[i].execute(KeybindMode::OnRelease);
-        }
-        halfAxes_[i].hasChanged_ = false;
-      }
-
-      if (halfAxes_[i].wasDown_)
-      {
-        if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
-          halfAxes_[i].execute(KeybindMode::OnHold);
-      }
-
-      // these are the actually useful axis bindings for analog input AND output
-      if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
-      {
-        //COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl;
-        halfAxes_[i].execute();
-      }
-    }
-
-    if (bDeriveMouseInput_ && state.mouse)
-    {
-      if (deriveTime_ > derivePeriod_)
-      {
-        //CCOUT(3) << "mouse abs: ";
-        for (int i = 0; i < 2; i++)
-        {
-          if (mouseRelative_[i] > 0)
-          {
-            halfAxes_[2*i + 0].absVal_ =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
-            halfAxes_[2*i + 1].absVal_ = 0.0f;
-          }
-          else if (mouseRelative_[i] < 0)
-          {
-            halfAxes_[2*i + 0].absVal_ = 0.0f;
-            halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
-          }
-          else
-          {
-            halfAxes_[2*i + 0].absVal_ = 0.0f;
-            halfAxes_[2*i + 1].absVal_ = 0.0f;
-          }
-          //COUT(3) << mouseRelative_[i] << " | ";
-          mouseRelative_[i] = 0;
-          halfAxes_[2*i + 0].hasChanged_ = true;
-          halfAxes_[2*i + 1].hasChanged_ = true;
-        }
-        deriveTime_ = 0.0f;
-        //COUT(3) << std::endl;
-      }
-      else
-        deriveTime_ += dt;
-    }
-
-    // execute all buffered bindings (addional parameter)
-    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
-      paramCommandBuffer_[i]->execute();
-
-    // always reset the relative movement of the mouse
-    if (state.mouse)
-      for (unsigned int i = 0; i < 8; i++)
-        halfAxes_[i].relVal_ = 0.0f;
-  }
-
-  void KeyBinder::keyPressed (const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::keyReleased(const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::keyHeld    (const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnHold); }
-
-
-  void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnHold); }
-
-
-  void KeyBinder::joyStickButtonPressed (int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::joyStickButtonReleased(int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::joyStickButtonHeld    (int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnHold); }
-
-  /**
-    @brief Event handler for the mouseMoved Event.
-    @param e Mouse state information
-  */
-  void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
-  {
-    // y axis of mouse input is inverted
-    int rel[] = { rel_.x, -rel_.y };
-
-    if (!bDeriveMouseInput_)
-    {
-      for (int i = 0; i < 2; i++)
-      {
-        if (rel[i])
-        {
-          // absolute
-          halfAxes_[2*i + 0].hasChanged_ = true;
-          halfAxes_[2*i + 1].hasChanged_ = true;
-          mousePosition_[i] += rel[i];
-
-          if (bClipMouse_)
-          {
-            if (mousePosition_[i] > 1024)
-              mousePosition_[i] =  1024;
-            if (mousePosition_[i] < -1024)
-              mousePosition_[i] = -1024;
-          }
-
-          if (mousePosition_[i] >= 0)
-          {
-            halfAxes_[2*i + 0].absVal_ =   mousePosition_[i]/1024.0f * mouseSensitivity_;
-            halfAxes_[2*i + 1].absVal_ =  0.0f;
-          }
-          else
-          {
-            halfAxes_[2*i + 0].absVal_ =  0.0f;
-            halfAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/1024.0f * mouseSensitivity_;
-          }
-        }
-      }
-    }
-    else
-    {
-      mouseRelative_[0] += rel[0];
-      mouseRelative_[1] += rel[1];
-    }
-
-    // relative
-    for (int i = 0; i < 2; i++)
-    {
-      if (rel[i] > 0)
-        halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
-      else
-        halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
-    }
-  }
-
-  /**
-    @brief Event handler for the mouseScrolled Event.
-    @param e Mouse state information
-  */
-  void KeyBinder::mouseScrolled(int abs, int rel)
-  {
-    //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
-
-    if (rel > 0)
-      for (int i = 0; i < rel/120; i++)
-        mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
-    else
-      for (int i = 0; i < -rel/120; i++)
-        mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
-  }
-
-  void KeyBinder::joyStickAxisMoved(int joyStickID, int axis, float value)
-  {
-    // TODO: Use proper calibration values instead of generally 16-bit integer
-    int i = 8 + axis * 2;
-    if (value >= 0)
-    {
-      //if (value > 10000)
-      //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; }
-
-      halfAxes_[i].absVal_ = value;
-      halfAxes_[i].relVal_ = value;
-      halfAxes_[i].hasChanged_ = true;
-      if (halfAxes_[i + 1].absVal_ > 0.0f)
-      {
-        halfAxes_[i + 1].absVal_ = -0.0f;
-        halfAxes_[i + 1].relVal_ = -0.0f;
-        halfAxes_[i + 1].hasChanged_ = true;
-      }
-    }
-    else
-    {
-      //if (value < -10000)
-      //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; }
-
-      halfAxes_[i + 1].absVal_ = -value;
-      halfAxes_[i + 1].relVal_ = -value;
-      halfAxes_[i + 1].hasChanged_ = true;
-      if (halfAxes_[i].absVal_ > 0.0f)
-      {
-        halfAxes_[i].absVal_ = -0.0f;
-        halfAxes_[i].relVal_ = -0.0f;
-        halfAxes_[i].hasChanged_ = true;
-      }
-    }
-  }
-
-
-  // ###############################
-  // #####     KeyDetector     #####
-  // ###############################
-
-  /**
-    @brief Constructor
-  */
-  KeyDetector::KeyDetector()
-  {
-    RegisterObject(KeyDetector);
-  }
-
-  /**
-    @brief Destructor
-  */
-  KeyDetector::~KeyDetector()
-  {
-  }
-
-  /**
-    @brief Loads the key and button bindings.
-    @return True if loading succeeded.
-  */
-  void KeyDetector::loadBindings()
-  {
-    clearBindings();
-    setConfigValues();
-  }
-
-  void KeyDetector::readTrigger(Button& button)
-  {
-    SimpleCommand* cmd = new SimpleCommand();
-    cmd->evaluation_ = CommandExecutor::evaluate("storeKeyStroke " + button.name_);
-    button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
-    button.commands_[KeybindMode::OnPress][0] = cmd;
-    button.nCommands_[KeybindMode::OnPress] = 1;
-  }
-
-
-  // ###############################
-  // ##### CalibratorCallback  #####
-  // ###############################
-
-  void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
-  {
-    if (evt.key == KeyCode::Return)
-    {
-      InputManager::setInputState(InputManager::IS_NOCALIBRATE);
-    }
-  }
-}
Index: code/branches/input/src/core/KeyBinder.h
===================================================================
--- code/branches/input/src/core/KeyBinder.h	(revision 1510)
+++ 	(revision )
@@ -1,259 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- @brief Different definitions of input processing.
- */
-
-#ifndef _KeyBinder_H__
-#define _KeyBinder_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include <vector>
-
-#include "ois/OIS.h"
-#include "util/Math.h"
-#include "OrxonoxClass.h"
-#include "CommandEvaluation.h"
-#include "InputInterfaces.h"
-
-namespace orxonox
-{
-  class _CoreExport BufferedParamCommand
-  {
-  public:
-    BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
-    bool execute();
-
-    float value_;
-    unsigned int nValuesAdded_;
-    int paramIndex_;
-    CommandEvaluation evaluation_;
-  };
-
-  class _CoreExport BaseCommand
-  {
-  public:
-    virtual ~BaseCommand() { }
-    virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
-  };
-
-  class _CoreExport SimpleCommand : public BaseCommand
-  {
-  public:
-    bool execute(float abs = 1.0f, float rel = 1.0f);
-
-    CommandEvaluation evaluation_;
-  };
-
-  class _CoreExport ParamCommand : public BaseCommand
-  {
-  public:
-    ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
-    bool execute(float abs = 1.0f, float rel = 1.0f);
-
-    bool bRelative_;
-    float paramModifier_;
-    BufferedParamCommand* paramCommand_;
-  };
-
-  class _CoreExport Button
-  {
-  public:
-    Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }
-    virtual ~Button() { clear(); }
-    virtual void clear();
-    virtual bool addParamCommand(ParamCommand* command) { return false; }
-    void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);
-    bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
-
-    //! The configured string value
-    std::string bindingString_;
-    //! Name of the trigger as strings
-    std::string name_;
-    //! Basic commands for OnPress, OnHold and OnRelease
-    BaseCommand** commands_[3];
-    //! Number of basic commands
-    unsigned int nCommands_[3];
-    //! Says how much it takes for an analog axis to trigger a button
-    //! Note: This variable is here to have only one parse() function.
-    float buttonThreshold_;
-  };
-
-
-  class _CoreExport HalfAxis : public Button
-  {
-  public:
-    HalfAxis() : relVal_(0.0f), absVal_(0.0f), paramCommands_(0), nParamCommands_(0),
-                 wasDown_(false), hasChanged_(false) { }
-    using Button::execute;
-    bool execute();
-    //bool execute(KeybindMode::Enum mode) { return Button::execute(mode); }
-    bool addParamCommand(ParamCommand* command);
-    void clear();
-
-    // axis related
-    float relVal_;
-    float absVal_;
-    ParamCommand** paramCommands_;
-    unsigned int nParamCommands_;
-
-    // button related
-    bool wasDown_;
-    bool hasChanged_;
-  };
-
-
-  /**
-    @brief Handles mouse, keyboard and joy stick input while in the actual game mode.
-           Manages the key bindings.
-  */
-  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
-  {
-  public:
-    KeyBinder ();
-    virtual ~KeyBinder();
-
-    void loadBindings();
-    void clearBindings();
-    void setConfigValues();
-    void resetJoyStickAxes();
-
-  protected: // functions
-    void tickInput(float dt, const HandlerState& state);
-
-    virtual void readTrigger(Button& button);
-
-    void keyPressed (const KeyEvent& evt);
-    void keyReleased(const KeyEvent& evt);
-    void keyHeld    (const KeyEvent& evt);
-
-    void mouseButtonPressed (MouseButton::Enum id);
-    void mouseButtonReleased(MouseButton::Enum id);
-    void mouseButtonHeld    (MouseButton::Enum id);
-    void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
-    void mouseScrolled      (int abs, int rel);
-
-    void joyStickButtonPressed (int joyStickID, int button);
-    void joyStickButtonReleased(int joyStickID, int button);
-    void joyStickButtonHeld    (int joyStickID, int button);
-    void joyStickAxisMoved     (int joyStickID, int axis, float value);
-
-  protected: // variables
-    //! denotes the number of different keys there are in OIS.
-    static const unsigned int nKeys_s = 0xEE;
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button keys_ [nKeys_s];
-
-    //! denotes the number of different mouse buttons there are in OIS.
-    static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button mouseButtons_ [nMouseButtons_s];
-
-    //! denotes the number of different joy stick buttons there are in OIS.
-    static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button joyStickButtons_ [nJoyStickButtons_s];
-
-    //! denotes the number of half axes (every axis twice) there can be.
-    static const unsigned int nHalfAxes_s = 56;
-    /**
-    * Array with all the half axes for mouse and joy sticks.
-    * Keep in mind that the positions are fixed and that the first entry is the
-    * positive one and the second is negative.
-    * Sequence is as follows:
-    *  0 -  3: Mouse x and y
-    *  4 -  7: empty
-    *  8 - 23: joy stick slider axes 1 to 8
-    * 24 - 55: joy stick axes 1 - 16
-    */
-    HalfAxis halfAxes_[nHalfAxes_s];
-
-    /**
-    * Commands that have additional parameters (axes) are executed at the end of
-    * the tick() so that all values can be buffered for single execution.
-    */
-    std::vector<BufferedParamCommand*> paramCommandBuffer_;
-
-    //! Keeps track of the absolute mouse value (incl. scroll wheel)
-    int mousePosition_[2];
-    //! Used to derive mouse input if requested
-    int mouseRelative_[2];
-    float deriveTime_;
-
-    //##### ConfigValues #####
-    //! Threshold for analog triggers until which the state is 0.
-    float analogThreshold_;
-    //! Threshold for analog triggers until which the button is not pressed.
-    float buttonThreshold_;
-    //! Derive mouse input for absolute values?
-    bool bDeriveMouseInput_;
-    //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
-    float derivePeriod_;
-    //! mouse sensitivity
-    float mouseSensitivity_;
-    //! mouse sensitivity if mouse input is derived
-    float mouseSensitivityDerived_;
-    //! Whether or not to clip abslute mouse values to 1024
-    bool bClipMouse_;
-  };
-
-
-  class _CoreExport KeyDetector : public KeyBinder
-  {
-  public:
-    KeyDetector();
-    ~KeyDetector();
-    void loadBindings();
-
-  protected:
-    void readTrigger(Button& button);
-  };
-
-  class _CoreExport CalibratorCallback : public KeyHandler
-  {
-  public:
-    CalibratorCallback() {}
-    ~CalibratorCallback() {}
-
-  private:
-    void keyPressed (const KeyEvent& evt);
-    void keyReleased(const KeyEvent& evt) {}
-    void keyHeld    (const KeyEvent& evt) {}
-
-    void tickInput(float dt, const HandlerState &state) { }
-  };
-}
-
-
-
-
-#endif /* _KeyBinder_H__ */
Index: code/branches/input/src/core/Shell.cc
===================================================================
--- code/branches/input/src/core/Shell.cc	(revision 1510)
+++ code/branches/input/src/core/Shell.cc	(revision 1519)
@@ -33,5 +33,5 @@
 #include "CoreSettings.h"
 #include "ConsoleCommand.h"
-#include "InputInterfaces.h"
+#include "input/InputInterfaces.h"
 
 #define SHELL_UPDATE_LISTENERS(function) \
Index: code/branches/input/src/core/Shell.h
===================================================================
--- code/branches/input/src/core/Shell.h	(revision 1510)
+++ code/branches/input/src/core/Shell.h	(revision 1519)
@@ -36,5 +36,5 @@
 
 #include "OrxonoxClass.h"
-#include "InputBuffer.h"
+#include "input/InputBuffer.h"
 #include "OutputBuffer.h"
 
Index: code/branches/input/src/core/input/InputBuffer.cc
===================================================================
--- code/branches/input/src/core/input/InputBuffer.cc	(revision 1519)
+++ code/branches/input/src/core/input/InputBuffer.cc	(revision 1519)
@@ -0,0 +1,257 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "InputBuffer.h"
+
+#include <iostream>
+
+#include "util/Clipboard.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    InputBuffer::InputBuffer()
+    {
+        RegisterObject(InputBuffer);
+
+        this->buffer_ = "";
+        this->cursor_ = 0;
+        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
+                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
+                               äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
+                               0123456789 \
+                               \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    InputBuffer::InputBuffer(const std::string allowedChars)
+    {
+        RegisterObject(InputBuffer);
+
+        this->allowedChars_ = allowedChars;
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    void InputBuffer::setConfigValues()
+    {
+        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
+        SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
+
+        if (keyRepeatDeleay_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatDeleay_);
+        }
+        if (keyRepeatTime_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatTime_);
+        }
+    }
+
+    void InputBuffer::set(const std::string& input, bool update)
+    {
+        this->clear(false);
+        this->insert(input, update);
+    }
+
+    void InputBuffer::insert(const std::string& input, bool update)
+    {
+        for (unsigned int i = 0; i < input.size(); ++i)
+        {
+            this->insert(input[i], false);
+
+            if (update)
+                this->updated(input[i], false);
+        }
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::insert(const char& input, bool update)
+    {
+        if (this->charIsAllowed(input))
+        {
+            this->buffer_.insert(this->cursor_, 1, input);
+            ++this->cursor_;
+        }
+
+        if (update)
+            this->updated(input, true);
+    }
+
+    void InputBuffer::clear(bool update)
+    {
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::removeBehindCursor(bool update)
+    {
+        if (this->cursor_ > 0)
+        {
+            --this->cursor_;
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::removeAtCursor(bool update)
+    {
+        if (this->cursor_ < this->buffer_.size())
+        {
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::updated()
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->bListenToAllChanges_)
+                (*it)->callFunction();
+        }
+    }
+
+    void InputBuffer::updated(const char& update, bool bSingleInput)
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))
+                (*it)->callFunction();
+        }
+    }
+
+    bool InputBuffer::charIsAllowed(const char& input)
+    {
+        if (this->allowedChars_ == "")
+            return true;
+        else
+            return (this->allowedChars_.find(input) != std::string::npos);
+    }
+
+
+    void InputBuffer::processKey(const KeyEvent &evt)
+    {
+        if (evt.isModifierDown(KeyboardModifier::Alt) && evt.key == KeyCode::Tab)
+            return;
+
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key))
+                (*it)->callFunction();
+        }
+
+        if (evt.isModifierDown(KeyboardModifier::Ctrl))
+        {
+            if (evt.key == KeyCode::V)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::C)
+                toClipboard(this->buffer_);
+            else if (evt.key == KeyCode::X)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+        else if (evt.isModifierDown(KeyboardModifier::Shift))
+        {
+            if (evt.key == KeyCode::Insert)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::Delete)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+
+        this->insert((char)evt.text);
+    }
+
+    /**
+        @brief This tick() function is called by the InputManager if the InputBuffer is active.
+        @param dt Delta time
+    */
+    void InputBuffer::tickInput(float dt, const HandlerState& state)
+    {
+        timeSinceKeyPressed_ += dt;
+        if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
+        {
+            // initial time out has gone by, start repeating keys
+            while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
+            {
+                timeSinceKeyRepeated_ += keyRepeatTime_;
+                keysToRepeat_++;
+            }
+        }
+    }
+
+    void InputBuffer::keyPressed(const KeyEvent &evt)
+    {
+        lastKey_ = evt.key;
+        timeSinceKeyPressed_ = 0.0;
+        timeSinceKeyRepeated_ = keyRepeatDeleay_;
+        keysToRepeat_ = 0;
+
+        processKey(evt);
+    }
+
+    void InputBuffer::keyHeld(const KeyEvent& evt)
+    {
+        if (evt.key == lastKey_)
+        {
+            while (keysToRepeat_)
+            {
+                processKey(evt);
+                keysToRepeat_--;
+            }
+        }
+    }
+}
Index: code/branches/input/src/core/input/InputBuffer.h
===================================================================
--- code/branches/input/src/core/input/InputBuffer.h	(revision 1519)
+++ code/branches/input/src/core/input/InputBuffer.h	(revision 1519)
@@ -0,0 +1,189 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _InputBuffer_H__
+#define _InputBuffer_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class BaseInputBufferListenerTuple
+    {
+    public:
+        BaseInputBufferListenerTuple(bool bListenToAllChanges, bool bOnlySingleInput,
+            bool trueKeyFalseChar, char _char, KeyCode::Enum key)
+            : bListenToAllChanges_(bListenToAllChanges), bOnlySingleInput_(bOnlySingleInput),
+              trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key)
+        { }
+        virtual ~BaseInputBufferListenerTuple() { }
+        virtual void callFunction() = 0;
+        bool bListenToAllChanges_;
+        bool bOnlySingleInput_;
+        bool trueKeyFalseChar_;
+        char char_;
+        KeyCode::Enum key_;
+    };
+
+    template <class T>
+    class InputBufferListenerTuple : public BaseInputBufferListenerTuple
+    {
+    public:
+        InputBufferListenerTuple(T* listener, void (T::*function)(), bool bListenToAllChanges,
+            bool bOnlySingleInput, bool trueKeyFalseChar, char _char, KeyCode::Enum key)
+            : BaseInputBufferListenerTuple(bListenToAllChanges, bOnlySingleInput, trueKeyFalseChar, _char, key),
+              listener_(listener), function_(function)
+        { }
+        virtual ~InputBufferListenerTuple() { }
+        void callFunction()
+        {
+            (listener_->*function_)();
+        }
+        T* listener_;
+        void (T::*function_)();
+    };
+
+    class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
+    {
+        public:
+            InputBuffer();
+            InputBuffer(const std::string allowedChars);
+
+            void setConfigValues();
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), KeyCode::Enum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, KeyCode::Enum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void unregisterListener(T* listener)
+            {
+                for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+                {
+                    InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
+                    if (refListener && refListener->listener_ == listener)
+                        this->listeners_.erase(it++);
+                    else
+                        it++;
+                }
+            }
+
+            void set(const std::string& input, bool update = true);
+            void insert(const std::string& input, bool update = true);
+            void insert(const char& input, bool update = true);
+            void clear(bool update = true);
+            void removeAtCursor(bool update = true);
+            void removeBehindCursor(bool update = true);
+
+            void updated();
+            void updated(const char& update, bool bSingleInput);
+
+            inline std::string get() const
+                { return this->buffer_; }
+            inline unsigned int getSize() const
+                { return this->buffer_.size(); }
+
+            inline unsigned int getCursorPosition() const
+                { return this->cursor_; }
+            inline void setCursorPosition(unsigned int cursor)
+                { if (cursor <= this->buffer_.size()) { this->cursor_ = cursor; } }
+            inline void setCursorToEnd()
+                { this->cursor_ = this->buffer_.size(); }
+            inline void setCursorToBegin()
+                { this->cursor_ = 0; }
+            inline void increaseCursor()
+                { if (this->cursor_ < this->buffer_.size()) { ++this->cursor_; } }
+            inline void decreaseCursor()
+                { if (this->cursor_ > 0) { --this->cursor_; } }
+
+        private:
+            bool charIsAllowed(const char& input);
+
+            void keyPressed (const KeyEvent& evt);
+            void keyReleased(const KeyEvent& evt) { }
+            void keyHeld    (const KeyEvent& evt);
+            void processKey (const KeyEvent &e);
+
+            void tickInput(float dt, const HandlerState& state);
+
+            std::string buffer_;
+            std::list<BaseInputBufferListenerTuple*> listeners_;
+            std::string allowedChars_;
+            unsigned int cursor_;
+
+            KeyCode::Enum lastKey_;
+            float timeSinceKeyPressed_;
+            float timeSinceKeyRepeated_;
+            int keysToRepeat_;
+
+            float keyRepeatDeleay_;
+            float keyRepeatTime_;
+    };
+}
+
+#endif /* _InputBuffer_H__ */
Index: code/branches/input/src/core/input/InputInterfaces.h
===================================================================
--- code/branches/input/src/core/input/InputInterfaces.h	(revision 1519)
+++ code/branches/input/src/core/input/InputInterfaces.h	(revision 1519)
@@ -0,0 +1,322 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Declarations of various interface classes for the input management.
+*/
+
+#ifndef _InputInterfaces_H__
+#define _InputInterfaces_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ois/OIS.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+  namespace KeyCode
+  {
+    // note: KeyCode comments were directly taken from OISKeyboard.h
+    enum Enum
+    {
+      Unassigned    = OIS::KC_UNASSIGNED,  
+      Escape        = OIS::KC_ESCAPE,      
+      NumRow1       = OIS::KC_1,           
+      NumRow2       = OIS::KC_2,           
+      NumRow3       = OIS::KC_3,           
+      NumRow4       = OIS::KC_4,           
+      NumRow5       = OIS::KC_5,           
+      NumRow6       = OIS::KC_6,           
+      NumRow7       = OIS::KC_7,           
+      NumRow8       = OIS::KC_8,           
+      NumRow9       = OIS::KC_9,           
+      NumRow0       = OIS::KC_0,           
+      Minus         = OIS::KC_MINUS,           // - on main keyboard
+      Equals        = OIS::KC_EQUALS,      
+      Back          = OIS::KC_BACK,            // backspace
+      Tab           = OIS::KC_TAB,         
+      Q             = OIS::KC_Q,           
+      W             = OIS::KC_W,           
+      E             = OIS::KC_E,           
+      R             = OIS::KC_R,           
+      T             = OIS::KC_T,           
+      Y             = OIS::KC_Y,           
+      U             = OIS::KC_U,           
+      I             = OIS::KC_I,           
+      O             = OIS::KC_O,           
+      P             = OIS::KC_P,           
+      LeftBracket   = OIS::KC_LBRACKET,    
+      RightBracket  = OIS::KC_RBRACKET,    
+      Return        = OIS::KC_RETURN,          // Enter on main keyboard
+      LeftControl   = OIS::KC_LCONTROL,    
+      A             = OIS::KC_A,           
+      S             = OIS::KC_S,           
+      D             = OIS::KC_D,           
+      F             = OIS::KC_F,           
+      G             = OIS::KC_G,           
+      H             = OIS::KC_H,           
+      J             = OIS::KC_J,           
+      K             = OIS::KC_K,           
+      L             = OIS::KC_L,           
+      Semicolon     = OIS::KC_SEMICOLON,   
+      Apostrophe    = OIS::KC_APOSTROPHE,  
+      Grave         = OIS::KC_GRAVE,           // accent
+      LeftShift     = OIS::KC_LSHIFT,      
+      Backslash     = OIS::KC_BACKSLASH,   
+      Z             = OIS::KC_Z,           
+      X             = OIS::KC_X,           
+      C             = OIS::KC_C,           
+      V             = OIS::KC_V,           
+      B             = OIS::KC_B,           
+      N             = OIS::KC_N,           
+      M             = OIS::KC_M,           
+      Comma         = OIS::KC_COMMA,       
+      Period        = OIS::KC_PERIOD,          // . on main keyboard
+      Slash         = OIS::KC_SLASH,           // / on main keyboard
+      RightShift    = OIS::KC_RSHIFT,      
+      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
+      LeftAlt       = OIS::KC_LMENU,           // left Alt
+      Space         = OIS::KC_SPACE,       
+      CapsLock      = OIS::KC_CAPITAL,     
+      F1            = OIS::KC_F1,          
+      F2            = OIS::KC_F2,          
+      F3            = OIS::KC_F3,          
+      F4            = OIS::KC_F4,          
+      F5            = OIS::KC_F5,          
+      F6            = OIS::KC_F6,          
+      F7            = OIS::KC_F7,          
+      F8            = OIS::KC_F8,          
+      F9            = OIS::KC_F9,          
+      F10           = OIS::KC_F10,         
+      Numlock       = OIS::KC_NUMLOCK,     
+      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
+      Numpad7       = OIS::KC_NUMPAD7,     
+      Numpad8       = OIS::KC_NUMPAD8,     
+      Numpad9       = OIS::KC_NUMPAD9,     
+      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
+      Numpad4       = OIS::KC_NUMPAD4,     
+      Numpad5       = OIS::KC_NUMPAD5,     
+      Numpad6       = OIS::KC_NUMPAD6,     
+      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
+      Numpad1       = OIS::KC_NUMPAD1,     
+      Numpad2       = OIS::KC_NUMPAD2,     
+      Numpad3       = OIS::KC_NUMPAD3,     
+      Numpad0       = OIS::KC_NUMPAD0,     
+      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
+      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
+      F11           = OIS::KC_F11,         
+      F12           = OIS::KC_F12,         
+      F13           = OIS::KC_F13,             //                     (NEC PC98)
+      F14           = OIS::KC_F14,             //                     (NEC PC98)
+      F15           = OIS::KC_F15,             //                     (NEC PC98)
+      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
+      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
+      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
+      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
+      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
+      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
+      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
+      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+      AT            = OIS::KC_AT,              //                     (NEC PC98)
+      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
+      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
+      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
+      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
+      AX            = OIS::KC_AX,              //                     (Japan AX)
+      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
+      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
+      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
+      RightControl  = OIS::KC_RCONTROL,    
+      Mute          = OIS::KC_MUTE,            // Mute
+      Calculator    = OIS::KC_CALCULATOR,      // Calculator
+      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
+      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
+      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
+      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
+      WebHome       = OIS::KC_WEBHOME,         // Web home
+      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
+      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
+      SYSRQ         = OIS::KC_SYSRQ,       
+      RightAlt      = OIS::KC_RMENU,           // right Alt
+      Pause         = OIS::KC_PAUSE,           // Pause
+      Home          = OIS::KC_HOME,            // Home on arrow keypad
+      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
+      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
+      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
+      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
+      End           = OIS::KC_END,             // End on arrow keypad
+      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
+      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
+      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
+      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
+      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
+      RightWindows  = OIS::KC_RWIN,            // Right Windows key
+      Apps          = OIS::KC_APPS,            // AppMenu key
+      Power         = OIS::KC_POWER,           // System Power
+      Sleep         = OIS::KC_SLEEP,           // System Sleep
+      Wake          = OIS::KC_WAKE,            // System Wake
+      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
+      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
+      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
+      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
+      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
+      WebBack       = OIS::KC_WEBBACK,         // Web Back
+      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
+      Mail          = OIS::KC_MAIL,            // Mail
+      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
+    };
+  }
+
+  namespace MouseButton
+  {
+    enum Enum
+    {
+      Left    = OIS::MB_Left,
+      Right   = OIS::MB_Right,
+      Middle  = OIS::MB_Middle,
+      Button3 = OIS::MB_Button3,
+      Button4 = OIS::MB_Button4,
+      Button5 = OIS::MB_Button5,
+      Button6 = OIS::MB_Button6,
+      Button7 = OIS::MB_Button7
+    };
+  }
+
+  namespace KeyboardModifier
+  {
+    enum Enum
+    {
+      Shift = 0x0000001,
+      Ctrl  = 0x0000010,
+      Alt   = 0x0000100
+    };
+  }
+
+  struct _CoreExport Key
+  {
+    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
+    KeyCode::Enum key;
+    unsigned int text;
+  };
+
+  class _CoreExport KeyEvent
+  {
+  public:
+    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
+    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
+    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
+    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
+
+    const KeyCode::Enum key;
+    unsigned int text;
+    unsigned int modifiers;
+  };
+
+  //typedef OIS::MouseState MouseState;
+
+  /*class _CoreExport JoyStickState
+  {
+  public:
+    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
+    JoyStickState() { clear(); }
+    int mJoyStickID;
+		JoyStickState() { clear(); }
+
+		std::vector<bool> mButtons;
+		int axes[16];
+		std::vector<Vector3> mVectors;
+  };*/
+  
+  /**
+  * Helper struct to determine which handlers of an object (can implement
+  * multiple handlers) are active.
+  */
+  struct HandlerState
+  {
+    HandlerState() : key(false), mouse(false), joyStick(false) { }
+    bool key;
+    bool mouse;
+    bool joyStick;
+  };
+
+  class _CoreExport InputTickable
+  {
+  public:
+    virtual ~InputTickable() { }
+    virtual void tickInput(float dt, const HandlerState& state) = 0;
+  };
+
+  /**
+    @brief Interface class used for key input listeners.
+  */
+  class _CoreExport KeyHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~KeyHandler() { }
+    virtual void keyPressed (const KeyEvent& evt) = 0;
+    virtual void keyReleased(const KeyEvent& evt) = 0;
+    virtual void keyHeld    (const KeyEvent& evt) = 0;
+    //virtual void tickKey    (float dt) { }
+  };
+
+  /**
+    @brief Interface class used for mouse input listeners.
+  */
+  class _CoreExport MouseHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~MouseHandler() { }
+    virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
+    virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
+    virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
+    virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+    virtual void mouseScrolled      (int abs, int rel)     = 0;
+    //virtual void tickMouse          (float dt) { }
+  };
+
+
+  /**
+    @brief Interface class used for joy stick input listeners.
+  */
+  class _CoreExport JoyStickHandler : virtual public InputTickable
+  {
+  public:
+    virtual ~JoyStickHandler() { }
+    virtual void joyStickButtonPressed (int joyStickID, int button) = 0;
+    virtual void joyStickButtonReleased(int joyStickID, int button) = 0;
+    virtual void joyStickButtonHeld    (int joyStickID, int button) = 0;
+    virtual void joyStickAxisMoved     (int joyStickID, int axis, float value) = 0;
+    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
+    //virtual void tickJoyStick          (float dt) { }
+  };
+
+}
+
+#endif /* _InputInterfaces_H__ */
Index: code/branches/input/src/core/input/InputManager.cc
===================================================================
--- code/branches/input/src/core/input/InputManager.cc	(revision 1519)
+++ code/branches/input/src/core/input/InputManager.cc	(revision 1519)
@@ -0,0 +1,1544 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Implementation of the InputManager that captures all the input from OIS
+         and redirects it to handlers.
+ */
+
+#include "InputManager.h"
+
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Debug.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/Shell.h"
+#include "InputBuffer.h"
+#include "KeyBinder.h"
+
+namespace orxonox
+{
+  SetConsoleCommandShortcut(InputManager, keyBind);
+  SetConsoleCommandShortcut(InputManager, storeKeyStroke);
+  SetConsoleCommandShortcut(InputManager, calibrate);
+
+  // ###############################
+  // ###    Internal Methods     ###
+  // ###############################
+  // ###############################
+
+  /**
+    @brief Constructor only sets member fields to initial zero values
+           and registers the class in the class hierarchy.
+  */
+  InputManager::InputManager() :
+      inputSystem_(0), keyboard_(0), mouse_(0),
+      joySticksSize_(0),
+      keyBinder_(0), keyDetector_(0), buffer_(0), calibratorCallback_(0),
+      state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT),
+      keyboardModifiers_(0)
+  {
+    RegisterObject(InputManager);
+  }
+
+  /**
+    @brief The one instance of the InputManager is stored in this function.
+    @return A reference to the only instance of the InputManager
+  */
+  InputManager& InputManager::_getSingleton()
+  {
+    static InputManager theOnlyInstance;
+    return theOnlyInstance;
+  }
+
+  /**
+    @brief Destructor only called at the end of the program, after main.
+  */
+  InputManager::~InputManager()
+  {
+    _destroy();
+  }
+
+  /**
+    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
+           the joysticks and assigns the key bindings.
+    @param windowHnd The window handle of the render window
+    @param windowWidth The width of the render window
+    @param windowHeight The height of the render window
+  */
+  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
+        bool createKeyboard, bool createMouse, bool createJoySticks)
+  {
+    if (state_ == IS_UNINIT)
+    {
+      CCOUT(3) << "Initialising Input System..." << std::endl;
+      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
+
+      OIS::ParamList paramList;
+      std::ostringstream windowHndStr;
+
+      // Fill parameter list
+      windowHndStr << (unsigned int)windowHnd;
+      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
+      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+//#if defined OIS_LINUX_PLATFORM
+//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+//#endif
+
+      try
+      {
+        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+      }
+      catch (OIS::Exception ex)
+      {
+        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
+            << "OIS message: \"" << ex.eText << "\"" << std::endl;
+        inputSystem_ = 0;
+        return false;
+      }
+
+      if (createKeyboard)
+        _initialiseKeyboard();
+
+      if (createMouse)
+        _initialiseMouse();
+
+      if (createJoySticks)
+        _initialiseJoySticks();
+
+      // Set mouse/joystick region
+      if (mouse_)
+      {
+        setWindowExtents(windowWidth, windowHeight);
+      }
+
+      state_ = IS_NONE;
+      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+
+      // InputManager holds the input buffer --> create one and add it.
+      buffer_ = new InputBuffer();
+      addKeyHandler(buffer_, "buffer");
+      Shell::getInstance().setInputBuffer(buffer_);
+
+      keyBinder_ = new KeyBinder();
+      keyBinder_->loadBindings();
+      addKeyHandler(keyBinder_, "keybinder");
+      addMouseHandler(keyBinder_, "keybinder");
+      addJoyStickHandler(keyBinder_, "keybinder");
+
+      keyDetector_ = new KeyDetector();
+      keyDetector_->loadBindings();
+      addKeyHandler(keyDetector_, "keydetector");
+      addMouseHandler(keyDetector_, "keydetector");
+      addJoyStickHandler(keyDetector_, "keydetector");
+
+      calibratorCallback_ = new CalibratorCallback();
+      addKeyHandler(calibratorCallback_, "calibratorcallback");
+
+      setConfigValues();
+
+      CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+    }
+    return true;
+  }
+
+  /**
+    @brief Creates a keyboard and sets the event handler.
+    @return False if keyboard stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseKeyboard()
+  {
+    if (keyboard_ != 0)
+    {
+      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+      {
+        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
+        // register our listener in OIS.
+        keyboard_->setEventCallback(this);
+        // note: OIS will not detect keys that have already been down when the keyboard was created.
+        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
+        return false;
+      }
+    }
+    catch (OIS::Exception ex)
+    {
+      // TODO: Test this output regarding formatting
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      keyboard_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates a mouse and sets the event handler.
+    @return False if mouse stays uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseMouse()
+  {
+    if (mouse_ != 0)
+    {
+      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
+      return true;
+    }
+    try
+    {
+      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+      {
+        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+        // register our listener in OIS.
+        mouse_->setEventCallback(this);
+        CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
+        return true;
+      }
+      else
+      {
+        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+        return false;
+      }
+    }
+    catch (OIS::Exception ex)
+    {
+      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
+          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+      mouse_ = 0;
+      return false;
+    }
+  }
+
+  /**
+    @brief Creates all joy sticks and sets the event handler.
+    @return False joy stick stay uninitialised, true otherwise.
+  */
+  bool InputManager::_initialiseJoySticks()
+  {
+    if (joySticksSize_ > 0)
+    {
+      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
+      return true;
+    }
+    bool success = false;
+    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
+    {
+      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+      {
+        try
+        {
+          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
+          joySticks_.push_back(stig);
+          // register our listener in OIS.
+          stig->setEventCallback(this);
+          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
+          success = true;
+        }
+        catch (OIS::Exception ex)
+        {
+          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
+              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+        }
+      }
+    }
+    else
+    {
+      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
+      return false;
+    }
+    joySticksSize_ = joySticks_.size();
+    activeJoyStickHandlers_.resize(joySticksSize_);
+    joyStickButtonsDown_.resize(joySticksSize_);
+    povStates_.resize(joySticksSize_);
+    sliderStates_.resize(joySticksSize_);
+    joySticksCalibration_.resize(joySticksSize_);
+    for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
+    {
+      // reset the calibration with default values
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
+        joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
+        joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
+      }
+    }
+    return success;
+  }
+
+  /**
+    @brief Sets the configurable values. Use keybindings.ini as file..
+  */
+  void InputManager::setConfigValues()
+  {
+    if (joySticksSize_)
+    {
+      std::vector<MultiTypeMath> coeffPos;
+      std::vector<MultiTypeMath> coeffNeg;
+      std::vector<MultiTypeMath> zero;
+      coeffPos.resize(24);
+      coeffNeg.resize(24);
+      zero.resize(24);
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        coeffPos[i] =  1.0f/32767.0f;
+        coeffNeg[i] =  1.0f/32768.0f;
+        zero[i]     =  0;
+      }
+
+      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffPos", coeffPos);
+          getIdentifier()->addConfigValueContainer("CoeffPos", cont);
+      }
+      cont->getValue(&coeffPos);
+
+      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffNeg", coeffNeg);
+          getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
+      }
+      cont->getValue(&coeffNeg);
+
+      cont = getIdentifier()->getConfigValueContainer("Zero");
+      if (!cont)
+      {
+          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "Zero", zero);
+          getIdentifier()->addConfigValueContainer("Zero", cont);
+      }
+      cont->getValue(&zero);
+
+      // copy values to our own variables
+      for (unsigned int i = 0; i < 24; i++)
+      {
+        joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
+        joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
+        joySticksCalibration_[0].zeroStates[i]    = zero[i];
+      }
+    }
+  }
+
+  /**
+    @brief Destroys all the created input devices and sets the InputManager to construction state.
+  */
+  void InputManager::_destroy()
+  {
+    if (state_ != IS_UNINIT)
+    {
+      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
+
+      if (buffer_)
+        delete buffer_;
+
+      if (keyBinder_)
+        delete keyBinder_;
+
+      if (keyDetector_)
+        delete keyDetector_;
+
+      if (calibratorCallback_)
+        delete calibratorCallback_;
+
+      keyHandlers_.clear();
+      mouseHandlers_.clear();
+      joyStickHandlers_.clear();
+
+      _destroyKeyboard();
+      _destroyMouse();
+      _destroyJoySticks();
+
+      activeHandlers_.clear();
+
+      // inputSystem_ can never be 0, or else the code is mistaken
+      OIS::InputManager::destroyInputSystem(inputSystem_);
+      inputSystem_ = 0;
+
+      state_ = IS_UNINIT;
+      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
+    }
+  }
+
+  /**
+    @brief Destroys the keyboard and sets it to 0.
+  */
+  void InputManager::_destroyKeyboard()
+  {
+    if (keyboard_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(keyboard_);
+    keyboard_ = 0;
+    activeKeyHandlers_.clear();
+    keysDown_.clear();
+    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys the mouse and sets it to 0.
+  */
+  void InputManager::_destroyMouse()
+  {
+    if (mouse_)
+      // inputSystem_ can never be 0, or else the code is mistaken
+      inputSystem_->destroyInputObject(mouse_);
+    mouse_ = 0;
+    activeMouseHandlers_.clear();
+    mouseButtonsDown_.clear();
+    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
+  }
+
+  /**
+    @brief Destroys all the joy sticks and resizes the lists to 0.
+  */
+  void InputManager::_destroyJoySticks()
+  {
+    if (joySticksSize_ > 0)
+    {
+      // note: inputSystem_ can never be 0, or else the code is mistaken
+      for (unsigned int i = 0; i < joySticksSize_; i++)
+        if (joySticks_[i] != 0)
+          inputSystem_->destroyInputObject(joySticks_[i]);
+
+      joySticks_.clear();
+      joySticksSize_ = 0;
+      activeJoyStickHandlers_.clear();
+      joyStickButtonsDown_.clear();
+      povStates_.clear();
+      sliderStates_.clear();
+      joySticksCalibration_.clear();
+    }
+    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
+  }
+
+  void InputManager::_saveState()
+  {
+    savedHandlers_.activeHandlers_ = activeHandlers_;
+    savedHandlers_.activeJoyStickHandlers_ = activeJoyStickHandlers_;
+    savedHandlers_.activeKeyHandlers_ = activeKeyHandlers_;
+    savedHandlers_.activeMouseHandlers_ = activeMouseHandlers_;
+  }
+
+  void InputManager::_restoreState()
+  {
+    activeHandlers_ = savedHandlers_.activeHandlers_;
+    activeJoyStickHandlers_ = savedHandlers_.activeJoyStickHandlers_;
+    activeKeyHandlers_ = savedHandlers_.activeKeyHandlers_;
+    activeMouseHandlers_ = savedHandlers_.activeMouseHandlers_;
+  }
+
+  void InputManager::_updateTickables()
+  {
+    // we can use a map to have a list of unique pointers (an object can implement all 3 handlers)
+    std::map<InputTickable*, HandlerState> tempSet;
+    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
+      tempSet[activeKeyHandlers_[iHandler]].joyStick = true;
+    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
+      tempSet[activeMouseHandlers_[iHandler]].mouse = true;
+    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+        tempSet[activeJoyStickHandlers_[iJoyStick][iHandler]].joyStick = true;
+
+    // copy the content of the map back to the actual vector
+    activeHandlers_.clear();
+    for (std::map<InputTickable*, HandlerState>::const_iterator itHandler = tempSet.begin();
+        itHandler != tempSet.end(); itHandler++)
+      activeHandlers_.push_back(std::pair<InputTickable*, HandlerState>((*itHandler).first, (*itHandler).second));
+  }
+
+
+  // #################################
+  // ### Private Interface Methods ###
+  // #################################
+  // #################################
+
+  /**
+    @brief Updates the InputManager. Tick is called by Orxonox.
+    @param dt Delta time
+  */
+  void InputManager::tick(float dt)
+  {
+    if (state_ == IS_UNINIT)
+      return;
+
+    if (state_ != stateRequest_)
+    {
+      InputState sr = stateRequest_;
+      switch (sr)
+      {
+      case IS_NORMAL:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        // normal play mode
+        // note: we assume that the handlers exist since otherwise, something's wrong anyway.
+        enableKeyHandler("keybinder");
+        enableMouseHandler("keybinder");
+        enableJoyStickHandler("keybinder", 0);
+        stateRequest_ = IS_NORMAL;
+        state_ = IS_NORMAL;
+        break;
+
+      case IS_GUI:
+        state_ = IS_GUI;
+        break;
+
+      case IS_CONSOLE:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        enableMouseHandler("keybinder");
+        enableJoyStickHandler("keybinder", 0);
+        enableKeyHandler("buffer");
+        stateRequest_ = IS_CONSOLE;
+        state_ = IS_CONSOLE;
+        break;
+
+      case IS_DETECT:
+        savedState_ = state_;
+        _saveState();
+
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+
+        enableKeyHandler("keydetector");
+        enableMouseHandler("keydetector");
+        enableJoyStickHandler("keydetector", 0);
+
+        stateRequest_ = IS_DETECT;
+        state_ = IS_DETECT;
+        break;
+
+      case IS_NODETECT:
+        _restoreState();
+        keysDown_.clear();
+        mouseButtonsDown_.clear();
+        joyStickButtonsDown_[0].clear();
+        state_ = IS_NODETECT;
+        stateRequest_ = savedState_;
+        break;
+
+      case IS_CALIBRATE:
+        if (joySticksSize_)
+        {
+          savedState_ = _getSingleton().state_;
+          for (unsigned int i = 0; i < 24; i++)
+          {
+            marginalsMax_[i] = INT_MIN;
+            marginalsMin_[i] = INT_MAX;
+          }
+          COUT(0) << "Move all joy stick axes in all directions a few times. "
+            << "Then put all axes in zero state and hit enter." << std::endl;
+
+          savedState_ = state_;
+          _saveState();
+
+          activeKeyHandlers_.clear();
+          activeMouseHandlers_.clear();
+          for (unsigned int i = 0; i < joySticksSize_; i++)
+            activeJoyStickHandlers_[i].clear();
+
+          enableKeyHandler("calibratorcallback");
+          stateRequest_ = IS_CALIBRATE;
+          state_ = IS_CALIBRATE;
+        }
+        else
+        {
+          COUT(3) << "Connot calibrate, no joy stick found!" << std::endl;
+          stateRequest_ = state_;
+        }
+        break;
+
+      case IS_NOCALIBRATE:
+        _completeCalibration();
+        _restoreState();
+        keyBinder_->resetJoyStickAxes();
+        state_ = IS_NOCALIBRATE;
+        stateRequest_ = savedState_;
+        break;
+
+      case IS_NONE:
+        activeKeyHandlers_.clear();
+        activeMouseHandlers_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; i++)
+          activeJoyStickHandlers_[i].clear();
+        state_ = IS_NONE;
+
+      default:
+        break;
+      }
+    }
+
+    // Capture all the input. This calls the event handlers in InputManager.
+    if (mouse_)
+      mouse_->capture();
+    if (keyboard_)
+      keyboard_->capture();
+    for (unsigned  int i = 0; i < joySticksSize_; i++)
+      joySticks_[i]->capture();
+
+    if (state_ != IS_CALIBRATE)
+    {
+      // call all the handlers for the held key events
+      for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+        for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
+          activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
+
+      // call all the handlers for the held mouse button events
+      for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+        for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
+          activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
+
+      // call all the handlers for the held joy stick button events
+      for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+        for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
+          for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+            activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+    }
+
+    // call the ticks for the handlers (need to be treated specially)
+    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
+      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
+  }
+
+  void InputManager::_completeCalibration()
+  {
+    for (unsigned int i = 0; i < 24; i++)
+    {
+      // positive coefficient
+      if (marginalsMax_[i] == INT_MIN)
+        marginalsMax_[i] =  32767;
+      // coefficients
+      if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
+        joySticksCalibration_[0].positiveCoeff[i] =  1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
+      else
+        joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
+
+      // config value
+      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
+
+      // negative coefficient
+      if (marginalsMin_[i] == INT_MAX)
+        marginalsMin_[i] = -32768;
+      // coefficients
+      if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
+        joySticksCalibration_[0].negativeCoeff[i] = -1.0f/(marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
+      else
+        joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
+      // config value
+      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
+
+      // zero states
+      if (i < 8)
+      {
+        if (!(i & 1))
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
+        else
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
+      }
+      else
+      {
+        if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
+          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
+        else
+          joySticksCalibration_[0].zeroStates[i] = 0;
+      }
+      // config value
+      cont = getIdentifier()->getConfigValueContainer("Zero");
+      assert(cont);
+      cont->set(i, joySticksCalibration_[0].zeroStates[i]);
+    }
+  }
+
+  // ###### Key Events ######
+
+  /**
+    @brief Event handler for the keyPressed Event.
+    @param e Event information
+  */
+  bool InputManager::keyPressed(const OIS::KeyEvent &e)
+  {
+    // check whether the key already is in the list (can happen when focus was lost)
+    unsigned int iKey = 0;
+    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
+      iKey++;
+    if (iKey == keysDown_.size())
+      keysDown_.push_back(Key(e));
+
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the keyReleased Event.
+    @param e Event information
+  */
+  bool InputManager::keyReleased(const OIS::KeyEvent &e)
+  {
+    // remove the key from the keysDown_ list
+    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+    {
+      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
+      {
+        keysDown_.erase(keysDown_.begin() + iKey);
+        break;
+      }
+    }
+
+    // update modifiers
+    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
+    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
+    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
+
+    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
+      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
+
+    return true;
+  }
+
+
+  // ###### Mouse Events ######
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Event information
+  */
+  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
+  {
+    // check for actual moved event
+    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
+            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
+    }
+
+    // check for mouse scrolled event
+    if (e.state.Z.rel != 0)
+    {
+      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+    }
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mousePressed Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // check whether the button already is in the list (can happen when focus was lost)
+    unsigned int iButton = 0;
+    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
+      iButton++;
+    if (iButton == mouseButtonsDown_.size())
+      mouseButtonsDown_.push_back((MouseButton::Enum)id);
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
+
+    return true;
+  }
+
+  /**
+    @brief Event handler for the mouseReleased Event.
+    @param e Event information
+    @param id The ID of the mouse button
+  */
+  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+  {
+    // remove the button from the keysDown_ list
+    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+    {
+      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
+      {
+        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
+        break;
+      }
+    }
+
+    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
+      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
+
+    return true;
+  }
+
+
+  // ###### Joy Stick Events ######
+
+  inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
+  {
+    // use the device to identify which one called the method
+    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+    unsigned int iJoyStick = 0;
+    while (joySticks_[iJoyStick] != joyStick)
+    {
+      iJoyStick++;
+      if (iJoyStick == joySticksSize_)
+      {
+        CCOUT(3) << "Unknown joystick fired an event. This means there is a bug somewhere! Aborting." << std::endl;
+        abort();
+      }
+    }
+    return iJoyStick;
+  }
+
+  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // check whether the button already is in the list (can happen when focus was lost)
+    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+    unsigned int iButton = 0;
+    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
+      iButton++;
+    if (iButton == buttonsDown.size())
+      buttonsDown.push_back(button);
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
+
+    return true;
+  }
+
+  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // remove the button from the joyStickButtonsDown_ list
+    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
+    {
+      if (buttonsDown[iButton] == button)
+      {
+        buttonsDown.erase(buttonsDown.begin() + iButton);
+        break;
+      }
+    }
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
+
+    return true;
+  }
+
+  void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
+  {
+    if (state_ == IS_CALIBRATE)
+    {
+      if (value > marginalsMax_[axis])
+        marginalsMax_[axis] = value;
+      if (value < marginalsMin_[axis])
+        marginalsMin_[axis] = value;
+    }
+    else
+    {
+      float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
+      if (fValue > 0.0f)
+        fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
+      else
+        fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
+
+      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis, fValue);
+    }
+  }
+
+  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+  {
+    //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000)
+    //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;}
+
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // keep in mind that the first 8 axes are reserved for the sliders
+    _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
+
+    return true;
+  }
+
+  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000)
+    //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;}
+    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
+
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
+      _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
+    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
+      _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
+
+    return true;
+  }
+
+  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    // translate the POV into 8 simple buttons
+    int lastState = povStates_[iJoyStick][id];
+    if (lastState & OIS::Pov::North)
+      buttonReleased(arg, 32 + id * 4 + 0);
+    if (lastState & OIS::Pov::South)
+      buttonReleased(arg, 32 + id * 4 + 1);
+    if (lastState & OIS::Pov::East)
+      buttonReleased(arg, 32 + id * 4 + 2);
+    if (lastState & OIS::Pov::West)
+      buttonReleased(arg, 32 + id * 4 + 3);
+
+    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
+
+    int currentState = povStates_[iJoyStick][id];
+    if (currentState & OIS::Pov::North)
+      buttonPressed(arg, 32 + id * 4 + 0);
+    if (currentState & OIS::Pov::South)
+      buttonPressed(arg, 32 + id * 4 + 1);
+    if (currentState & OIS::Pov::East)
+      buttonPressed(arg, 32 + id * 4 + 2);
+    if (currentState & OIS::Pov::West)
+      buttonPressed(arg, 32 + id * 4 + 3);
+
+    return true;
+  }
+
+  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
+  {
+    unsigned int iJoyStick = _getJoystick(arg);
+
+    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
+      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
+
+    return true;
+  }*/
+
+
+  // ################################
+  // ### Static Interface Methods ###
+  // ################################
+  // ################################
+
+  std::string InputManager::bindingCommmandString_s = "";
+
+  bool InputManager::initialise(const 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();
+  }
+
+  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().joySticksSize_;
+  }
+
+  /*bool InputManager::isKeyDown(KeyCode::Enum key)
+  {
+    if (_getSingleton().keyboard_)
+      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
+    else
+      return false;
+  }*/
+
+  /*bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
+  {
+    if (_getSingleton().keyboard_)
+      return isModifierDown(modifier);
+    else
+      return false;
+  }*/
+
+  /*const MouseState InputManager::getMouseState()
+  {
+    if (_getSingleton().mouse_)
+      return _getSingleton().mouse_->getMouseState();
+    else
+      return MouseState();
+  }*/
+
+  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
+  {
+    if (ID < _getSingleton().joySticksSize_)
+      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
+    else
+      return JoyStickState();
+  }*/
+
+  void InputManager::destroy()
+  {
+    _getSingleton()._destroy();
+  }
+
+  void InputManager::destroyKeyboard()
+  {
+    return _getSingleton()._destroyKeyboard();
+  }
+
+  void InputManager::destroyMouse()
+  {
+    return _getSingleton()._destroyMouse();
+  }
+
+  void InputManager::destroyJoySticks()
+  {
+    return _getSingleton()._destroyJoySticks();
+  }
+
+
+  /**
+    @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(const int width, const int height)
+  {
+    if (_getSingleton().mouse_)
+    {
+      // Set mouse region (if window resizes, we should alter this to reflect as well)
+      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
+      mouseState.width  = width;
+      mouseState.height = height;
+    }
+  }
+
+  /**
+    @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::setInputState(const InputState state)
+  {
+    _getSingleton().stateRequest_ = state;
+  }
+
+  /**
+    @brief Returns the current input handling method
+    @return The current input mode.
+  */
+  InputManager::InputState InputManager::getInputState()
+  {
+    return _getSingleton().state_;
+  }
+
+  void InputManager::storeKeyStroke(const std::string& name)
+  {
+    setInputState(IS_NODETECT);
+    COUT(0) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
+    CommandExecutor::execute("config KeyBinder " + name + " " + bindingCommmandString_s, false);
+  }
+
+  void InputManager::keyBind(const std::string& command)
+  {
+    bindingCommmandString_s = command;
+    setInputState(IS_DETECT);
+    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+  }
+
+  void InputManager::calibrate()
+  {
+    _getSingleton().setInputState(IS_CALIBRATE);
+  }
+
+  // ###### KeyHandler ######
+
+  /**
+    @brief Adds a new key handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Key handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeKeyHandler(const std::string &name)
+  {
+    disableKeyHandler(name);
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      _getSingleton().keyHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  KeyHandler* InputManager::getKeyHandler(const std::string& name)
+  {
+    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
+    if (it != _getSingleton().keyHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific key handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableKeyHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific key handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableKeyHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeKeyHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a key handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isKeyHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
+    if (mapIt == _getSingleton().keyHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
+          it != _getSingleton().activeKeyHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### MouseHandler ######
+  /**
+    @brief Adds a new mouse handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a Mouse handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeMouseHandler(const std::string &name)
+  {
+    disableMouseHandler(name);
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      _getSingleton().mouseHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  MouseHandler* InputManager::getMouseHandler(const std::string& name)
+  {
+    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
+    if (it != _getSingleton().mouseHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific mouse handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::enableMouseHandler(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific mouse handler.
+    @param name Unique name of the handler.
+    @return False if name was not found, true otherwise.
+  */
+  bool InputManager::disableMouseHandler(const std::string &name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // look for the handler in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+      {
+        _getSingleton().activeMouseHandlers_.erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a mouse handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isMouseHandlerActive(const std::string& name)
+  {
+    // get pointer from the map with all stored handlers
+    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
+    if (mapIt == _getSingleton().mouseHandlers_.end())
+      return false;
+    // see whether the handler already is in the list
+    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
+          it != _getSingleton().activeMouseHandlers_.end(); it++)
+    {
+      if ((*it) == (*mapIt).second)
+        return true;
+    }
+    return false;
+  }
+
+
+  // ###### JoyStickHandler ######
+
+  /**
+    @brief Adds a new joy stick handler.
+    @param handler Pointer to the handler object.
+    @param name Unique name of the handler.
+    @return True if added, false if name already existed.
+  */
+  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
+  {
+    if (!handler)
+      return false;
+    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_[name] = handler;
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Removes a JoyStick handler from the list.
+    @param name Unique name of the handler.
+    @return True if removal was successful, false if name was not found.
+  */
+  bool InputManager::removeJoyStickHandler(const std::string &name)
+  {
+    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
+          itstick != _getSingleton().joySticks_.end(); itstick++)
+      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
+
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      _getSingleton().joyStickHandlers_.erase(it);
+      return true;
+    }
+    else
+      return false;
+  }
+
+  /**
+    @brief Returns the pointer to a handler.
+    @param name Unique name of the handler.
+    @return Pointer to the instance, 0 if name was not found.
+  */
+  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
+  {
+    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
+    if (it != _getSingleton().joyStickHandlers_.end())
+    {
+      return (*it).second;
+    }
+    else
+      return 0;
+  }
+
+  /**
+    @brief Enables a specific joy stick handler that has already been added.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        return true;
+      }
+    }
+    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
+    _getSingleton().stateRequest_ = IS_CUSTOM;
+    _getSingleton()._updateTickables();
+    return true;
+  }
+
+  /**
+    @brief Disables a specific joy stick handler.
+    @param name Unique name of the handler.
+    @return False if name or id was not found, true otherwise.
+  */
+  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // look for the handler in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+      {
+        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
+        _getSingleton().stateRequest_ = IS_CUSTOM;
+        _getSingleton()._updateTickables();
+        return true;
+      }
+    }
+    return true;
+  }
+
+  /**
+    @brief Checks whether a joy stick handler is active
+    @param name Unique name of the handler.
+    @return False if key handler is not active or doesn't exist, true otherwise.
+  */
+  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
+  {
+    // get handler pointer from the map with all stored handlers
+    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
+    if (handlerIt == _getSingleton().joyStickHandlers_.end())
+      return false;
+
+    // check for existence of the ID
+    if (ID >= _getSingleton().joySticksSize_)
+      return false;
+
+    // see whether the handler already is in the list
+    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
+          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
+    {
+      if ((*it) == (*handlerIt).second)
+        return true;
+    }
+    return false;
+  }
+
+}
Index: code/branches/input/src/core/input/InputManager.h
===================================================================
--- code/branches/input/src/core/input/InputManager.h	(revision 1519)
+++ code/branches/input/src/core/input/InputManager.h	(revision 1519)
@@ -0,0 +1,260 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of a little Input handler that distributes everything
+        coming from OIS.
+ */
+
+#ifndef _InputManager_H__
+#define _InputManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <vector>
+
+#include "ois/OIS.h"
+#include "util/Math.h"
+#include "core/Tickable.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+  /**
+  * Helper class to realise a vector<int[4]>
+  */
+  class POVStates
+  {
+  public:
+    int operator[](unsigned int index) { return povStates[index]; }
+    int povStates[4];
+  };
+
+  /**
+  * Helper class to realise a vector< {int[4], int[4]} >
+  */
+  class SliderStates
+  {
+  public:
+    IntVector2 sliderStates[4];
+  };
+
+  /**
+  * Struct for storing a custom input state
+  */
+  struct StoredState
+  {
+    std::vector<KeyHandler*>                    activeKeyHandlers_;
+    std::vector<MouseHandler*>                  activeMouseHandlers_;
+    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
+  };
+
+  struct JoyStickCalibration
+  {
+    int zeroStates[24];
+    float positiveCoeff[24];
+    float negativeCoeff[24];
+  };
+
+  /**
+    @brief Captures and distributes mouse and keyboard input.
+  */
+  class _CoreExport InputManager
+        : public TickableReal,
+          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
+  {
+  public: // enumerations
+    /**
+      @brief Designates the way input is handled and redirected.
+    */
+    enum InputState
+    {
+      IS_UNINIT,    //!< InputManager has not yet been initialised.
+      IS_NONE,      //!< Input is discarded.
+      IS_NORMAL,    //!< Normal play state. Key and button bindings are active.
+      IS_GUI,       //!< All OIS input events are passed to CEGUI.
+      IS_CONSOLE,   //!< Keyboard input is redirected to the InputBuffer.
+      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
+      IS_NODETECT,  //!< remove KeyDetector
+      IS_NOCALIBRATE,
+      IS_CALIBRATE,
+      IS_CUSTOM     //!< Any possible configuration.
+    };
+
+  public: // member functions
+    void setConfigValues();
+
+  public: // static functions
+    static bool initialise(const 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 int  numberOfKeyboards();
+    static int  numberOfMice();
+    static int  numberOfJoySticks();
+
+    static void destroy();
+    static void destroyKeyboard();
+    static void destroyMouse();
+    static void destroyJoySticks();
+
+    //static bool isModifierDown(KeyboardModifier::Enum modifier);
+    //static bool isKeyDown(KeyCode::Enum key);
+    //static const MouseState getMouseState();
+    //static const JoyStickState getJoyStickState(unsigned int ID);
+
+    static void setWindowExtents(const int width, const int height);
+
+    static void setInputState(const InputState state);
+    static InputState getInputState();
+
+    static void storeKeyStroke(const std::string& name);
+    static void keyBind(const std::string& command);
+
+    static void calibrate();
+
+    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
+    static bool removeKeyHandler              (const std::string& name);
+    static KeyHandler* getKeyHandler          (const std::string& name);
+    static bool enableKeyHandler              (const std::string& name);
+    static bool disableKeyHandler             (const std::string& name);
+    static bool isKeyHandlerActive            (const std::string& name);
+
+    static bool addMouseHandler               (MouseHandler* handler, const std::string& name);
+    static bool removeMouseHandler            (const std::string& name);
+    static MouseHandler* getMouseHandler      (const std::string& name);
+    static bool enableMouseHandler            (const std::string& name);
+    static bool disableMouseHandler           (const std::string& name);
+    static bool isMouseHandlerActive          (const std::string& name);
+
+    static bool addJoyStickHandler            (JoyStickHandler* handler, const std::string& name);
+    static bool removeJoyStickHandler         (const std::string& name);
+    static JoyStickHandler* getJoyStickHandler(const std::string& name);
+    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
+    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
+    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
+
+  private: // functions
+    // don't mess with a Singleton
+    InputManager ();
+    InputManager (const InputManager&);
+    ~InputManager();
+
+    // Intenal methods
+    bool _initialise(const size_t, int, int, bool, bool, bool);
+    bool _initialiseKeyboard();
+    bool _initialiseMouse();
+    bool _initialiseJoySticks();
+
+    void _destroy();
+    void _destroyKeyboard();
+    void _destroyMouse();
+    void _destroyJoySticks();
+
+    void _updateTickables();
+
+    void _saveState();
+    void _restoreState();
+
+    void _completeCalibration();
+
+    void _fireAxis(unsigned int iJoyStick, int axis, int value);
+    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
+
+    void tick(float dt);
+
+    // input events
+    bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+    bool mouseMoved    (const OIS::MouseEvent    &arg);
+    bool keyPressed    (const OIS::KeyEvent      &arg);
+    bool keyReleased   (const OIS::KeyEvent      &arg);
+    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+    //bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
+
+    static InputManager& _getSingleton();
+    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
+
+  private: // variables
+    OIS::InputManager*                          inputSystem_;     //!< OIS input manager
+    OIS::Keyboard*                              keyboard_;        //!< OIS mouse
+    OIS::Mouse*                                 mouse_;           //!< OIS keyboard
+    std::vector<OIS::JoyStick*>                 joySticks_;       //!< OIS joy sticks
+    unsigned int                                joySticksSize_;
+
+    KeyBinder*                                  keyBinder_;       //!< KeyBinder instance
+    KeyDetector*                                keyDetector_;     //!< KeyDetector instance
+    InputBuffer*                                buffer_;          //!< InputBuffer instance
+    CalibratorCallback*                         calibratorCallback_;
+
+    InputState state_;
+    InputState stateRequest_;
+    InputState savedState_;
+    unsigned int keyboardModifiers_;
+    StoredState savedHandlers_;
+
+    // joystick calibration
+    //std::vector<int> marginalsMaxConfig_;
+    //std::vector<int> marginalsMinConfig_;
+    int marginalsMax_[24];
+    int marginalsMin_[24];
+    bool bCalibrated_;
+
+    //! Keeps track of the joy stick POV states
+    std::vector<POVStates>                      povStates_;
+    //! Keeps track of the possibly two slider axes
+    std::vector<SliderStates>                   sliderStates_;
+    std::vector<JoyStickCalibration>            joySticksCalibration_;
+
+    std::map<std::string, KeyHandler*>          keyHandlers_;
+    std::map<std::string, MouseHandler*>        mouseHandlers_;
+    std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
+
+    std::vector<KeyHandler*>                    activeKeyHandlers_;
+    std::vector<MouseHandler*>                  activeMouseHandlers_;
+    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
+    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
+
+    std::vector<Key>                            keysDown_;
+    std::vector<MouseButton::Enum>              mouseButtonsDown_;
+    std::vector<std::vector<int> >              joyStickButtonsDown_;
+
+    static std::string                          bindingCommmandString_s;
+  };
+
+}
+
+#endif /* _InputManager_H__ */
Index: code/branches/input/src/core/input/KeyBinder.cc
===================================================================
--- code/branches/input/src/core/input/KeyBinder.cc	(revision 1519)
+++ code/branches/input/src/core/input/KeyBinder.cc	(revision 1519)
@@ -0,0 +1,908 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the different input handlers.
+ */
+
+#include "KeyBinder.h"
+#include <fstream>
+#include <limits.h>
+#include "util/Convert.h"
+#include "util/SubString.h"
+#include "util/String.h"
+#include "core/Debug.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/Executor.h"
+// TODO: only needed by the CalibratorCallback class; move to new file
+#include "InputManager.h"
+
+namespace orxonox
+{
+  // ###############################
+  // ###  BufferedParamCommand   ###
+  // ###############################
+
+  /**
+  * Executes a buffered command. This is used for commands with additional
+  * parameters.
+  * @return True if command execution was successful or value was zero.
+  */
+  bool BufferedParamCommand::execute()
+  {
+    if (nValuesAdded_)
+    {
+      BufferedParamCommand& cmd = *this;
+      cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
+      // reset
+      cmd.nValuesAdded_ = 0;
+      cmd.value_ = 0;
+      return cmd.evaluation_.execute();
+    }
+    else
+      return true;
+  }
+
+  // ###############################
+  // #####    SimpleCommand    #####
+  // ###############################
+
+  /**
+  * Executes a simple command with no additional paramters.
+  * @return True if command execution was successful, false otherwise.
+  */
+  bool SimpleCommand::execute(float abs, float rel)
+  {
+    return evaluation_.execute();
+  }
+
+  // ###############################
+  // #####    ParamCommand     #####
+  // ###############################
+
+  /**
+  * Executes a parameter command. The commmand string is not directly executed,
+  * but instead stored in a buffer list so that values can be combined.
+  * @return Always true.
+  */
+  bool ParamCommand::execute(float abs, float rel)
+  {
+    BufferedParamCommand& cmd = *paramCommand_;
+    // command has an additional parameter
+    if (bRelative_)
+    {
+      if (rel != 0.0f)
+      {
+        // we have to calculate a relative movement.
+        // paramModifier_ says how much one keystroke is
+        cmd.value_ += paramModifier_ * rel;
+      }
+    }
+    else if (abs != 0.0f)
+    {
+      // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
+      // and normally this is caught in tickInput(), but that threshold cannot be to high
+      // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
+      // Someone only uses buttons with an active joystick. The joy stick value could then
+      // be 0.05 for instance and the the key value 1. Without handling the problem, the final
+      // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
+      float absQ = abs * abs;
+      float valueQ = cmd.value_ * cmd.value_;
+      if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
+      {
+        cmd.value_ = abs * paramModifier_;
+        cmd.nValuesAdded_ = 1;
+      }
+      else if (absQ * 50.0f < valueQ)
+      {
+        // abs is too small, we just don't do anything
+      }
+      else
+      {
+        // we have to calculate the absolute position of the axis.
+        // Since there might be another axis that is affected, we have to wait and
+        // store the result in a temporary place
+        cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
+      }
+    }
+    return true;
+  }
+
+  // ###############################
+  // #####       Button        #####
+  // ###############################
+
+  void Button::clear()
+  {
+    for (unsigned int j = 0; j < 3; j++)
+    {
+      if (nCommands_[j])
+      {
+        // delete all commands and the command pointer array
+        for (unsigned int i = 0; i < nCommands_[j]; i++)
+          delete commands_[j][i];
+        delete[] commands_[j];
+        commands_[j] = 0;
+        nCommands_[j] = 0;
+      }
+      else
+      {
+        commands_[j] = 0;
+      }
+    }
+  }
+
+  void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer)
+  {
+    if (isEmpty(bindingString_))
+    {
+      clear();
+      return;
+    }
+
+    // use std::vector for a temporary dynamic array
+    std::vector<BaseCommand*> commands[3];
+
+
+    // separate the commands
+    SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
+        '\\', false, '"', false, '(', ')', false, '\0');
+
+    for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
+    {
+      if (commandStrings[iCommand] != "")
+      {
+        SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
+            '\\', false, '"', false, '(', ')', false, '\0');
+
+        unsigned int iToken = 0;
+
+        // for real axes, we can feed a ButtonThreshold argument as entire command
+        if (getLowercase(tokens[0]) == "buttonthreshold")
+        {
+          if (tokens.size() == 1)
+            continue;
+          // may fail, but doesn't matter
+          convertValue(&buttonThreshold_, tokens[1]);
+          continue;
+        }
+
+        // first argument can be OnPress, OnHold OnRelease or nothing
+        KeybindMode::Enum mode = KeybindMode::None;
+        if (getLowercase(tokens[iToken]) == "onpress")
+          mode = KeybindMode::OnPress,   iToken++;
+        if (getLowercase(tokens[iToken]) == "onrelease")
+          mode = KeybindMode::OnRelease, iToken++;
+        if (getLowercase(tokens[iToken]) == "onhold")
+          mode = KeybindMode::OnHold,    iToken++;
+
+        if (iToken == tokens.size())
+          continue;
+
+        // second argument can be the amplitude for the case it as an axis command
+        // default amplitude is 1.0f
+        float paramModifier = 1.0f;
+        if (getLowercase(tokens[iToken]) == "scale")
+        {
+          iToken++;
+          if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
+          {
+            COUT(2) << "Error while parsing key binding " << name_
+                << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
+            if (iToken == tokens.size())
+              continue;
+          }
+          iToken++;
+        }
+
+        // no more arguments expected except for the actual command
+        if (iToken == tokens.size())
+          continue;
+
+        std::string commandStr;
+        while (iToken != tokens.size())
+          commandStr += tokens[iToken++] + " ";
+
+        // evaluate the command
+        CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
+        if (!eval.isValid())
+          continue;
+
+        // check for param command
+        int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
+        if (paramIndex >= 0)
+        {
+          // parameter supported command
+          ParamCommand* cmd = new ParamCommand();
+          cmd->paramModifier_ = paramModifier;
+          cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
+
+          // add command to the buffer if not yet existing
+          for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
+          {
+            if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())
+                == getLowercase(commandStr))
+            {
+              // already in list
+              cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
+              break;
+            }
+          }
+          if (cmd->paramCommand_ == 0)
+          {
+            cmd->paramCommand_ = new BufferedParamCommand();
+            paramCommandBuffer.push_back(cmd->paramCommand_);
+            cmd->paramCommand_->evaluation_ = eval;
+            cmd->paramCommand_->paramIndex_ = paramIndex;
+          }
+
+
+          // we don't know whether this is an actual axis or just a button
+          if (mode == KeybindMode::None)
+          {
+            if (!addParamCommand(cmd))
+            {
+              mode = eval.getConsoleCommand()->getKeybindMode();
+              commands[mode].push_back(cmd);
+            }
+          }
+        }
+        else
+        {
+          SimpleCommand* cmd = new SimpleCommand();
+          cmd->evaluation_ = eval;
+
+          if (mode == KeybindMode::None)
+            mode = eval.getConsoleCommand()->getKeybindMode();
+
+          commands[mode].push_back(cmd);
+        }
+      }
+    }
+
+    for (unsigned int j = 0; j < 3; j++)
+    {
+      nCommands_[j] = commands[j].size();
+      if (nCommands_[j])
+      {
+        commands_[j] = new BaseCommand*[nCommands_[j]];
+        for (unsigned int i = 0; i < commands[j].size(); i++)
+          commands_[j][i] = commands[j][i];
+      }
+      else
+        commands_[j] = 0;
+    }
+  }
+
+  bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
+  {
+    // execute all the parsed commands in the string
+    for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
+      commands_[mode][iCommand]->execute(abs, rel);
+    return true;
+  }
+
+  // ###############################
+  // #####      HalfAxis       #####
+  // ###############################
+
+  void HalfAxis::clear()
+  {
+    Button::clear();
+    if (nParamCommands_)
+    {
+      // delete all commands and the command pointer array
+      for (unsigned int i = 0; i < nParamCommands_; i++)
+        delete paramCommands_[i];
+      delete[] paramCommands_;
+      nParamCommands_ = 0;
+    }
+    else
+    {
+      nParamCommands_ = 0; nParamCommands_ = 0;
+    }
+  }
+
+  bool HalfAxis::addParamCommand(ParamCommand* command)
+  {
+    ParamCommand** cmds = paramCommands_;
+    paramCommands_ = new ParamCommand*[++nParamCommands_];
+    unsigned int i;
+    for (i = 0; i < nParamCommands_ - 1; i++)
+      paramCommands_[i] = cmds[i];
+    paramCommands_[i] = command;
+    if (nParamCommands_ > 1)
+      delete[] cmds;
+    return true;
+  }
+
+  bool HalfAxis::execute()
+  {
+    bool success = true;
+    for (unsigned int i = 0; i < nParamCommands_; i++)
+      success = success && paramCommands_[i]->execute(absVal_, relVal_);
+    return success;
+  }
+
+
+  // ###############################
+  // ######     KeyBinder     ######
+  // ###############################
+
+  /**
+    @brief Constructor that does as little as necessary.
+  */
+  KeyBinder::KeyBinder() : deriveTime_(0.0f)
+  {
+    mouseRelative_[0] = 0;
+    mouseRelative_[1] = 0;
+    mousePosition_[0] = 0;
+    mousePosition_[1] = 0;
+
+    RegisterObject(KeyBinder);
+
+    // keys
+    std::string keyNames[] = {
+      "UNASSIGNED",
+      "ESCAPE",
+      "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
+      "MINUS", "EQUALS", "BACK", "TAB",
+      "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
+      "LBRACKET", "RBRACKET",
+      "RETURN", "LCONTROL",
+      "A", "S", "D", "F", "G", "H", "J", "K", "L",
+      "SEMICOLON", "APOSTROPHE", "GRAVE",
+      "LSHIFT", "BACKSLASH",
+      "Z", "X", "C", "V", "B", "N", "M",
+      "COMMA", "PERIOD", "SLASH",
+      "RSHIFT",
+      "MULTIPLY",
+      "LMENU",
+      "SPACE",
+      "CAPITAL",
+      "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
+      "NUMLOCK", "SCROLL",
+      "NUMPAD7", "NUMPAD8", "NUMPAD9",
+      "SUBTRACT",
+      "NUMPAD4", "NUMPAD5", "NUMPAD6",
+      "ADD",
+      "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0",
+      "DECIMAL",
+      "","",
+      "OEM_102",
+      "F11", "F12",
+      "","","","","","","","","","","",
+      "F13", "F14", "F15",
+      "","","","","","","","","","",
+      "KANA",
+      "","",
+      "ABNT_C1",
+      "","","","","",
+      "CONVERT",
+      "",
+      "NOCONVERT",
+      "",
+      "YEN",
+      "ABNT_C2",
+      "","","","","","","","","","","","","","",
+      "NUMPADEQUALS",
+      "","",
+      "PREVTRACK",
+      "AT",
+      "COLON", "UNDERLINE",
+      "KANJI",
+      "STOP",
+      "AX",
+      "UNLABELED",
+      "NEXTTRACK",
+      "","",
+      "NUMPADENTER",
+      "RCONTROL",
+      "","",
+      "MUTE",
+      "CALCULATOR",
+      "PLAYPAUSE",
+      "",
+      "MEDIASTOP",
+      "","","","","","","","","",
+      "VOLUMEDOWN",
+      "",
+      "VOLUMEUP",
+      "",
+      "WEBHOME",
+      "NUMPADCOMMA",
+      "",
+      "DIVIDE",
+      "",
+      "SYSRQ",
+      "RMENU",
+      "","","","","","","","","","","","",
+      "PAUSE",
+      "",
+      "HOME",
+      "UP",
+      "PGUP",
+      "",
+      "LEFT",
+      "",
+      "RIGHT",
+      "",
+      "END", "DOWN", "PGDOWN", "INSERT", "DELETE",
+      "","","","","","","",
+      "LWIN", "RWIN", "APPS",
+      "POWER", "SLEEP",
+      "","","",
+      "WAKE",
+      "",
+      "WEBSEARCH", "WEBFAVORITES", "WEBREFRESH", "WEBSTOP", "WEBFORWARD", "WEBBACK",
+      "MYCOMPUTER", "MAIL", "MEDIASELECT"
+    };
+    for (unsigned int i = 0; i < nKeys_s; i++)
+      keys_[i].name_ = "Key" + keyNames[i];
+
+    // mouse buttons
+    std::string mouseButtonNames[] = {
+      "MouseLeft", "MouseRight", "MouseMiddle",
+      "MouseButton3", "MouseButton4", "MouseButton5",
+      "MouseButton6", "MouseButton7",
+      "MouseWheel1Up", "MouseWheel1Down",
+      "MouseWheel2Up", "MouseWheel2Down" };
+    for (unsigned int i = 0; i < nMouseButtons_s; i++)
+      mouseButtons_[i].name_ = mouseButtonNames[i];
+
+    // joy stick buttons
+    for (unsigned int i = 0; i < 32; i++)
+      joyStickButtons_[i].name_ = "JoyButton" + getConvertedValue<int, std::string>(i);
+    for (unsigned int i = 32; i < nJoyStickButtons_s; i += 4)
+    {
+		  joyStickButtons_[i + 0].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
+		  joyStickButtons_[i + 1].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
+		  joyStickButtons_[i + 2].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
+		  joyStickButtons_[i + 3].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
+    }
+
+    // half axes
+    std::string rawNames[nHalfAxes_s/2];
+    rawNames[0] = "MouseX";
+    rawNames[1] = "MouseY";
+    rawNames[2] = "Empty1";
+    rawNames[3] = "Empty2";
+    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
+      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
+    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
+    {
+      halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
+      halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
+    }
+
+    for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
+      halfAxes_[i].buttonThreshold_ = buttonThreshold_;
+  }
+
+  /**
+    @brief Destructor
+  */
+  KeyBinder::~KeyBinder()
+  {
+    // almost no destructors required because most of the arrays are static.
+    clearBindings(); // does some destruction work
+  }
+
+  /**
+    @brief Loads the key and button bindings.
+    @return True if loading succeeded.
+  */
+  void KeyBinder::loadBindings()
+  {
+    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
+
+    clearBindings();
+
+    std::ifstream infile;
+    infile.open("keybindings.ini");
+    if (!infile.is_open())
+    {
+      ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "def_keybindings.ini");
+      ConfigFileManager::getSingleton()->save(CFT_Keybindings, "keybindings.ini");
+    }
+    infile.close();
+    ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
+
+    // parse key bindings
+    setConfigValues();
+
+    COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
+  }
+
+  /**
+    @brief Loader for the key bindings, managed by config values.
+  */
+  void KeyBinder::setConfigValues()
+  {
+    SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.01f)  .description("Threshold for analog axes until which the state is 0.");
+    SetConfigValueGeneric(KeyBinder, mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
+    SetConfigValueGeneric(KeyBinder, bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
+    SetConfigValueGeneric(KeyBinder, derivePeriod_, 0.5f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
+    SetConfigValueGeneric(KeyBinder, mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
+    SetConfigValueGeneric(KeyBinder, bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
+
+    float oldThresh = buttonThreshold_;
+    SetConfigValueGeneric(KeyBinder, buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
+    if (oldThresh != buttonThreshold_)
+      for (unsigned int i = 0; i < nHalfAxes_s; i++)
+        if (halfAxes_[i].buttonThreshold_ == oldThresh)
+          halfAxes_[i].buttonThreshold_ = buttonThreshold_;
+
+    // keys
+    for (unsigned int i = 0; i < nKeys_s; i++)
+      readTrigger(keys_[i]);
+    // mouse buttons
+    for (unsigned int i = 0; i < nMouseButtons_s; i++)
+      readTrigger(mouseButtons_[i]);
+    // joy stick buttons
+    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
+      readTrigger(joyStickButtons_[i]);
+    // half axes
+    for (unsigned int i = 0; i < nHalfAxes_s; i++)
+      readTrigger(halfAxes_[i]);
+  }
+
+  void KeyBinder::readTrigger(Button& button)
+  {
+    // config value stuff
+    ConfigValueContainer* cont = ClassManager<KeyBinder>::getIdentifier()->getConfigValueContainer(button.name_);
+    if (!cont)
+    {
+      cont = new ConfigValueContainer(CFT_Keybindings, ClassManager<KeyBinder>::getIdentifier(), button.name_, "");
+      ClassManager<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
+    }
+    std::string old = button.bindingString_;
+    cont->getValue(&button.bindingString_);
+
+    // keybinder stuff
+    if (old != button.bindingString_)
+    {
+      // clear everything so we don't get old axis ParamCommands mixed up
+      button.clear();
+
+      // binding has changed
+      button.parse(paramCommandBuffer_);
+    }
+  }
+
+  /**
+    @brief Overwrites all bindings with ""
+  */
+  void KeyBinder::clearBindings()
+  {
+    for (unsigned int i = 0; i < nKeys_s; i++)
+      keys_[i].clear();
+
+    for (unsigned int i = 0; i < nMouseButtons_s; i++)
+      mouseButtons_[i].clear();
+
+    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
+      joyStickButtons_[i].clear();
+
+    for (unsigned int i = 0; i < nHalfAxes_s; i++)
+      halfAxes_[i].clear();
+
+    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+      delete paramCommandBuffer_[i];
+    paramCommandBuffer_.clear();
+  }
+
+  void KeyBinder::resetJoyStickAxes()
+  {
+    for (unsigned int i = 8; i < nHalfAxes_s; i++)
+    {
+      halfAxes_[i].absVal_ = 0.0f;
+      halfAxes_[i].relVal_ = 0.0f;
+    }
+  }
+
+  void KeyBinder::tickInput(float dt, const HandlerState& state)
+  {
+    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
+    unsigned int iBegin = 8;
+    unsigned int iEnd   = 8;
+    if (state.joyStick)
+      iEnd = nHalfAxes_s;
+    if (state.mouse)
+      iBegin = 0;
+    for (unsigned int i = iBegin; i < iEnd; i++)
+    {
+      if (halfAxes_[i].hasChanged_)
+      {
+        if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
+        {
+          halfAxes_[i].wasDown_ = true;
+          if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
+            halfAxes_[i].execute(KeybindMode::OnPress);
+        }
+        else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
+        {
+          halfAxes_[i].wasDown_ = false;
+          if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
+            halfAxes_[i].execute(KeybindMode::OnRelease);
+        }
+        halfAxes_[i].hasChanged_ = false;
+      }
+
+      if (halfAxes_[i].wasDown_)
+      {
+        if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
+          halfAxes_[i].execute(KeybindMode::OnHold);
+      }
+
+      // these are the actually useful axis bindings for analog input AND output
+      if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
+      {
+        //COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl;
+        halfAxes_[i].execute();
+      }
+    }
+
+    if (bDeriveMouseInput_ && state.mouse)
+    {
+      if (deriveTime_ > derivePeriod_)
+      {
+        //CCOUT(3) << "mouse abs: ";
+        for (int i = 0; i < 2; i++)
+        {
+          if (mouseRelative_[i] > 0)
+          {
+            halfAxes_[2*i + 0].absVal_ =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+            halfAxes_[2*i + 1].absVal_ = 0.0f;
+          }
+          else if (mouseRelative_[i] < 0)
+          {
+            halfAxes_[2*i + 0].absVal_ = 0.0f;
+            halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+          }
+          else
+          {
+            halfAxes_[2*i + 0].absVal_ = 0.0f;
+            halfAxes_[2*i + 1].absVal_ = 0.0f;
+          }
+          //COUT(3) << mouseRelative_[i] << " | ";
+          mouseRelative_[i] = 0;
+          halfAxes_[2*i + 0].hasChanged_ = true;
+          halfAxes_[2*i + 1].hasChanged_ = true;
+        }
+        deriveTime_ = 0.0f;
+        //COUT(3) << std::endl;
+      }
+      else
+        deriveTime_ += dt;
+    }
+
+    // execute all buffered bindings (addional parameter)
+    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+      paramCommandBuffer_[i]->execute();
+
+    // always reset the relative movement of the mouse
+    if (state.mouse)
+      for (unsigned int i = 0; i < 8; i++)
+        halfAxes_[i].relVal_ = 0.0f;
+  }
+
+  void KeyBinder::keyPressed (const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::keyReleased(const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::keyHeld    (const KeyEvent& evt)
+  { keys_[evt.key].execute(KeybindMode::OnHold); }
+
+
+  void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
+  { mouseButtons_[id].execute(KeybindMode::OnHold); }
+
+
+  void KeyBinder::joyStickButtonPressed (int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnPress); }
+
+  void KeyBinder::joyStickButtonReleased(int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnRelease); }
+
+  void KeyBinder::joyStickButtonHeld    (int joyStickID, int button)
+  { joyStickButtons_[button].execute(KeybindMode::OnHold); }
+
+  /**
+    @brief Event handler for the mouseMoved Event.
+    @param e Mouse state information
+  */
+  void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
+  {
+    // y axis of mouse input is inverted
+    int rel[] = { rel_.x, -rel_.y };
+
+    if (!bDeriveMouseInput_)
+    {
+      for (int i = 0; i < 2; i++)
+      {
+        if (rel[i])
+        {
+          // absolute
+          halfAxes_[2*i + 0].hasChanged_ = true;
+          halfAxes_[2*i + 1].hasChanged_ = true;
+          mousePosition_[i] += rel[i];
+
+          if (bClipMouse_)
+          {
+            if (mousePosition_[i] > 1024)
+              mousePosition_[i] =  1024;
+            if (mousePosition_[i] < -1024)
+              mousePosition_[i] = -1024;
+          }
+
+          if (mousePosition_[i] >= 0)
+          {
+            halfAxes_[2*i + 0].absVal_ =   mousePosition_[i]/1024.0f * mouseSensitivity_;
+            halfAxes_[2*i + 1].absVal_ =  0.0f;
+          }
+          else
+          {
+            halfAxes_[2*i + 0].absVal_ =  0.0f;
+            halfAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/1024.0f * mouseSensitivity_;
+          }
+        }
+      }
+    }
+    else
+    {
+      mouseRelative_[0] += rel[0];
+      mouseRelative_[1] += rel[1];
+    }
+
+    // relative
+    for (int i = 0; i < 2; i++)
+    {
+      if (rel[i] > 0)
+        halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
+      else
+        halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
+    }
+  }
+
+  /**
+    @brief Event handler for the mouseScrolled Event.
+    @param e Mouse state information
+  */
+  void KeyBinder::mouseScrolled(int abs, int rel)
+  {
+    //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
+
+    if (rel > 0)
+      for (int i = 0; i < rel/120; i++)
+        mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+    else
+      for (int i = 0; i < -rel/120; i++)
+        mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+  }
+
+  void KeyBinder::joyStickAxisMoved(int joyStickID, int axis, float value)
+  {
+    // TODO: Use proper calibration values instead of generally 16-bit integer
+    int i = 8 + axis * 2;
+    if (value >= 0)
+    {
+      //if (value > 10000)
+      //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; }
+
+      halfAxes_[i].absVal_ = value;
+      halfAxes_[i].relVal_ = value;
+      halfAxes_[i].hasChanged_ = true;
+      if (halfAxes_[i + 1].absVal_ > 0.0f)
+      {
+        halfAxes_[i + 1].absVal_ = -0.0f;
+        halfAxes_[i + 1].relVal_ = -0.0f;
+        halfAxes_[i + 1].hasChanged_ = true;
+      }
+    }
+    else
+    {
+      //if (value < -10000)
+      //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; }
+
+      halfAxes_[i + 1].absVal_ = -value;
+      halfAxes_[i + 1].relVal_ = -value;
+      halfAxes_[i + 1].hasChanged_ = true;
+      if (halfAxes_[i].absVal_ > 0.0f)
+      {
+        halfAxes_[i].absVal_ = -0.0f;
+        halfAxes_[i].relVal_ = -0.0f;
+        halfAxes_[i].hasChanged_ = true;
+      }
+    }
+  }
+
+
+  // ###############################
+  // #####     KeyDetector     #####
+  // ###############################
+
+  /**
+    @brief Constructor
+  */
+  KeyDetector::KeyDetector()
+  {
+    RegisterObject(KeyDetector);
+  }
+
+  /**
+    @brief Destructor
+  */
+  KeyDetector::~KeyDetector()
+  {
+  }
+
+  /**
+    @brief Loads the key and button bindings.
+    @return True if loading succeeded.
+  */
+  void KeyDetector::loadBindings()
+  {
+    clearBindings();
+    setConfigValues();
+  }
+
+  void KeyDetector::readTrigger(Button& button)
+  {
+    SimpleCommand* cmd = new SimpleCommand();
+    cmd->evaluation_ = CommandExecutor::evaluate("storeKeyStroke " + button.name_);
+    button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
+    button.commands_[KeybindMode::OnPress][0] = cmd;
+    button.nCommands_[KeybindMode::OnPress] = 1;
+  }
+
+
+  // ###############################
+  // ##### CalibratorCallback  #####
+  // ###############################
+
+  void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
+  {
+    if (evt.key == KeyCode::Return)
+    {
+      InputManager::setInputState(InputManager::IS_NOCALIBRATE);
+    }
+  }
+}
Index: code/branches/input/src/core/input/KeyBinder.h
===================================================================
--- code/branches/input/src/core/input/KeyBinder.h	(revision 1519)
+++ code/branches/input/src/core/input/KeyBinder.h	(revision 1519)
@@ -0,0 +1,259 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ @brief Different definitions of input processing.
+ */
+
+#ifndef _KeyBinder_H__
+#define _KeyBinder_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <vector>
+
+#include "ois/OIS.h"
+#include "util/Math.h"
+#include "core/OrxonoxClass.h"
+#include "core/CommandEvaluation.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+  class _CoreExport BufferedParamCommand
+  {
+  public:
+    BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
+    bool execute();
+
+    float value_;
+    unsigned int nValuesAdded_;
+    int paramIndex_;
+    CommandEvaluation evaluation_;
+  };
+
+  class _CoreExport BaseCommand
+  {
+  public:
+    virtual ~BaseCommand() { }
+    virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
+  };
+
+  class _CoreExport SimpleCommand : public BaseCommand
+  {
+  public:
+    bool execute(float abs = 1.0f, float rel = 1.0f);
+
+    CommandEvaluation evaluation_;
+  };
+
+  class _CoreExport ParamCommand : public BaseCommand
+  {
+  public:
+    ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
+    bool execute(float abs = 1.0f, float rel = 1.0f);
+
+    bool bRelative_;
+    float paramModifier_;
+    BufferedParamCommand* paramCommand_;
+  };
+
+  class _CoreExport Button
+  {
+  public:
+    Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }
+    virtual ~Button() { clear(); }
+    virtual void clear();
+    virtual bool addParamCommand(ParamCommand* command) { return false; }
+    void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);
+    bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
+
+    //! The configured string value
+    std::string bindingString_;
+    //! Name of the trigger as strings
+    std::string name_;
+    //! Basic commands for OnPress, OnHold and OnRelease
+    BaseCommand** commands_[3];
+    //! Number of basic commands
+    unsigned int nCommands_[3];
+    //! Says how much it takes for an analog axis to trigger a button
+    //! Note: This variable is here to have only one parse() function.
+    float buttonThreshold_;
+  };
+
+
+  class _CoreExport HalfAxis : public Button
+  {
+  public:
+    HalfAxis() : relVal_(0.0f), absVal_(0.0f), paramCommands_(0), nParamCommands_(0),
+                 wasDown_(false), hasChanged_(false) { }
+    using Button::execute;
+    bool execute();
+    //bool execute(KeybindMode::Enum mode) { return Button::execute(mode); }
+    bool addParamCommand(ParamCommand* command);
+    void clear();
+
+    // axis related
+    float relVal_;
+    float absVal_;
+    ParamCommand** paramCommands_;
+    unsigned int nParamCommands_;
+
+    // button related
+    bool wasDown_;
+    bool hasChanged_;
+  };
+
+
+  /**
+    @brief Handles mouse, keyboard and joy stick input while in the actual game mode.
+           Manages the key bindings.
+  */
+  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
+  {
+  public:
+    KeyBinder ();
+    virtual ~KeyBinder();
+
+    void loadBindings();
+    void clearBindings();
+    void setConfigValues();
+    void resetJoyStickAxes();
+
+  protected: // functions
+    void tickInput(float dt, const HandlerState& state);
+
+    virtual void readTrigger(Button& button);
+
+    void keyPressed (const KeyEvent& evt);
+    void keyReleased(const KeyEvent& evt);
+    void keyHeld    (const KeyEvent& evt);
+
+    void mouseButtonPressed (MouseButton::Enum id);
+    void mouseButtonReleased(MouseButton::Enum id);
+    void mouseButtonHeld    (MouseButton::Enum id);
+    void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+    void mouseScrolled      (int abs, int rel);
+
+    void joyStickButtonPressed (int joyStickID, int button);
+    void joyStickButtonReleased(int joyStickID, int button);
+    void joyStickButtonHeld    (int joyStickID, int button);
+    void joyStickAxisMoved     (int joyStickID, int axis, float value);
+
+  protected: // variables
+    //! denotes the number of different keys there are in OIS.
+    static const unsigned int nKeys_s = 0xEE;
+    //! Actual key bindings as bundle for Press, Hold and Release
+    Button keys_ [nKeys_s];
+
+    //! denotes the number of different mouse buttons there are in OIS.
+    static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
+    //! Actual key bindings as bundle for Press, Hold and Release
+    Button mouseButtons_ [nMouseButtons_s];
+
+    //! denotes the number of different joy stick buttons there are in OIS.
+    static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
+    //! Actual key bindings as bundle for Press, Hold and Release
+    Button joyStickButtons_ [nJoyStickButtons_s];
+
+    //! denotes the number of half axes (every axis twice) there can be.
+    static const unsigned int nHalfAxes_s = 56;
+    /**
+    * Array with all the half axes for mouse and joy sticks.
+    * Keep in mind that the positions are fixed and that the first entry is the
+    * positive one and the second is negative.
+    * Sequence is as follows:
+    *  0 -  3: Mouse x and y
+    *  4 -  7: empty
+    *  8 - 23: joy stick slider axes 1 to 8
+    * 24 - 55: joy stick axes 1 - 16
+    */
+    HalfAxis halfAxes_[nHalfAxes_s];
+
+    /**
+    * Commands that have additional parameters (axes) are executed at the end of
+    * the tick() so that all values can be buffered for single execution.
+    */
+    std::vector<BufferedParamCommand*> paramCommandBuffer_;
+
+    //! Keeps track of the absolute mouse value (incl. scroll wheel)
+    int mousePosition_[2];
+    //! Used to derive mouse input if requested
+    int mouseRelative_[2];
+    float deriveTime_;
+
+    //##### ConfigValues #####
+    //! Threshold for analog triggers until which the state is 0.
+    float analogThreshold_;
+    //! Threshold for analog triggers until which the button is not pressed.
+    float buttonThreshold_;
+    //! Derive mouse input for absolute values?
+    bool bDeriveMouseInput_;
+    //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
+    float derivePeriod_;
+    //! mouse sensitivity
+    float mouseSensitivity_;
+    //! mouse sensitivity if mouse input is derived
+    float mouseSensitivityDerived_;
+    //! Whether or not to clip abslute mouse values to 1024
+    bool bClipMouse_;
+  };
+
+
+  class _CoreExport KeyDetector : public KeyBinder
+  {
+  public:
+    KeyDetector();
+    ~KeyDetector();
+    void loadBindings();
+
+  protected:
+    void readTrigger(Button& button);
+  };
+
+  class _CoreExport CalibratorCallback : public KeyHandler
+  {
+  public:
+    CalibratorCallback() {}
+    ~CalibratorCallback() {}
+
+  private:
+    void keyPressed (const KeyEvent& evt);
+    void keyReleased(const KeyEvent& evt) {}
+    void keyHeld    (const KeyEvent& evt) {}
+
+    void tickInput(float dt, const HandlerState &state) { }
+  };
+}
+
+
+
+
+#endif /* _KeyBinder_H__ */
Index: code/branches/input/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/branches/input/src/orxonox/GraphicsEngine.cc	(revision 1510)
+++ code/branches/input/src/orxonox/GraphicsEngine.cc	(revision 1519)
@@ -40,5 +40,5 @@
 #include <OgreLogManager.h>
 #include <OgreTextureManager.h>
-#include "core/InputManager.h"
+#include "core/input/InputManager.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
Index: code/branches/input/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/input/src/orxonox/Orxonox.cc	(revision 1510)
+++ code/branches/input/src/orxonox/Orxonox.cc	(revision 1519)
@@ -58,5 +58,5 @@
 #include "core/Loader.h"
 #include "core/Tickable.h"
-#include "core/InputManager.h"
+#include "core/input/InputManager.h"
 #include "core/TclBind.h"
 
Index: code/branches/input/src/orxonox/console/InGameConsole.cc
===================================================================
--- code/branches/input/src/orxonox/console/InGameConsole.cc	(revision 1510)
+++ code/branches/input/src/orxonox/console/InGameConsole.cc	(revision 1519)
@@ -42,5 +42,5 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
-#include "core/InputManager.h"
+#include "core/input/InputManager.h"
 #include "util/Math.h"
 #include "GraphicsEngine.h"
Index: code/branches/input/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1510)
+++ code/branches/input/src/orxonox/objects/SpaceShip.cc	(revision 1519)
@@ -42,5 +42,5 @@
 #include "core/Debug.h"
 #include "GraphicsEngine.h"
-#include "core/InputManager.h"
+#include "core/input/InputManager.h"
 #include "particle/ParticleInterface.h"
 #include "Projectile.h"
Index: code/branches/input/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/branches/input/src/orxonox/objects/SpaceShip.h	(revision 1510)
+++ code/branches/input/src/orxonox/objects/SpaceShip.h	(revision 1519)
@@ -34,8 +34,7 @@
 
 #include "util/Math.h"
-#include "core/InputInterfaces.h"
 #include "Camera.h"
 #include "Model.h"
-#include "../tools/BillboardSet.h"
+#include "tools/BillboardSet.h"
 
 namespace orxonox
Index: code/branches/input/visual_studio/vc8/core.vcproj
===================================================================
--- code/branches/input/visual_studio/vc8/core.vcproj	(revision 1510)
+++ code/branches/input/visual_studio/vc8/core.vcproj	(revision 1519)
@@ -280,13 +280,13 @@
 				>
 				<File
-					RelativePath="..\..\src\core\InputBuffer.cc"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\core\InputManager.cc"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\core\KeyBinder.cc"
+					RelativePath="..\..\src\core\input\InputBuffer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.cc"
 					>
 				</File>
@@ -382,17 +382,17 @@
 				>
 				<File
-					RelativePath="..\..\src\core\InputBuffer.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\core\InputInterfaces.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\core\InputManager.h"
-					>
-				</File>
-				<File
-					RelativePath="..\..\src\core\KeyBinder.h"
+					RelativePath="..\..\src\core\input\InputBuffer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputInterfaces.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.h"
 					>
 				</File>
