Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2009, 5:36:10 PM (15 years ago)
Author:
rgrieder
Message:

Missing changes for previous commit (whatever happened…)

File:
1 edited

Legend:

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

    r5738 r5864  
    2929#include "KeyDetector.h"
    3030
    31 #include "util/Debug.h"
     31#include "core/ConsoleCommand.h"
    3232#include "core/CoreIncludes.h"
    3333#include "Button.h"
     
    3535namespace orxonox
    3636{
    37     /**
    38     @brief
    39         Constructor
    40     */
     37    std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
     38    KeyDetector* KeyDetector::singletonPtr_s = 0;
     39
    4140    KeyDetector::KeyDetector()
     41        : KeyBinder("")
    4242    {
    4343        RegisterObject(KeyDetector);
     44
     45        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
     46        this->assignCommands();
    4447    }
    4548
    46     /**
    47     @brief
    48         Destructor
    49     */
    50     KeyDetector::~KeyDetector()
     49    void KeyDetector::assignCommands()
    5150    {
    52     }
    53 
    54     /**
    55     @brief
    56         Assigns all the buttons 'command' plus the button's name.
    57     */
    58     void KeyDetector::setCallbackCommand(const std::string& command)
    59     {
    60         callbackCommand_ = command;
     51        // Assign every button/axis the same command, but with its name as argument
    6152        clearBindings();
    6253        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    6354        {
    64             it->second->bindingString_ = callbackCommand_ + it->second->groupName_ + "." + it->second->name_;
     55            it->second->bindingString_ = callbackCommand_s + " " + it->second->groupName_ + "." + it->second->name_;
    6556            it->second->parse();
    6657        }
     58    }
     59
     60    void KeyDetector::callback(const std::string& name)
     61    {
     62        // Call the registered function
     63        if (this->callbackFunction_)
     64            (*this->callbackFunction_)(name);
    6765    }
    6866
     
    7068    {
    7169        KeyBinder::JoyStickQuantityChanged(joyStickList);
    72         if (!callbackCommand_.empty())
    73             setCallbackCommand(callbackCommand_);
     70        this->assignCommands();
    7471    }
    7572}
Note: See TracChangeset for help on using the changeset viewer.