This Component stores one callback for each input key pressed. When a key is pressed if there are callback linked to that key, the callback will be executed.
More...
#include <Component.hpp>
|
void | registerAction (const unsigned int &key, const std::function< void()> &callback) |
| Registers a callback to a specific key.
|
void | call (const unsigned int &key) |
| Calls the function in the map at key index.
|
std::vector< unsigned int > | getAllKeys () const |
| Retrieves all the key that are linked to a callback.
|
| InputComponent ()=default |
| Instances basic Component.
|
|
std::map< unsigned int, std::function< void()> > | callbacks |
| map containing a callback for a specified key
|
This Component stores one callback for each input key pressed. When a key is pressed if there are callback linked to that key, the callback will be executed.
- Note
- While using with GLFW before calling a callback a ogl::Window must be attached.
◆ call()
void InputComponent::call |
( |
const unsigned int & | key | ) |
|
|
inline |
Calls the function in the map at key index.
- Parameters
-
key | an unsigned int key code |
◆ getAllKeys()
std::vector< unsigned int > InputComponent::getAllKeys |
( |
| ) |
const |
|
inline |
Retrieves all the key that are linked to a callback.
- Returns
- a std::vector<unsigned int> object containing all the key registered
◆ registerAction()
void InputComponent::registerAction |
( |
const unsigned int & | key, |
|
|
const std::function< void()> & | callback ) |
|
inline |
Registers a callback to a specific key.
- Parameters
-
key | an unsigned int key code |
callback | a function to be called |
The documentation for this class was generated from the following file: