Go to the documentation of this file.
16 #ifndef SURGSIM_BLOCKS_KEYBEHAVIOR_H
17 #define SURGSIM_BLOCKS_KEYBEHAVIOR_H
45 void update(
double dt)
override;
61 static bool registerKey(
int keycode,
const std::string& description);
78 virtual void onKeyUp(
int key) = 0;
89 static std::unordered_map<int, std::string>
m_keyMap;
int m_lastKey
Keep track if the key was pressed the last time around.
Definition: KeyBehavior.h:84
void setInputComponent(std::shared_ptr< Framework::Component > inputComponent)
Set the input component from which pressed key comes.
Definition: KeyBehavior.cpp:43
static bool unregisterKey(int keycode)
Remove a key from the registry.
Definition: KeyBehavior.cpp:117
virtual void onKeyDown(int key)=0
Implement to execute functionality on key press.
Behaviors perform actions.
Definition: Behavior.h:40
void update(double dt) override
Update the behavior.
Definition: KeyBehavior.cpp:68
Definition: CompoundShapeToGraphics.cpp:29
Behavior to abstract the functionality of keyboard driven behaviors, can be programmed to react to a ...
Definition: KeyBehavior.h:36
static bool registerKey(int keycode, const std::string &description)
Register the key, this let's the system keep track of keys used in the application.
Definition: KeyBehavior.cpp:95
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: KeyBehavior.cpp:54
static boost::mutex m_keyMapMutex
Definition: KeyBehavior.h:88
~KeyBehavior()
Destructor.
Definition: KeyBehavior.cpp:39
static std::unordered_map< int, std::string > m_keyMap
Definition: KeyBehavior.h:89
KeyBehavior(const std::string &name)
Constructor.
Definition: KeyBehavior.cpp:30
std::shared_ptr< Input::InputComponent > getInputComponent() const
Get the input component of this behavior, from which the pressed key comes.
Definition: KeyBehavior.cpp:49
static void logMap()
Write the keymap out to the logger.
Definition: KeyBehavior.cpp:129
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: KeyBehavior.cpp:59
virtual void onKeyUp(int key)=0
Implement to execute functionality on key release.
std::shared_ptr< Input::InputComponent > m_inputComponent
Input component needs to provide key.
Definition: KeyBehavior.h:81