Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::InputManager Class Reference

Stores per-frame keyboard and mouse input state. More...

#include <InputManager.h>

Public Member Functions

 InputManager ()=default
 
 InputManager (const InputManager &)=delete
 
 InputManager (InputManager &&)=delete
 
InputManageroperator= (const InputManager &)=delete
 
InputManageroperator= (InputManager &&)=delete
 
void SetKeyPressed (Key key, bool pressed)
 Record a key press or release event.
 
bool IsKeyPressed (Key key) const
 Query whether a key is currently held down.
 
void SetMouseButtonPressed (MouseButton button, bool pressed)
 Record a mouse-button press or release event.
 
bool IsMouseButtonPressed (MouseButton button) const
 Query whether a mouse button is currently held down.
 
void SetMousePositionOld (const vec2 &pos)
 Store the cursor position from the previous frame.
 
const vec2 GetMousePositionOld () const
 Retrieve the cursor position from the previous frame.
 
void SetMousePositionCurrent (const vec2 &pos)
 Store the cursor position for the current frame.
 
void SetMousePositionChanged (bool changed)
 
bool IsMousePositionChanged () const
 
const vec2 GetMousePositionCurrent () const
 Retrieve the cursor position for the current frame.
 

Friends

class Engine
 

Detailed Description

Stores per-frame keyboard and mouse input state.

Owned by the Engine singleton. Game code reads state; only the Engine writes state (it is a friend). Arrays are sized for 512 keys and 16 mouse buttons, matching GLFW's key-code range.

Definition at line 33 of file InputManager.h.

Constructor & Destructor Documentation

◆ InputManager() [1/3]

mnd::InputManager::InputManager ( )
default

◆ InputManager() [2/3]

mnd::InputManager::InputManager ( const InputManager )
delete

◆ InputManager() [3/3]

mnd::InputManager::InputManager ( InputManager &&  )
delete

Member Function Documentation

◆ GetMousePositionCurrent()

const vec2 mnd::InputManager::GetMousePositionCurrent ( ) const

Retrieve the cursor position for the current frame.

Subtract GetMousePositionOld() to get a per-frame delta suitable for camera rotation.

Returns
Screen-space cursor coordinates.

Definition at line 82 of file InputManager.cpp.

Referenced by mnd::Engine::Run().

◆ GetMousePositionOld()

const vec2 mnd::InputManager::GetMousePositionOld ( ) const

Retrieve the cursor position from the previous frame.

Returns
Screen-space cursor coordinates.

Definition at line 72 of file InputManager.cpp.

◆ IsKeyPressed()

bool mnd::InputManager::IsKeyPressed ( Key  key) const

Query whether a key is currently held down.

Parameters
keyKey code (e.g. Key::W).
Returns
True if the key is pressed.

Definition at line 26 of file InputManager.cpp.

References mnd::EditorSwallowsInput(), and LOG_WARN.

◆ IsMouseButtonPressed()

bool mnd::InputManager::IsMouseButtonPressed ( MouseButton  button) const

Query whether a mouse button is currently held down.

Parameters
buttonMouse-button code (e.g. MouseButton::Left).
Returns
True if the button is pressed.

Definition at line 52 of file InputManager.cpp.

References mnd::EditorSwallowsInput().

◆ IsMousePositionChanged()

bool mnd::InputManager::IsMousePositionChanged ( ) const

Definition at line 92 of file InputManager.cpp.

References mnd::EditorSwallowsInput().

◆ operator=() [1/2]

InputManager & mnd::InputManager::operator= ( const InputManager )
delete

◆ operator=() [2/2]

InputManager & mnd::InputManager::operator= ( InputManager &&  )
delete

◆ SetKeyPressed()

void mnd::InputManager::SetKeyPressed ( Key  key,
bool  pressed 
)

Record a key press or release event.

Parameters
keyKey code (out-of-range values are ignored with a warning).
pressedTrue when pressed, false when released.

Definition at line 15 of file InputManager.cpp.

References LOG_WARN.

Referenced by mnd::KeyCallback().

◆ SetMouseButtonPressed()

void mnd::InputManager::SetMouseButtonPressed ( MouseButton  button,
bool  pressed 
)

Record a mouse-button press or release event.

Parameters
buttonMouse-button code.
pressedTrue when pressed, false when released.

Definition at line 42 of file InputManager.cpp.

Referenced by mnd::MouseButtonCallback().

◆ SetMousePositionChanged()

void mnd::InputManager::SetMousePositionChanged ( bool  changed)

Definition at line 87 of file InputManager.cpp.

Referenced by mnd::Engine::Run().

◆ SetMousePositionCurrent()

void mnd::InputManager::SetMousePositionCurrent ( const vec2 pos)

Store the cursor position for the current frame.

Parameters
posScreen-space cursor coordinates.

Definition at line 77 of file InputManager.cpp.

◆ SetMousePositionOld()

void mnd::InputManager::SetMousePositionOld ( const vec2 pos)

Store the cursor position from the previous frame.

Parameters
posScreen-space cursor coordinates.

Definition at line 67 of file InputManager.cpp.

Referenced by mnd::CursorPositionCallback(), and mnd::Engine::Run().

Friends And Related Symbol Documentation

◆ Engine

friend class Engine
friend

Definition at line 110 of file InputManager.h.


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