Index: code/branches/gui/src/core/input/InputManager.cc
===================================================================
--- code/branches/gui/src/core/input/InputManager.cc	(revision 2813)
+++ code/branches/gui/src/core/input/InputManager.cc	(revision 2814)
@@ -174,5 +174,5 @@
             //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
+#if defined ORXONOX_PLATFORM_LINUX
             paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
             paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
@@ -219,5 +219,5 @@
 
             // Lowest priority empty InputState
-            stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
+            stateEmpty_ = createInputState<SimpleInputState>("empty", InputStatePriority::Empty);
             stateEmpty_->setHandler(&EMPTY_HANDLER);
             activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
@@ -229,10 +229,10 @@
 
             // KeyDetector to evaluate a pressed key's name
-            SimpleInputState* detector = createInputState<SimpleInputState>("detector", 101);
+            SimpleInputState* detector = createInputState<SimpleInputState>("detector", InputStatePriority::Detector);
             keyDetector_ = new KeyDetector();
             detector->setHandler(keyDetector_);
 
             // Joy stick calibration helper callback
-            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", 100);
+            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", InputStatePriority::Calibrator);
             calibrator->setHandler(&EMPTY_HANDLER);
             calibratorCallbackBuffer_ = new InputBuffer();
@@ -428,6 +428,6 @@
 
         // inform all states
-        for (std::map<int, InputState*>::const_iterator it = inputStatesByPriority_.begin();
-            it != inputStatesByPriority_.end(); ++it)
+        for (std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.begin();
+            it != inputStatesByName_.end(); ++it)
         {
             it->second->setNumOfJoySticks(joySticksSize_);
@@ -555,6 +555,6 @@
 
                 // destroy all user InputStates
-                while (inputStatesByPriority_.size() > 0)
-                    _destroyState((*inputStatesByPriority_.rbegin()).second);
+                while (inputStatesByName_.size() > 0)
+                    _destroyState((*inputStatesByName_.rbegin()).second);
 
                 // destroy the devices
@@ -640,5 +640,4 @@
             _updateActiveStates();
         }
-        inputStatesByPriority_.erase(state->getPriority());
         inputStatesByName_.erase(state->getName());
         delete state;
@@ -768,4 +767,6 @@
 
                 activeStates_.erase((*rit)->getPriority());
+                if ((*rit)->getPriority() < InputStatePriority::HighPriority)
+                    (*rit)->setPriority(0);
                 _updateActiveStates();
             }
@@ -782,4 +783,20 @@
                 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
 
+                if ((*rit)->getPriority() == 0)
+                {
+                    // Get smallest possible priority between 1 and maxStateStackSize_s
+                    for(std::map<int, InputState*>::const_reverse_iterator rit2 = activeStates_.rbegin();
+                        rit2 != activeStates_.rend(); ++rit2)
+                    {
+                        if (rit2->first < InputStatePriority::HighPriority)
+                        {
+                            (*rit)->setPriority(rit2->first + 1);
+                            break;
+                        }
+                    }
+                    // In case no normal handler was on the stack
+                    if ((*rit)->getPriority() == 0)
+                        (*rit)->setPriority(1);
+                }
                 activeStates_[(*rit)->getPriority()] = (*rit);
                 _updateActiveStates();
@@ -813,5 +830,5 @@
             _updateActiveStates();
 
-        // mark that we capture and distribute input
+        // mark that we now start capturing and distributing input
         internalState_ |= Ticking;
 
@@ -1246,5 +1263,7 @@
         Unique name of the handler.
     @param priority
-        Unique integer number. Higher means more prioritised.
+        Determines which InputState gets the input. Higher is better.
+        Use 0 to handle it implicitely by the order of activation.
+        Otherwise numbers larger than maxStateStackSize_s have to be used!
     @return
         True if added, false if name or priority already existed.
@@ -1258,20 +1277,24 @@
         if (inputStatesByName_.find(name) == inputStatesByName_.end())
         {
-            if (inputStatesByPriority_.find(priority)
-                == inputStatesByPriority_.end())
-            {
-                inputStatesByName_[name] = state;
-                inputStatesByPriority_[priority] = state;
-                state->setNumOfJoySticks(numberOfJoySticks());
-                state->setName(name);
+            if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
+            {
+                // Make sure we don't add two high priority states with the same priority
+                for (std::map<std::string, InputState*>::const_iterator it = this->inputStatesByName_.begin();
+                    it != this->inputStatesByName_.end(); ++it)
+                {
+                    if (it->second->getPriority() == priority)
+                    {
+                        COUT(2) << "Warning: Could not add an InputState with the same priority '"
+                            << priority << "' != 0." << std::endl;
+                        return false;
+                    }
+                }
+            }
+            inputStatesByName_[name] = state;
+            state->setNumOfJoySticks(numberOfJoySticks());
+            state->setName(name);
+            if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
                 state->setPriority(priority);
-                return true;
-            }
-            else
-            {
-                COUT(2) << "Warning: Could not add an InputState with the same priority '"
-                    << priority << "'." << std::endl;
-                return false;
-            }
+            return true;
         }
         else
@@ -1372,5 +1395,5 @@
                 {
                     // not scheduled for destruction
-                    // set prevents a state being added multiple times
+                    // prevents a state being added multiple times
                     stateEnterRequests_.insert(it->second);
                     return true;
@@ -1391,4 +1414,9 @@
     bool InputManager::requestLeaveState(const std::string& name)
     {
+        if (name == "empty")
+        {
+            COUT(2) << "InputManager: Leaving the empty state is not allowed!" << std::endl;
+            return false;
+        }
         // get pointer from the map with all stored handlers
         std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
Index: code/branches/gui/src/core/input/InputManager.h
===================================================================
--- code/branches/gui/src/core/input/InputManager.h	(revision 2813)
+++ code/branches/gui/src/core/input/InputManager.h	(revision 2814)
@@ -43,4 +43,5 @@
 #include <stack>
 #include "util/Math.h"
+#include "util/OrxEnum.h"
 #include "core/OrxonoxClass.h"
 #include "InputInterfaces.h"
@@ -74,4 +75,17 @@
         float positiveCoeff[24];
         float negativeCoeff[24];
+    };
+
+    struct InputStatePriority : OrxEnum<InputStatePriority>
+    {
+        OrxEnumConstructors(InputStatePriority);
+
+        static const int Empty        = -1;
+        static const int Dynamic      = 0;
+
+        static const int HighPriority = 1000;
+        static const int Console      = HighPriority + 0;
+        static const int Calibrator   = HighPriority + 1;
+        static const int Detector     = HighPriority + 2;
     };
 
@@ -116,5 +130,5 @@
 
         template <class T>
-        T* createInputState(const std::string& name, int priority);
+        T* createInputState(const std::string& name, InputStatePriority priority = InputStatePriority::Dynamic);
 
         InputState* getState       (const std::string& name);
@@ -202,5 +216,4 @@
 
         std::map<std::string, InputState*>  inputStatesByName_;
-        std::map<int, InputState*>          inputStatesByPriority_;
 
         std::set<InputState*>               stateEnterRequests_;   //!< Request to enter a new state
@@ -249,5 +262,5 @@
     */
     template <class T>
-    T* InputManager::createInputState(const std::string& name, int priority)
+    T* InputManager::createInputState(const std::string& name, InputStatePriority priority)
     {
         T* state = new T;
Index: code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 2813)
+++ code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 2814)
@@ -82,5 +82,5 @@
         if (Core::showsGraphics())
         {
-            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
+            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
             keyBinder_ = new KeyBinder();
             keyBinder_->loadBindings("keybindings.ini");
Index: code/branches/gui/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/branches/gui/src/orxonox/gui/GUIManager.cc	(revision 2813)
+++ code/branches/gui/src/orxonox/gui/GUIManager.cc	(revision 2814)
@@ -167,5 +167,5 @@
 
                 // register us as input handler
-                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
+                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui");
                 state->setHandler(this);
                 state->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
Index: code/branches/gui/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- code/branches/gui/src/orxonox/overlays/console/InGameConsole.cc	(revision 2813)
+++ code/branches/gui/src/orxonox/overlays/console/InGameConsole.cc	(revision 2814)
@@ -173,5 +173,5 @@
     {
         // create the corresponding input state
-        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
+        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", InputStatePriority::Console);
         inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
         bHidesAllInputChanged();
