CG-Project2
Loading...
Searching...
No Matches
InputComponent Class Reference

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>

Inheritance diagram for InputComponent:
Collaboration diagram for InputComponent:

Public Member Functions

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.

Public Attributes

std::map< unsigned int, std::function< void()> > callbacks
 map containing a callback for a specified key

Detailed Description

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.

Member Function Documentation

◆ call()

void InputComponent::call ( const unsigned int & key)
inline

Calls the function in the map at key index.

Parameters
keyan 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
keyan unsigned int key code
callbacka function to be called

The documentation for this class was generated from the following file: