Go to the documentation of this file.
16 #ifndef SURGSIM_BLOCKS_KEYBOARDCALLBACKBEHAVIOR_H
17 #define SURGSIM_BLOCKS_KEYBOARDCALLBACKBEHAVIOR_H
33 SURGSIM_STATIC_REGISTRATION(KeyboardCallbackBehavior);
64 void update(
double dt)
override;
92 #endif //SURGSIM_BLOCKS_KEYBOARDCALLBACKBEHAVIOR_H
KeyboardCallbackBehavior(const std::string &name)
Constructor.
Definition: KeyboardCallbackBehavior.cpp:30
std::shared_ptr< Input::InputComponent > m_inputComponent
Input component from which pressed key comes.
Definition: KeyboardCallbackBehavior.h:86
void registerKey(int key)
Register a key, so that when such key is pressed, this behavior will call the callback.
Definition: KeyboardCallbackBehavior.cpp:51
void registerCallback(CallbackType func)
Register a callback function.
Definition: KeyboardCallbackBehavior.cpp:95
void update(double dt) override
Update the behavior.
Definition: KeyboardCallbackBehavior.cpp:56
std::shared_ptr< Input::InputComponent > getInputComponent() const
Get the input component of this behavior, from which the pressed key comes.
Definition: KeyboardCallbackBehavior.cpp:46
Behaviors perform actions.
Definition: Behavior.h:40
Definition: CompoundShapeToGraphics.cpp:29
int m_actionKey
The registered key, when pressed, the registered callback will be called.
Definition: KeyboardCallbackBehavior.h:80
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: KeyboardCallbackBehavior.cpp:73
std::function< void()> CallbackType
Definition: KeyboardCallbackBehavior.h:39
CallbackType m_callback
Callback function.
Definition: KeyboardCallbackBehavior.h:83
bool m_keyPressedLastUpdate
Record if any key is pressed in last update() call.
Definition: KeyboardCallbackBehavior.h:77
This behavior will call the registered callback function when the registered key is pressed.
Definition: KeyboardCallbackBehavior.h:36
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: KeyboardCallbackBehavior.cpp:78
SURGSIM_CLASSNAME(SurgSim::Blocks::KeyboardCallbackBehavior)
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
int getKey() const
Definition: KeyboardCallbackBehavior.cpp:90
void setInputComponent(std::shared_ptr< Framework::Component > inputComponent)
Set the input component from which pressed key comes.
Definition: KeyboardCallbackBehavior.cpp:40