This is the input manager. It does what you expect! Nearly completely copied from GLEngine, the ol' gal. More...
#include <InputManager.hpp>
Collaboration diagram for BARE2D::InputManager:Public Member Functions | |
| InputManager () | |
| ~InputManager () | |
| void | update () |
| Updates the inputmanager. Should be called every frame. More... | |
| void | pressKey (unsigned int keyID) |
| Sets a key as 'pressed'. More... | |
| void | releaseKey (unsigned int keyID) |
| Sets a key as 'released'. More... | |
| void | setMousePosition (float x, float y) |
| Sets the mouse position to (x,y) More... | |
| void | setMousePosition (glm::vec2 position) |
| Sets the mouse position to 'position'. More... | |
| void | setMouseScrollwheelPosition (int position) |
| Sets the "position" of the scrollwheel - essentially, how much it has moved since the last frame. More... | |
| bool | isKeyDown (unsigned int keyID) const |
| Checks if the key is down at all. More... | |
| bool | isKeyPressed (unsigned int keyID) const |
| Checks if the key has just been pressed. More... | |
| char | getPressedCharacter (bool alpha=true, bool nums=true, bool all=true) const |
| Gets entered character (This just follows the first character that has been pressed this update) More... | |
| glm::vec2 | getMousePosition () const |
| Gets the position of the mouse in the window. More... | |
| int | getMouseScrollwheelPosition () const |
| Gets the position of the mousewheel. More... | |
Private Member Functions | |
| bool | wasKeyDown (unsigned int keyID) const |
| Checks if the key was down last frame. More... | |
Private Attributes | |
| std::unordered_map< unsigned int, bool > | m_keyMap |
| std::unordered_map< unsigned int, bool > | m_previousKeyMap |
| glm::vec2 | m_mousePosition |
| int | m_mouseScrollwheelPosition = 0 |
This is the input manager. It does what you expect! Nearly completely copied from GLEngine, the ol' gal.
Definition at line 12 of file InputManager.hpp.
| BARE2D::InputManager::InputManager | ( | ) |
Definition at line 7 of file InputManager.cpp.
| BARE2D::InputManager::~InputManager | ( | ) |
Definition at line 10 of file InputManager.cpp.
| glm::vec2 BARE2D::InputManager::getMousePosition | ( | ) | const |
Gets the position of the mouse in the window.
Definition at line 115 of file InputManager.cpp.
References m_mousePosition.
| int BARE2D::InputManager::getMouseScrollwheelPosition | ( | ) | const |
Gets the position of the mousewheel.
Definition at line 120 of file InputManager.cpp.
References m_mouseScrollwheelPosition.
| char BARE2D::InputManager::getPressedCharacter | ( | bool | alpha = true, |
| bool | nums = true, |
||
| bool | all = true |
||
| ) | const |
Gets entered character (This just follows the first character that has been pressed this update)
| alpha | If true, checks alphabetical characters |
| nums | If true, checks numbers |
| symbols | If true, checks all other (readable) symbols |
Definition at line 76 of file InputManager.cpp.
References isKeyDown(), and isKeyPressed().
Here is the call graph for this function:| bool BARE2D::InputManager::isKeyDown | ( | unsigned int | keyID | ) | const |
Checks if the key is down at all.
| keyID | The SDL-given ID to check against |
Definition at line 53 of file InputManager.cpp.
References m_keyMap.
Referenced by getPressedCharacter(), and isKeyPressed().
Here is the caller graph for this function:| bool BARE2D::InputManager::isKeyPressed | ( | unsigned int | keyID | ) | const |
Checks if the key has just been pressed.
| keyID | The SDL-given ID to check against |
Definition at line 70 of file InputManager.cpp.
References isKeyDown(), and wasKeyDown().
Referenced by getPressedCharacter().
Here is the call graph for this function:
Here is the caller graph for this function:| void BARE2D::InputManager::pressKey | ( | unsigned int | keyID | ) |
Sets a key as 'pressed'.
| keyID | The id given for a key by SDL |
Definition at line 25 of file InputManager.cpp.
References m_keyMap.
Referenced by BARE2D::App::pollSDLInput().
Here is the caller graph for this function:| void BARE2D::InputManager::releaseKey | ( | unsigned int | keyID | ) |
Sets a key as 'released'.
| keyID | The id given for a key by SDL |
Definition at line 31 of file InputManager.cpp.
References m_keyMap.
Referenced by BARE2D::App::pollSDLInput().
Here is the caller graph for this function:| void BARE2D::InputManager::setMousePosition | ( | float | x, |
| float | y | ||
| ) |
Sets the mouse position to (x,y)
| x | A float to represent x position |
| y | A float to represent y position |
Definition at line 37 of file InputManager.cpp.
References m_mousePosition.
Referenced by BARE2D::App::pollSDLInput().
Here is the caller graph for this function:| void BARE2D::InputManager::setMousePosition | ( | glm::vec2 | position | ) |
Sets the mouse position to 'position'.
| position | The position to set it to. |
Definition at line 43 of file InputManager.cpp.
References m_mousePosition.
| void BARE2D::InputManager::setMouseScrollwheelPosition | ( | int | position | ) |
Sets the "position" of the scrollwheel - essentially, how much it has moved since the last frame.
| position | The distance it has moved since last update. |
Definition at line 48 of file InputManager.cpp.
References m_mouseScrollwheelPosition.
Referenced by BARE2D::App::pollSDLInput().
Here is the caller graph for this function:| void BARE2D::InputManager::update | ( | ) |
Updates the inputmanager. Should be called every frame.
Definition at line 13 of file InputManager.cpp.
References m_keyMap, m_mouseScrollwheelPosition, and m_previousKeyMap.
Referenced by BARE2D::App::updateInput().
Here is the caller graph for this function:
|
private |
Checks if the key was down last frame.
| keyID | The SDL-given ID to check against |
Definition at line 125 of file InputManager.cpp.
References m_previousKeyMap.
Referenced by isKeyPressed().
Here is the caller graph for this function:
|
private |
Definition at line 97 of file InputManager.hpp.
Referenced by isKeyDown(), pressKey(), releaseKey(), and update().
|
private |
Definition at line 99 of file InputManager.hpp.
Referenced by getMousePosition(), and setMousePosition().
|
private |
Definition at line 100 of file InputManager.hpp.
Referenced by getMouseScrollwheelPosition(), setMouseScrollwheelPosition(), and update().
|
private |
Definition at line 98 of file InputManager.hpp.
Referenced by update(), and wasKeyDown().