Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2009, 12:26:05 AM (15 years ago)
Author:
rgrieder
Message:

Applied ScopedSingletonManager to KeyBinderManager and KeyDetector.

Location:
code/branches/core5/src/libraries/core/input
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/input/InputManager.cc

    r5863 r5869  
    5353
    5454#include "InputBuffer.h"
    55 #include "KeyDetector.h"
    5655#include "JoyStick.h"
    5756#include "JoyStickQuantityListener.h"
     
    9089        , bExclusiveMouse_(false)
    9190        , emptyState_(0)
    92         , keyDetector_(0)
    9391        , calibratorCallbackHandler_(0)
    9492    {
     
    105103        emptyState_->setHandler(&InputHandler::EMPTY);
    106104        activeStates_[emptyState_->getPriority()] = emptyState_;
    107 
    108         // KeyDetector to evaluate a pressed key's name
    109         InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
    110         // Create a callback to avoid buttonHeld events after the key has been detected
    111         detector->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, this));
    112         keyDetector_ = new KeyDetector();
    113         detector->setHandler(keyDetector_);
    114105
    115106        // Joy stick calibration helper callback
     
    274265
    275266        // Destroy calibrator helper handler and state
    276         keyDetector_->destroy();
    277267        this->destroyState("calibrator");
    278268        // Destroy KeyDetector and state
    279269        calibratorCallbackHandler_->destroy();
    280         this->destroyState("detector");
    281270        // destroy the empty InputState
    282271        this->destroyStateInternal(this->emptyState_);
  • code/branches/core5/src/libraries/core/input/InputManager.h

    r5863 r5869  
    195195        // some internally handled states and handlers
    196196        InputState*                         emptyState_;           //!< Lowest priority states (makes handling easier)
    197         KeyDetector*                        keyDetector_;          //!< KeyDetector instance
    198197        //! InputBuffer that reacts to the Enter key when calibrating the joy sticks
    199198        InputBuffer*                        calibratorCallbackHandler_;
  • code/branches/core5/src/libraries/core/input/KeyBinderManager.cc

    r5863 r5869  
    3434#include "core/ConsoleCommand.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/ScopedSingletonManager.h"
    3637#include "InputManager.h"
    3738#include "KeyDetector.h"
     
    4041{
    4142    KeyBinderManager* KeyBinderManager::singletonPtr_s = 0;
     43    ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics);
    4244
    4345    KeyBinderManager::KeyBinderManager()
  • code/branches/core5/src/libraries/core/input/KeyDetector.cc

    r5864 r5869  
    3131#include "core/ConsoleCommand.h"
    3232#include "core/CoreIncludes.h"
     33#include "core/ScopedSingletonManager.h"
    3334#include "Button.h"
     35#include "InputManager.h"
     36#include "InputState.h"
    3437
    3538namespace orxonox
     
    3740    std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
    3841    KeyDetector* KeyDetector::singletonPtr_s = 0;
     42    ManageScopedSingleton(KeyDetector, ScopeID::Graphics);
    3943
    4044    KeyDetector::KeyDetector()
     
    4549        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
    4650        this->assignCommands();
     51
     52        inputState_ = InputManager::getInstance().createInputState("detector", false, false, InputStatePriority::Detector);
     53        // Create a callback to avoid buttonHeld events after the key has been detected
     54        inputState_->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, &InputManager::getInstance()));
     55        inputState_->setHandler(this);
     56    }
     57
     58    KeyDetector::~KeyDetector()
     59    {
     60        inputState_->setHandler(NULL);
     61        InputManager::getInstance().destroyState("detector");
    4762    }
    4863
  • code/branches/core5/src/libraries/core/input/KeyDetector.h

    r5864 r5869  
    4343    public:
    4444        KeyDetector();
    45         ~KeyDetector() { }
     45        ~KeyDetector();
    4646
    4747        void setCallback(Functor* function) { this->callbackFunction_ = function; }
     
    5555
    5656        Functor* callbackFunction_;
     57        InputState* inputState_;
    5758        static std::string callbackCommand_s;
    5859        static KeyDetector* singletonPtr_s;
Note: See TracChangeset for help on using the changeset viewer.