Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
Classes | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
blowbox::KeyboardState Class Reference

#include <keyboard_state.h>

Classes

struct  KeyState
 

Public Member Functions

bool GetKey (KeyCode key)
 
bool GetKeyDown (KeyCode key)
 
bool GetKeyPressed (KeyCode key)
 
bool GetKeyReleased (KeyCode key)
 
const KeyStateGetKeyState (KeyCode key)
 
Queue< unsigned int > GetInputKeys () const
 

Protected Member Functions

void SetKeyPressed (KeyCode key)
 
void SetKeyReleased (KeyCode key)
 
void SetKeyModifiers (KeyCode key, int modifiers)
 
void AddInputKey (unsigned int key)
 
void ResetKeys ()
 

Private Attributes

Map< KeyCode, KeyStatekey_states_
 
Queue< unsigned int > input_keys_
 

Friends

class GLFWManager
 
class Window
 
class ImGuiManager
 

Detailed Description

Keeps track of the state of the keyboard.

This class keeps track of the state of the keyboard. Normally, you would find access to instances of this class through Window instances, because every Window has different keyboard states. Access the KeyboardState by calling Window::GetKeyboardState().

Member Function Documentation

void blowbox::KeyboardState::AddInputKey ( unsigned int  key)
protected

Adds an input key.

Parameters
[in]keyThe key that was pressed (as a unicode id)
Queue< unsigned int > blowbox::KeyboardState::GetInputKeys ( ) const
Returns
A list of keys that were pressed over the last frame, in the correct order. Every item in the queue is a unicode ID.
Remarks
Note that this function reserves a copy of a queue of KeyCodes. This is intentional, so that you can process the queue in whatever way you want.
bool blowbox::KeyboardState::GetKey ( KeyCode  key)

Find out whether a key is down or not.

Parameters
[in]keyThe key you want to know the down-state of.
Returns
Whether the key is down or not.
bool blowbox::KeyboardState::GetKeyDown ( KeyCode  key)

Find out whether a key is down or not.

Parameters
[in]keyThe key you want to know the down-state of.
Returns
Whether the key is down or not.
bool blowbox::KeyboardState::GetKeyPressed ( KeyCode  key)

Find out whether a key is pressed or not.

Parameters
[in]keyThe key you want to know the pressed-state of.
Returns
Whether the key is pressed or not.
bool blowbox::KeyboardState::GetKeyReleased ( KeyCode  key)

Find out whether a key is released or not.

Parameters
[in]keyThe key you want to know the released-state of.
Returns
Whether the key is released or not.
const KeyboardState::KeyState & blowbox::KeyboardState::GetKeyState ( KeyCode  key)

Retrieves the full state of a key.

Parameters
[in]keyThe key you want to know the full KeyState of.
Returns
The full KeyState of a key.
void blowbox::KeyboardState::ResetKeys ( )
protected

Resets all keys by changing their press & release states to false.

void blowbox::KeyboardState::SetKeyModifiers ( KeyCode  key,
int  modifiers 
)
protected

Changes the key modifiers of a key to true.

Parameters
[in]keyThe key to be changed.
[in]modifiersThe modifiers that were pressed when the key was pressed.
void blowbox::KeyboardState::SetKeyPressed ( KeyCode  key)
protected

Changes the press-state of a key to true.

Parameters
[in]keyThe key to be changed.
void blowbox::KeyboardState::SetKeyReleased ( KeyCode  key)
protected

Changes the release-state of a key to true.

Parameters
[in]keyThe key to be changed.

Member Data Documentation

Queue<unsigned int> blowbox::KeyboardState::input_keys_
private

The keys that were pressed over the last frame, in correct order. These are stored in unicode ids.

Map<KeyCode, KeyState> blowbox::KeyboardState::key_states_
private

A map of KeyCodes to KeyStates.


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