Level H Engine
Static Public Member Functions | Private Types | Static Private Member Functions | Static Private Attributes | List of all members
InputManager Class Reference

Contains static variables and functions for use with input manager. More...

#include <InputManager.h>

Collaboration diagram for InputManager:
Collaboration graph

Static Public Member Functions

static void pollInputEvent (SDL_Event &incomingEvent)
 A static function to poll the input events. More...
 
static bool isKeyPressed (SDL_Keycode key)
 A static function to check if a specific key is pressed. More...
 
static bool isKeyReleased (SDL_Keycode key)
 A static function to check if a specific key is released. More...
 
static bool isMouseButtonPressed (uint8_t button)
 A static function to check if a specific mouse button is pressed. More...
 
static bool isMouseButtonReleased (uint8_t button)
 A static function to check if a specific mouse button is released. More...
 
static Vec2 getMousePos ()
 A static function to get the mouse position. More...
 
static void updateInputManager ()
 A static function to update the input manager. More...
 

Private Types

enum  state { PRESSED, RELEASED, NONE }
 An static enum for the state of the keys and buttons. More...
 

Static Private Member Functions

static void pollKeyEvent (SDL_Event &incomingEvent)
 A static function to poll the key input events. More...
 
static void pollMouseEvent (SDL_Event &incomingEvent)
 A function to poll the mouse input events. More...
 
static void resetKeys ()
 A function to reset the states of the keys. More...
 

Static Private Attributes

static Vec2 mousePos = Vec2(0.0f, 0.0f)
 The mouse position. More...
 
static std::unordered_map< SDL_Keycode, statekeys
 An unordered map of keys. More...
 
static std::unordered_map< uint8_t, statemouseButtons
 An unordered map of mouse buttons. More...
 

Detailed Description

Contains static variables and functions for use with input manager.

Member Enumeration Documentation

◆ state

enum InputManager::state
private

An static enum for the state of the keys and buttons.

Enumerator
PRESSED 
RELEASED 
NONE 

Member Function Documentation

◆ getMousePos()

Vec2 InputManager::getMousePos ( )
static

A static function to get the mouse position.

Returns
The position of the mouse.
Here is the caller graph for this function:

◆ isKeyPressed()

bool InputManager::isKeyPressed ( SDL_Keycode  key)
static

A static function to check if a specific key is pressed.

Parameters
keyThe key code of the key to check.
Returns
If the key is pressed.
Here is the caller graph for this function:

◆ isKeyReleased()

bool InputManager::isKeyReleased ( SDL_Keycode  key)
static

A static function to check if a specific key is released.

Parameters
keyThe key code of the key to check.
Returns
If the key is released.
Here is the caller graph for this function:

◆ isMouseButtonPressed()

bool InputManager::isMouseButtonPressed ( uint8_t  button)
static

A static function to check if a specific mouse button is pressed.

Parameters
keyThe mouse button to check.
Returns
If the mouse button is pressed.
Here is the caller graph for this function:

◆ isMouseButtonReleased()

bool InputManager::isMouseButtonReleased ( uint8_t  button)
static

A static function to check if a specific mouse button is released.

Parameters
keyThe mouse button to check.
Returns
If the mouse button is released.
Here is the caller graph for this function:

◆ pollInputEvent()

void InputManager::pollInputEvent ( SDL_Event &  incomingEvent)
static

A static function to poll the input events.

Parameters
incomingEventA reference to the SDL event.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollKeyEvent()

void InputManager::pollKeyEvent ( SDL_Event &  incomingEvent)
staticprivate

A static function to poll the key input events.

Parameters
incomingEventA reference to the SDL event.
Here is the caller graph for this function:

◆ pollMouseEvent()

void InputManager::pollMouseEvent ( SDL_Event &  incomingEvent)
staticprivate

A function to poll the mouse input events.

Parameters
incomingEventA reference to the SDL event.
Here is the caller graph for this function:

◆ resetKeys()

void InputManager::resetKeys ( )
staticprivate

A function to reset the states of the keys.

Here is the caller graph for this function:

◆ updateInputManager()

void InputManager::updateInputManager ( )
static

A static function to update the input manager.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ keys

std::unordered_map< SDL_Keycode, InputManager::state > InputManager::keys
staticprivate
Initial value:
=
{
{ SDLK_a, NONE },{ SDLK_b, NONE },{ SDLK_c, NONE },{ SDLK_d, NONE },{ SDLK_e, NONE },{ SDLK_f, NONE },{ SDLK_g, NONE },
{ SDLK_h, NONE },{ SDLK_i, NONE },{ SDLK_j, NONE },{ SDLK_k, NONE },{ SDLK_l, NONE },{ SDLK_o, NONE },{ SDLK_m, NONE },
{ SDLK_n, NONE },{ SDLK_p, NONE },{ SDLK_q, NONE },{ SDLK_r, NONE },{ SDLK_s, NONE },{ SDLK_t, NONE },{ SDLK_u, NONE },
{ SDLK_v, NONE },{ SDLK_w, NONE },{ SDLK_y, NONE },{ SDLK_x, NONE },{ SDLK_z, NONE },{ SDLK_ESCAPE, NONE },{ SDLK_SPACE, NONE },
{ SDLK_F1, NONE },{ SDLK_F2, NONE },{ SDLK_F3, NONE },{ SDLK_F4, NONE },{ SDLK_F5, NONE },{ SDLK_F6, NONE },{ SDLK_F7, NONE },
{ SDLK_F8, NONE },{ SDLK_F9, NONE },{ SDLK_F10, NONE },{ SDLK_F11, NONE },{ SDLK_F12, NONE },{ SDLK_1, NONE },{ SDLK_2, NONE },
{ SDLK_3, NONE },{ SDLK_4, NONE },{ SDLK_5, NONE },{ SDLK_6, NONE },{ SDLK_7, NONE },{ SDLK_8, NONE },{ SDLK_9, NONE },
{ SDLK_0, NONE },{ SDLK_COLON, NONE },{ SDLK_SEMICOLON, NONE },{ SDLK_LESS, NONE },{ SDLK_EQUALS, NONE },{ SDLK_GREATER, NONE },
{ SDLK_QUESTION, NONE },{ SDLK_AT, NONE },{ SDLK_LEFTBRACKET, NONE },{ SDLK_BACKSLASH, NONE },{ SDLK_RIGHTBRACKET, NONE },
{ SDLK_CARET, NONE },{ SDLK_UNDERSCORE, NONE },{ SDLK_BACKQUOTE, NONE },{ SDLK_PAUSE, NONE },{ SDLK_INSERT, NONE },
{ SDLK_HOME, NONE },{ SDLK_PAGEUP, NONE },{ SDLK_DELETE, NONE },{ SDLK_END, NONE },{ SDLK_PAGEDOWN, NONE },{ SDLK_RIGHT, NONE },
{ SDLK_LEFT, NONE },{ SDLK_DOWN, NONE },{ SDLK_UP, NONE },{ SDLK_KP_DIVIDE, NONE },{ SDLK_KP_MULTIPLY, NONE },
{ SDLK_KP_MINUS, NONE },{ SDLK_KP_PLUS, NONE },{ SDLK_KP_ENTER, NONE },{ SDLK_KP_1, NONE },{ SDLK_KP_2, NONE },
{ SDLK_KP_3, NONE },{ SDLK_KP_4, NONE },{ SDLK_KP_5, NONE },{ SDLK_KP_6, NONE },{ SDLK_KP_7, NONE },{ SDLK_KP_8, NONE },
{ SDLK_KP_9, NONE },{ SDLK_KP_0, NONE },{ SDLK_KP_PERIOD, NONE },{ SDLK_KP_EQUALS, NONE },{ SDLK_LCTRL, NONE },
{ SDLK_LSHIFT, NONE },{ SDLK_LALT, NONE },{ SDLK_RCTRL, NONE },{ SDLK_RSHIFT, NONE },{ SDLK_RALT, NONE },{ SDLK_RETURN, NONE },
{ SDLK_BACKSPACE, NONE },{ SDLK_TAB, NONE },{ SDLK_EXCLAIM, NONE },{ SDLK_QUOTEDBL, NONE },{ SDLK_HASH, NONE },
{ SDLK_PERCENT, NONE },{ SDLK_DOLLAR, NONE },{ SDLK_AMPERSAND, NONE },{ SDLK_QUOTE, NONE },{ SDLK_LEFTPAREN, NONE },
{ SDLK_RIGHTPAREN, NONE },{ SDLK_ASTERISK, NONE },{ SDLK_PLUS, NONE },{ SDLK_COMMA, NONE },{ SDLK_MINUS, NONE },
{ SDLK_PERIOD, NONE },{ SDLK_SLASH, NONE }
}

An unordered map of keys.

◆ mouseButtons

std::unordered_map< uint8_t, InputManager::state > InputManager::mouseButtons
staticprivate
Initial value:
=
{
{ SDL_BUTTON_LEFT, NONE },{ SDL_BUTTON_RIGHT, NONE }
}

An unordered map of mouse buttons.

◆ mousePos

Vec2 InputManager::mousePos = Vec2(0.0f, 0.0f)
staticprivate

The mouse position.


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