MAGE  v0.171.0
Matthias Advanced Game Engine
mage::input::Keyboard Class Reference

#include <keyboard.hpp>

Public Member Functions

 Keyboard (NotNull< HWND > window, IDirectInput8 &di)
 
 Keyboard (const Keyboard &keyboard)=delete
 
 Keyboard (Keyboard &&keyboard) noexcept
 
 ~Keyboard ()
 
Keyboardoperator= (const Keyboard &keyboard)=delete
 
Keyboardoperator= (Keyboard &&keyboard)=delete
 
NotNull< HWND > GetWindow () noexcept
 
void Update () noexcept
 
bool IsActive (U8 key) const noexcept
 
bool IsPassive (U8 key) const noexcept
 
bool IsSwitched (U8 key) const noexcept
 
bool IsActivated (U8 key) const noexcept
 
bool IsDeactivated (U8 key) const noexcept
 

Private Member Functions

void InitializeKeyboard ()
 

Private Attributes

NotNull< HWND > m_window
 
IDirectInput8 & m_di
 
ComPtr< IDirectInputDevice8 > m_keyboard
 
std::bitset< 512 > m_key_states
 

Detailed Description

A class of keyboards.

Constructor & Destructor Documentation

◆ Keyboard() [1/3]

mage::input::Keyboard::Keyboard ( NotNull< HWND >  window,
IDirectInput8 &  di 
)
explicit

Constructs a keyboard.

Parameters
[in]windowThe handle of the parent window.
[in,out]diA reference to a direct input object.
Exceptions
ExceptionFailed to initialize the keyboard.

◆ Keyboard() [2/3]

mage::input::Keyboard::Keyboard ( const Keyboard keyboard)
delete

Constructs a keyboard from the given keyboard.

Parameters
[in]keyboardA reference to the keyboard to copy.

◆ Keyboard() [3/3]

mage::input::Keyboard::Keyboard ( Keyboard &&  keyboard)
defaultnoexcept

Constructs a keyboard by moving the given keyboard.

Parameters
[in]keyboardA reference to the keyboard to move.

◆ ~Keyboard()

mage::input::Keyboard::~Keyboard ( )
default

Destructs this keyboard.

Member Function Documentation

◆ GetWindow()

NotNull< HWND > mage::input::Keyboard::GetWindow ( )
noexcept

Returns the window handle of this keyboard.

Returns
The window handle of this keyboard.

◆ InitializeKeyboard()

void mage::input::Keyboard::InitializeKeyboard ( )
private

Initializes the keyboard device of this keyboard.

Exceptions
ExceptionFailed to initialize the keyboard.

◆ IsActivated()

bool mage::input::Keyboard::IsActivated ( U8  key) const
noexcept

Checks whether the given key is activated.

Parameters
[in]keyThe key.
Returns
true if the given key is activated. false otherwise.

◆ IsActive()

bool mage::input::Keyboard::IsActive ( U8  key) const
noexcept

Checks whether the given key is active.

Parameters
[in]keyThe key.
Returns
true if the given key is active. false otherwise.

◆ IsDeactivated()

bool mage::input::Keyboard::IsDeactivated ( U8  key) const
noexcept

Checks whether the given key is deactivated.

Parameters
[in]keyThe key.
Returns
true if the given key is deactivated. false otherwise.

◆ IsPassive()

bool mage::input::Keyboard::IsPassive ( U8  key) const
noexcept

Checks whether the given key is passive.

Parameters
[in]keyThe key.
Returns
true if the given key is passive. false otherwise.

◆ IsSwitched()

bool mage::input::Keyboard::IsSwitched ( U8  key) const
noexcept

Checks whether the given key is switched from being passive to active or vice versa (i.e. activated or deactivated).

Parameters
[in]keyThe key.
Returns
true if the given key is switched from being passive to active or vice versa (i.e. activated or deactivated). false otherwise.

◆ operator=() [1/2]

Keyboard& mage::input::Keyboard::operator= ( const Keyboard keyboard)
delete

Copies the given keyboard to this keyboard.

Parameters
[in]keyboardA reference to the keyboard to copy.
Returns
A reference to the copy of the given keyboard (i.e. this keyboard).

◆ operator=() [2/2]

Keyboard& mage::input::Keyboard::operator= ( Keyboard &&  keyboard)
delete

Moves the given keyboard to this keyboard.

Parameters
[in]keyboardA reference to the keyboard to move.
Returns
A reference to the moved keyboard (i.e. this keyboard).

◆ Update()

void mage::input::Keyboard::Update ( )
noexcept

Updates the state of this keyboard.

Member Data Documentation

◆ m_di

IDirectInput8& mage::input::Keyboard::m_di
private

A reference to the DirectInput object of this keyboard.

◆ m_key_states

std::bitset< 512 > mage::input::Keyboard::m_key_states
private

The key states of this keyboard. Each key state consists of two flags.

The first flag indicates whether the key state switched from being passive to active or vice versa (i.e. activated or deactivated).

The second flag indicates whether the key state is active.

◆ m_keyboard

ComPtr< IDirectInputDevice8 > mage::input::Keyboard::m_keyboard
private

A pointer to the DirectInput keyboard device of this keyboard.

◆ m_window

NotNull< HWND > mage::input::Keyboard::m_window
private

The handle of the parent window of this keyboard.