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::MouseState Class Reference

#include <mouse_state.h>

Classes

struct  MouseButtonState
 

Public Member Functions

bool GetButton (MouseButton button)
 
bool GetButtonDown (MouseButton button)
 
bool GetButtonPressed (MouseButton button)
 
bool GetButtonReleased (MouseButton button)
 
const DirectX::XMFLOAT2 & GetMousePosition () const
 
const DirectX::XMFLOAT2 & GetMousePositionDelta () const
 
const DirectX::XMFLOAT2 & GetScrollDelta () const
 

Protected Member Functions

void SetMouseButtonPressed (MouseButton button)
 
void SetMouseButtonReleased (MouseButton button)
 
void SetMouseButtonModifiers (MouseButton button, int modifiers)
 
void SetMousePosition (const DirectX::XMFLOAT2 &new_mouse_position)
 
void SetScrollDelta (const DirectX::XMFLOAT2 &delta_scroll)
 
void SetMouseInWindow (bool is_mouse_in_window)
 
void Update ()
 

Private Attributes

DirectX::XMFLOAT2 mouse_position_
 
DirectX::XMFLOAT2 delta_mouse_position_
 
DirectX::XMFLOAT2 delta_mouse_position_accumulator_
 
DirectX::XMFLOAT2 delta_scroll_
 
DirectX::XMFLOAT2 delta_scroll_accumulator_
 
bool is_mouse_in_window_
 
Map< MouseButton, MouseButtonStatemouse_button_states_
 

Friends

class Window
 
class GLFWManager
 
class ImGuiManager
 

Detailed Description

Keeps track of the state of the mouse.

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

Member Function Documentation

bool blowbox::MouseState::GetButton ( MouseButton  button)

Find out whether a button is down or not.

Parameters
[in]buttonThe key you want to know the down-state of.
Returns
Whether the button is down or not.
bool blowbox::MouseState::GetButtonDown ( MouseButton  button)

Find out whether a button is down or not.

Parameters
[in]buttonThe key you want to know the down-state of.
Returns
Whether the button is down or not.
bool blowbox::MouseState::GetButtonPressed ( MouseButton  button)

Find out whether a button is pressed or not.

Parameters
[in]buttonThe key you want to know the pressed-state of.
Returns
Whether the button is pressed or not.
bool blowbox::MouseState::GetButtonReleased ( MouseButton  button)

Find out whether a button is released or not.

Parameters
[in]buttonThe key you want to know the released-state of.
Returns
Whether the button is released or not.
const DirectX::XMFLOAT2 & blowbox::MouseState::GetMousePosition ( ) const
Returns
The position of the mouse relative to the window.
const DirectX::XMFLOAT2 & blowbox::MouseState::GetMousePositionDelta ( ) const
Returns
The delta position of the mouse relative to the window. (i.e. how much it has moved since the last frame)
const DirectX::XMFLOAT2 & blowbox::MouseState::GetScrollDelta ( ) const
Returns
The scroll delta of the mouse since last frame.
void blowbox::MouseState::SetMouseButtonModifiers ( MouseButton  button,
int  modifiers 
)
protected

Changes the key modifiers of a button to true.

Parameters
[in]buttonThe button to be changed.
[in]modifiersThe modifiers that were pressed when the button was pressed.
void blowbox::MouseState::SetMouseButtonPressed ( MouseButton  button)
protected

Changes the press-state of a button to true.

Parameters
[in]buttonThe button to be changed.
void blowbox::MouseState::SetMouseButtonReleased ( MouseButton  button)
protected

Changes the release-state of a button to true.

Parameters
[in]buttonThe button to be changed.
void blowbox::MouseState::SetMouseInWindow ( bool  is_mouse_in_window)
protected

Sets whether the mouse is in the window or not.

Parameters
[in]is_mouse_in_windowWhether the mouse is in the window or not.
void blowbox::MouseState::SetMousePosition ( const DirectX::XMFLOAT2 &  new_mouse_position)
protected

Sets the mouse's position.

Parameters
[in]new_mouse_positionThe mouse's new position.
void blowbox::MouseState::SetScrollDelta ( const DirectX::XMFLOAT2 &  delta_scroll)
protected

Sets the mouse's scroll delta.

Parameters
[in]delta_scrollThe delta scroll.
void blowbox::MouseState::Update ( )
protected

Updates the MouseState. This makes it so that all accumulators are cleared and mouse states are updated accordingly.

Member Data Documentation

DirectX::XMFLOAT2 blowbox::MouseState::delta_mouse_position_
private

The delta of the mouse position over the last frame.

DirectX::XMFLOAT2 blowbox::MouseState::delta_mouse_position_accumulator_
private

An accumulator of delta mouse positions.

DirectX::XMFLOAT2 blowbox::MouseState::delta_scroll_
private

The delta scroll of the mouse over the last frame.

DirectX::XMFLOAT2 blowbox::MouseState::delta_scroll_accumulator_
private

An accumulator of delta scrolls.

bool blowbox::MouseState::is_mouse_in_window_
private

Whether the mouse is in the window.

Map<MouseButton, MouseButtonState> blowbox::MouseState::mouse_button_states_
private

All the different mouse states.

DirectX::XMFLOAT2 blowbox::MouseState::mouse_position_
private

The current position of the mouse.


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