Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Applied ScopedSingletonManager to KeyBinderManager and KeyDetector.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.