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

#include <mouse.hpp>

Public Member Functions

 Mouse (NotNull< HWND > window, IDirectInput8 &di)
 
 Mouse (const Mouse &mouse)=delete
 
 Mouse (Mouse &&mouse) noexcept
 
 ~Mouse ()
 
Mouseoperator= (const Mouse &mouse)=delete
 
Mouseoperator= (Mouse &&mouse)=delete
 
NotNull< HWND > GetWindow () noexcept
 
void Update () noexcept
 
bool IsActive (U8 button) const noexcept
 
bool IsPassive (U8 button) const noexcept
 
bool IsSwitched (U8 button) const noexcept
 
bool IsActivated (U8 button) const noexcept
 
bool IsDeactivated (U8 button) const noexcept
 
S32 GetPositionX () const noexcept
 
S32 GetPositionY () const noexcept
 
const S32x2 GetPosition () const noexcept
 
S32 GetDeltaX () const noexcept
 
S32 GetDeltaY () const noexcept
 
const S32x2 GetDelta () const noexcept
 
S32 GetDeltaWheel () const noexcept
 

Private Member Functions

void InitializeMouse ()
 

Private Attributes

NotNull< HWND > m_window
 
IDirectInput8 & m_di
 
ComPtr< IDirectInputDevice8 > m_mouse
 
S32x2 m_position
 
S32x2 m_delta
 
S32 m_delta_wheel
 
std::bitset< 16 > m_button_states
 

Detailed Description

A class of mouses.

Constructor & Destructor Documentation

◆ Mouse() [1/3]

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

Constructs a mouse.

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

◆ Mouse() [2/3]

mage::input::Mouse::Mouse ( const Mouse mouse)
delete

Constructs a mouse from the given mouse.

Parameters
[in]mouseA reference to the mouse to copy.

◆ Mouse() [3/3]

mage::input::Mouse::Mouse ( Mouse &&  mouse)
defaultnoexcept

Constructs a mouse by moving the given mouse.

Parameters
[in]mouseA reference to the mouse to move.

◆ ~Mouse()

mage::input::Mouse::~Mouse ( )
default

Destructs this mouse.

Member Function Documentation

◆ GetDelta()

const S32x2 mage::input::Mouse::GetDelta ( ) const
noexcept

Returns the change in this mouse's coordinates.

Returns
The change in this mouse's coordinates.

◆ GetDeltaWheel()

S32 mage::input::Mouse::GetDeltaWheel ( ) const
noexcept

Returns the change in this mouse's scroll wheel.

Returns
The change in this mouse's scroll wheel.

◆ GetDeltaX()

S32 mage::input::Mouse::GetDeltaX ( ) const
noexcept

Returns the change in this mouse's horizontal coordinate.

Returns
The change in this mouse's horizontal coordinate.

◆ GetDeltaY()

S32 mage::input::Mouse::GetDeltaY ( ) const
noexcept

Returns the change in this mouse's vertical coordinate.

Returns
The change in this mouse's vertical coordinate.

◆ GetPosition()

const S32x2 mage::input::Mouse::GetPosition ( ) const
noexcept

Returns the position of this mouse.

Returns
The position of this mouse.

◆ GetPositionX()

S32 mage::input::Mouse::GetPositionX ( ) const
noexcept

Returns the horizontal position of this mouse.

Returns
The horizontal position of this mouse.

◆ GetPositionY()

S32 mage::input::Mouse::GetPositionY ( ) const
noexcept

Returns the vertical position of this mouse.

Returns
The vertical position of this mouse.

◆ GetWindow()

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

Returns the window handle of this mouse.

Returns
The window handle of this mouse.

◆ InitializeMouse()

void mage::input::Mouse::InitializeMouse ( )
private

Initializes the mouse device of this mouse.

Exceptions
ExceptionFailed to initialize the mouse.

◆ IsActivated()

bool mage::input::Mouse::IsActivated ( U8  button) const
noexcept

Checks whether the given button is activated.

Parameters
[in]buttonThe button.
Returns
true if the given button is activated. false otherwise.

◆ IsActive()

bool mage::input::Mouse::IsActive ( U8  button) const
noexcept

Checks whether the given button is active.

Parameters
[in]buttonThe button.
Returns
true if the given button is active. false otherwise.

◆ IsDeactivated()

bool mage::input::Mouse::IsDeactivated ( U8  button) const
noexcept

Checks whether the given button is deactivated.

Parameters
[in]buttonThe button.
Returns
true if the given button is deactivated. false otherwise.

◆ IsPassive()

bool mage::input::Mouse::IsPassive ( U8  button) const
noexcept

Checks whether the given button is passive.

Parameters
[in]buttonThe button.
Returns
true if the given button is passive. false otherwise.

◆ IsSwitched()

bool mage::input::Mouse::IsSwitched ( U8  button) const
noexcept

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

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

◆ operator=() [1/2]

Mouse& mage::input::Mouse::operator= ( const Mouse mouse)
delete

Copies the given mouse to this mouse.

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

◆ operator=() [2/2]

Mouse& mage::input::Mouse::operator= ( Mouse &&  mouse)
delete

Moves the given mouse to this mouse.

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

◆ Update()

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

Updates the state of this mouse.

Member Data Documentation

◆ m_button_states

std::bitset< 16 > mage::input::Mouse::m_button_states
private

The button states of this mouse. Each button state consists of two flags.

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

The second flag indicates whether the button state is active.

◆ m_delta

S32x2 mage::input::Mouse::m_delta
private

The change in the horizontal and vertical coordinates of this mouse.

◆ m_delta_wheel

S32 mage::input::Mouse::m_delta_wheel
private

The change in the scroll wheel coordinates of this mouse.

◆ m_di

IDirectInput8& mage::input::Mouse::m_di
private

A reference to the DirectInput object of this mouse.

◆ m_mouse

ComPtr< IDirectInputDevice8 > mage::input::Mouse::m_mouse
private

A pointer to the DirectInput mouse device of this mouse.

◆ m_position

S32x2 mage::input::Mouse::m_position
private

The position of the mouse cursor on the screen of this mouse.

◆ m_window

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

The handle of the parent window of this mouse.