Go to the documentation of this file.
16 #ifndef SURGSIM_BLOCKS_KEYBOARDTOGGLESCOMPONENTBEHAVIOR_H
17 #define SURGSIM_BLOCKS_KEYBOARDTOGGLESCOMPONENTBEHAVIOR_H
19 #include <unordered_map>
20 #include <unordered_set>
41 SURGSIM_STATIC_REGISTRATION(KeyboardTogglesComponentBehavior);
47 typedef std::unordered_map<int, std::unordered_set<std::shared_ptr<SurgSim::Framework::Component>>>
58 void setInputComponent(std::shared_ptr<SurgSim::Framework::Component> inputComponent);
80 void update(
double dt)
override;
107 #endif //SURGSIM_BLOCKS_KEYBOARDTOGGLESCOMPONENTBEHAVIOR_H
std::shared_ptr< SurgSim::Input::InputComponent > m_inputComponent
Input component from which pressed keys come.
Definition: KeyboardTogglesComponentBehavior.h:98
KeyboardTogglesComponentBehavior(const std::string &name)
Constructor.
Definition: KeyboardTogglesComponentBehavior.cpp:32
Behaviors perform actions.
Definition: Behavior.h:41
void setInputComponent(std::shared_ptr< SurgSim::Framework::Component > inputComponent)
Set the input component from which pressed keys come.
Definition: KeyboardTogglesComponentBehavior.cpp:42
This behavior is used to control the activity of registered components.
Definition: KeyboardTogglesComponentBehavior.h:45
bool doInitialize() override
Initialize this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:81
bool doWakeUp() override
Wakeup this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:86
std::unordered_map< int, std::unordered_set< std::shared_ptr< SurgSim::Framework::Component > > > KeyboardRegistryType
Definition: KeyboardTogglesComponentBehavior.h:48
KeyCode
Definition: KeyCode.h:25
Definition: CompoundShapeToGraphics.cpp:30
void update(double dt) override
Update the behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:61
std::shared_ptr< SurgSim::Input::InputComponent > getInputComponent() const
Get the input component of this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:50
const KeyboardRegistryType & getKeyboardRegistry() const
Get the register map of this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:104
void setKeyboardRegistry(const KeyboardRegistryType &map)
Set the register map of this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:98
KeyboardRegistryType m_registry
A mapping between key and the graphical representation(s) it controls.
Definition: KeyboardTogglesComponentBehavior.h:101
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
bool m_keyPressedLastUpdate
Record if any key is pressed in last update() call.
Definition: KeyboardTogglesComponentBehavior.h:95
void registerKey(SurgSim::Devices::KeyCode key, std::shared_ptr< SurgSim::Framework::Component > component)
Register a key with a component in this behavior.
Definition: KeyboardTogglesComponentBehavior.cpp:55
SURGSIM_CLASSNAME(SurgSim::Blocks::KeyboardTogglesComponentBehavior)