[Orxonox-commit 1148] r5869 - in code/branches/core5/src/libraries/core: . input

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Oct 4 00:26:05 CEST 2009


Author: rgrieder
Date: 2009-10-04 00:26:05 +0200 (Sun, 04 Oct 2009)
New Revision: 5869

Modified:
   code/branches/core5/src/libraries/core/Core.cc
   code/branches/core5/src/libraries/core/Core.h
   code/branches/core5/src/libraries/core/input/InputManager.cc
   code/branches/core5/src/libraries/core/input/InputManager.h
   code/branches/core5/src/libraries/core/input/KeyBinderManager.cc
   code/branches/core5/src/libraries/core/input/KeyDetector.cc
   code/branches/core5/src/libraries/core/input/KeyDetector.h
Log:
Applied ScopedSingletonManager to KeyBinderManager and KeyDetector.

Modified: code/branches/core5/src/libraries/core/Core.cc
===================================================================
--- code/branches/core5/src/libraries/core/Core.cc	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/Core.cc	2009-10-03 22:26:05 UTC (rev 5869)
@@ -69,7 +69,6 @@
 #include "TclBind.h"
 #include "TclThreadManager.h"
 #include "input/InputManager.h"
-#include "input/KeyBinderManager.h"
 
 namespace orxonox
 {
@@ -289,9 +288,6 @@
         // Calls the InputManager which sets up the input devices.
         inputManager_.reset(new InputManager());
 
-        // Manages KeyBinders and makes them available
-        keyBinderManager_.reset(new KeyBinderManager());
-
         // load the CEGUI interface
         guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),
             inputManager_->getMousePosition(), graphicsManager_->isFullScreen()));
@@ -308,7 +304,6 @@
     {
         this->graphicsScope_.reset();
         this->guiManager_.reset();
-        this->keyBinderManager_.reset();
         this->inputManager_.reset();
         this->graphicsManager_.reset();
 

Modified: code/branches/core5/src/libraries/core/Core.h
===================================================================
--- code/branches/core5/src/libraries/core/Core.h	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/Core.h	2009-10-03 22:26:05 UTC (rev 5869)
@@ -99,7 +99,6 @@
             // graphical
             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
-            scoped_ptr<KeyBinderManager>  keyBinderManager_;    //!< Manages all KeyBinders
             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
             scoped_ptr<Scope<ScopeID::Root> >     rootScope_;
             scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;

Modified: code/branches/core5/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/InputManager.cc	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/input/InputManager.cc	2009-10-03 22:26:05 UTC (rev 5869)
@@ -52,7 +52,6 @@
 #include "core/GraphicsManager.h"
 
 #include "InputBuffer.h"
-#include "KeyDetector.h"
 #include "JoyStick.h"
 #include "JoyStickQuantityListener.h"
 #include "Mouse.h"
@@ -89,7 +88,6 @@
         , devices_(2)
         , bExclusiveMouse_(false)
         , emptyState_(0)
-        , keyDetector_(0)
         , calibratorCallbackHandler_(0)
     {
         RegisterRootObject(InputManager);
@@ -105,13 +103,6 @@
         emptyState_->setHandler(&InputHandler::EMPTY);
         activeStates_[emptyState_->getPriority()] = emptyState_;
 
-        // KeyDetector to evaluate a pressed key's name
-        InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
-        // Create a callback to avoid buttonHeld events after the key has been detected
-        detector->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, this));
-        keyDetector_ = new KeyDetector();
-        detector->setHandler(keyDetector_);
-
         // Joy stick calibration helper callback
         InputState* calibrator = createInputState("calibrator", false, false, InputStatePriority::Calibrator);
         calibrator->setHandler(&InputHandler::EMPTY);
@@ -273,11 +264,9 @@
         CCOUT(3) << "Destroying..." << std::endl;
 
         // Destroy calibrator helper handler and state
-        keyDetector_->destroy();
         this->destroyState("calibrator");
         // Destroy KeyDetector and state
         calibratorCallbackHandler_->destroy();
-        this->destroyState("detector");
         // destroy the empty InputState
         this->destroyStateInternal(this->emptyState_);
 

Modified: code/branches/core5/src/libraries/core/input/InputManager.h
===================================================================
--- code/branches/core5/src/libraries/core/input/InputManager.h	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/input/InputManager.h	2009-10-03 22:26:05 UTC (rev 5869)
@@ -194,7 +194,6 @@
 
         // some internally handled states and handlers
         InputState*                         emptyState_;           //!< Lowest priority states (makes handling easier)
-        KeyDetector*                        keyDetector_;          //!< KeyDetector instance
         //! InputBuffer that reacts to the Enter key when calibrating the joy sticks
         InputBuffer*                        calibratorCallbackHandler_;
 

Modified: code/branches/core5/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyBinderManager.cc	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/input/KeyBinderManager.cc	2009-10-03 22:26:05 UTC (rev 5869)
@@ -33,12 +33,14 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
 #include "InputManager.h"
 #include "KeyDetector.h"
 
 namespace orxonox
 {
     KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;
+    ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics);
 
     KeyBinderManager::KeyBinderManager()
         : currentBinder_(NULL)

Modified: code/branches/core5/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyDetector.cc	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/input/KeyDetector.cc	2009-10-03 22:26:05 UTC (rev 5869)
@@ -30,12 +30,16 @@
 
 #include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
 #include "Button.h"
+#include "InputManager.h"
+#include "InputState.h"
 
 namespace orxonox
 {
     std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
     KeyDetector* KeyDetector::singletonPtr_s = 0;
+    ManageScopedSingleton(KeyDetector, ScopeID::Graphics);
 
     KeyDetector::KeyDetector()
         : KeyBinder("")
@@ -44,8 +48,19 @@
 
         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
         this->assignCommands();
+
+        inputState_ = InputManager::getInstance().createInputState("detector", false, false, InputStatePriority::Detector);
+        // Create a callback to avoid buttonHeld events after the key has been detected
+        inputState_->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, &InputManager::getInstance()));
+        inputState_->setHandler(this);
     }
 
+    KeyDetector::~KeyDetector()
+    {
+        inputState_->setHandler(NULL);
+        InputManager::getInstance().destroyState("detector");
+    }
+
     void KeyDetector::assignCommands()
     {
         // Assign every button/axis the same command, but with its name as argument

Modified: code/branches/core5/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/branches/core5/src/libraries/core/input/KeyDetector.h	2009-10-03 22:03:14 UTC (rev 5868)
+++ code/branches/core5/src/libraries/core/input/KeyDetector.h	2009-10-03 22:26:05 UTC (rev 5869)
@@ -42,7 +42,7 @@
 
     public:
         KeyDetector();
-        ~KeyDetector() { }
+        ~KeyDetector();
 
         void setCallback(Functor* function) { this->callbackFunction_ = function; }
 
@@ -54,6 +54,7 @@
         void assignCommands();
 
         Functor* callbackFunction_;
+        InputState* inputState_;
         static std::string callbackCommand_s;
         static KeyDetector* singletonPtr_s;
     };




More information about the Orxonox-commit mailing list