Index: code/branches/chat/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/chat/src/orxonox/CMakeLists.txt	(revision 6787)
+++ code/branches/chat/src/orxonox/CMakeLists.txt	(revision 6788)
@@ -33,4 +33,5 @@
   Radar.cc
   ChatHistory.cc
+  ChatInputHandler.cc
 COMPILATION_BEGIN SceneCompilation.cc
   CameraManager.cc
Index: code/branches/chat/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/chat/src/orxonox/ChatInputHandler.cc	(revision 6787)
+++ code/branches/chat/src/orxonox/ChatInputHandler.cc	(revision 6788)
@@ -28,20 +28,34 @@
 
 #include "ChatInputHandler.h"
+#include <core/ScopedSingletonManager.h>
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include <string>
 
 namespace orxonox 
 {
   /* singleton */
-  ManageScopedSingleton( ChatInputHandler, ScopeID::Root, false );
+  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
 
   /* constructor */
-  void ChatInputHandler::ChatInputHandler()
+  ChatInputHandler::ChatInputHandler()
   {
     /* register the object  */
     RegisterObject(ChatInputHandler);
 
+    //COUT(0) << "Singleton registered for ChatInputHandler." << std::endl;
+
     /* create necessary objects */
     this->inpbuf = new InputBuffer();
 
+    /* configure the input buffer */
 		configureInputBuffer();
+
+    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
+    this->inputState->setKeyHandler(this->inpbuf);
+
+    /* set console shortcut */
+    this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(
+      &ChatInputHandler::activate, this), "startchat"), false);
   }
 
@@ -49,37 +63,40 @@
   {
 	  /* input has changed */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::inputChanged, true);
+    this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
 		
 		/* add a line */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
+    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
+    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
 
 		/* backspace */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
+    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
+    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
 
 		/* exit the chatinputhandler thingy (tbd) */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
+    this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
 
 		/* delete character */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
+    this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
 
 		/* cursor movement */
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
-    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
   }
 
 
   /* activate, deactivate */
-  void ChatInputHandler::activate()   /* TBI */
+  void ChatInputHandler::activate()
   {
     /* start listening */
+    COUT(0) << "chatinput activated." << std::endl;
+    InputManager::getInstance().enterState("chatinput");
   }
 
-  void ChatInputHandler::deactivate()   /* TBI */
+  void ChatInputHandler::deactivate() 
   {
     /* stop listening */
+    InputManager::getInstance().leaveState("chatinput");
   }
 
@@ -99,8 +116,9 @@
     /* actually do send what was input */
     /* a) get the string out of the inputbuffer */
-    String msgtosend = this->inpbuf->get();
+    std::string msgtosend = this->inpbuf->get();
 
     /* b) clear the input buffer */
-    this->inpbuf->clear();
+    if (this->inpbuf->getSize() > 0)
+      this->inpbuf->clear();
 
     /* c) send the chat via some call */
@@ -108,9 +126,10 @@
 
     /* d) stop listening to input  */
+    this->deactivate();
   }
 
   void ChatInputHandler::backspace()
   {
-    this->inputBuffer_->removeBehindCursor();
+    this->inpbuf->removeBehindCursor();
     //this->updateListeners<&ShellListener::inputChanged>();
     //this->updateListeners<&ShellListener::cursorChanged>();
@@ -119,5 +138,5 @@
   void ChatInputHandler::deleteChar()
   {
-    this->inputBuffer_->removeAtCursor();
+    this->inpbuf->removeAtCursor();
     //this->updateListeners<&ShellListener::inputChanged>();
   }
@@ -125,5 +144,5 @@
   void ChatInputHandler::cursorRight()
   {
-    this->inputBuffer_->increaseCursor();
+    this->inpbuf->increaseCursor();
     //this->updateListeners<&ShellListener::cursorChanged>();
   }
@@ -131,5 +150,5 @@
   void ChatInputHandler::cursorLeft()
   {
-    this->inputBuffer_->decreaseCursor();
+    this->inpbuf->decreaseCursor();
     //this->updateListeners<&ShellListener::cursorChanged>();
   }
@@ -137,5 +156,5 @@
   void ChatInputHandler::cursorEnd()
   {
-    this->inputBuffer_->setCursorToEnd();
+    this->inpbuf->setCursorToEnd();
     //this->updateListeners<&ShellListener::cursorChanged>();
   }
@@ -143,5 +162,5 @@
   void ChatInputHandler::cursorHome()
   {
-    this->inputBuffer_->setCursorToBegin();
+    this->inpbuf->setCursorToBegin();
     //this->updateListeners<&ShellListener::cursorChanged>();
   }
@@ -149,5 +168,5 @@
   void ChatInputHandler::exit()
   {
-    //if (this->inputBuffer_->getSize() > 0)
+    //if (this->inpbuf->getSize() > 0)
     //{
       //this->clearInput();
Index: code/branches/chat/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/chat/src/orxonox/ChatInputHandler.h	(revision 6787)
+++ code/branches/chat/src/orxonox/ChatInputHandler.h	(revision 6788)
@@ -39,6 +39,14 @@
 /* project includes */
 #include <OrxonoxPrereqs.h>
-#include <InputBuffer.h>
-#include <Host.h>
+#include "core/input/InputBuffer.h"
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+#include "../libraries/network/Host.h"
+#include <core/BaseObject.h>
+#include <PlayerManager.h>
+#include <infos/PlayerInfo.h>
+#include <network/ChatListener.h>
+#include <core/PathConfig.h>
+#include <util/Singleton.h>
 
 
@@ -46,5 +54,6 @@
 {
   /* class to handle chat using an InputBuffer */
-  class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>
+  class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>,
+    public OrxonoxClass
   {
     private:
@@ -54,6 +63,12 @@
       InputBuffer *inpbuf;
 
-      /* setup input buffer, the constructor calls this */
+      /** input state */
+      InputState *inputState;
+
+      /** setup input buffer, the constructor calls this */
       void configureInputBuffer();
+
+      /* singleton pointer */
+      static ChatInputHandler* singletonPtr_s;
 
     public:
@@ -65,4 +80,6 @@
       void activate();
       void deactivate();
+
+      /* callbacks for input handler */
 
       void inputChanged();
