HPC_Voxel_Engine 0.2.0
High-Performance C++ Voxel Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
InputManager Class Reference

Singleton class that handles global input state. More...

#include <src/app/InputManager.h>

Collaboration diagram for InputManager:
Collaboration graph

Public Member Functions

void Init (GLFWwindow *pWindow)
 Initializes input callbacks for the specified window.
 
void Update ()
 Updates internal state (previous keys, mouse delta) at the start of a frame.
 
bool IsKeyPressed (int iKey) const
 
bool IsKeyJustPressed (int iKey) const
 
bool IsMouseButtonPressed (int iButton) const
 
Core::Vec3 GetMousePosition () const
 
Core::Vec3 GetMouseDelta () const
 
double GetScroll () const
 

Static Public Member Functions

static InputManagerGetInstance ()
 Retrieves the singleton instance.
 
static void FrameBufferSizeCallback (GLFWwindow *window, int width, int height)
 

Private Member Functions

 InputManager ()=default
 

Static Private Member Functions

static void keyCallback (GLFWwindow *pWindow, int iKey, int iScanCode, int iAction, int iMods)
 
static void mouseButtonCallback (GLFWwindow *pWindow, int iButton, int iAction, int iMods)
 
static void mousePosCallback (GLFWwindow *pWindow, double dXPos, double dYPos)
 
static void scrollCallback (GLFWwindow *pWindow, double dXOffset, double dYOffset)
 

Private Attributes

bool m_bKeys [1024] = {false}
 
bool m_bPrevKeys [1024] = {false}
 
bool m_bButtons [8] = {false}
 
Core::Vec3 m_objMousePosition
 
Core::Vec3 m_objMousePrevPosition
 
Core::Vec3 m_objMouseDelta
 
double m_dScrollY = 0.0
 
bool m_bFirstMouse = false
 

Detailed Description

Singleton class that handles global input state.

Constructor & Destructor Documentation

◆ InputManager()

InputManager::InputManager ( )
privatedefault

Member Function Documentation

◆ FrameBufferSizeCallback()

void InputManager::FrameBufferSizeCallback ( GLFWwindow *  window,
int  width,
int  height 
)
static
Here is the caller graph for this function:

◆ GetInstance()

static InputManager & InputManager::GetInstance ( )
inlinestatic

Retrieves the singleton instance.

Here is the caller graph for this function:

◆ GetMouseDelta()

Core::Vec3 InputManager::GetMouseDelta ( ) const
inline
Here is the caller graph for this function:

◆ GetMousePosition()

Core::Vec3 InputManager::GetMousePosition ( ) const
inline

◆ GetScroll()

double InputManager::GetScroll ( ) const
inline
Here is the caller graph for this function:

◆ Init()

void InputManager::Init ( GLFWwindow *  pWindow)

Initializes input callbacks for the specified window.

Parameters
pWindowThe GLFW window handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsKeyJustPressed()

bool InputManager::IsKeyJustPressed ( int  iKey) const
Here is the caller graph for this function:

◆ IsKeyPressed()

bool InputManager::IsKeyPressed ( int  iKey) const
Here is the caller graph for this function:

◆ IsMouseButtonPressed()

bool InputManager::IsMouseButtonPressed ( int  iButton) const
Here is the caller graph for this function:

◆ keyCallback()

void InputManager::keyCallback ( GLFWwindow *  pWindow,
int  iKey,
int  iScanCode,
int  iAction,
int  iMods 
)
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseButtonCallback()

void InputManager::mouseButtonCallback ( GLFWwindow *  pWindow,
int  iButton,
int  iAction,
int  iMods 
)
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mousePosCallback()

void InputManager::mousePosCallback ( GLFWwindow *  pWindow,
double  dXPos,
double  dYPos 
)
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollCallback()

void InputManager::scrollCallback ( GLFWwindow *  pWindow,
double  dXOffset,
double  dYOffset 
)
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update()

void InputManager::Update ( )

Updates internal state (previous keys, mouse delta) at the start of a frame.

Note
Must be called BEFORE glfwPollEvents() for IsKeyJustPressed to work correctly.
Here is the caller graph for this function:

Member Data Documentation

◆ m_bButtons

bool InputManager::m_bButtons[8] = {false}
private

◆ m_bFirstMouse

bool InputManager::m_bFirstMouse = false
private

◆ m_bKeys

bool InputManager::m_bKeys[1024] = {false}
private

◆ m_bPrevKeys

bool InputManager::m_bPrevKeys[1024] = {false}
private

◆ m_dScrollY

double InputManager::m_dScrollY = 0.0
private

◆ m_objMouseDelta

Core::Vec3 InputManager::m_objMouseDelta
private

◆ m_objMousePosition

Core::Vec3 InputManager::m_objMousePosition
private

◆ m_objMousePrevPosition

Core::Vec3 InputManager::m_objMousePrevPosition
private

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