Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
InputManager Class Reference

The InputManager class is responsible for handling user input events, including keyboard and mouse input. It allows subscribers to register for specific input events (key presses and mouse button events) and notifies them when the events occur. More...

#include <InputManager.h>

Public Member Functions

 InputManager ()=default
 
 ~InputManager ()
 
 InputManager (const InputManager &)=delete
 
InputManageroperator= (const InputManager &)=delete
 
void HandleInputs (SDL_Event &pEvent)
 Handles input events (key and mouse events) and notifies the corresponding listeners.
 
void SubscribeToKey (SDL_Keycode pKeyCode, IInputListener *pListener)
 Subscribes a listener to a specific keyboard key event.
 
void SubscribeToMouse (Uint8 pButton, IInputListener *pListener)
 Subscribes a listener to a specific mouse button event.
 
void UnSubscribeToAllEvents (IInputListener *pListener)
 Unsubscribes from a listener.
 

Static Public Member Functions

static InputManagerInstance ()
 Returns the singleton instance of the InputManager.
 

Detailed Description

The InputManager class is responsible for handling user input events, including keyboard and mouse input. It allows subscribers to register for specific input events (key presses and mouse button events) and notifies them when the events occur.

Constructor & Destructor Documentation

◆ InputManager() [1/2]

InputManager::InputManager ( )
default

◆ ~InputManager()

InputManager::~InputManager ( )

◆ InputManager() [2/2]

InputManager::InputManager ( const InputManager & )
delete

Member Function Documentation

◆ HandleInputs()

void InputManager::HandleInputs ( SDL_Event & pEvent)

Handles input events (key and mouse events) and notifies the corresponding listeners.

Parameters
pEventThe SDL event to be processed.

◆ Instance()

InputManager & InputManager::Instance ( )
static

Returns the singleton instance of the InputManager.

Returns
Reference to the static InputManager instance.

◆ operator=()

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

◆ SubscribeToKey()

void InputManager::SubscribeToKey ( SDL_Keycode pKeyCode,
IInputListener * pListener )

Subscribes a listener to a specific keyboard key event.

Parameters
pKeyCodeThe SDL keycode for the key to subscribe to.
pListenerThe listener that will be notified when the key event occurs.

◆ SubscribeToMouse()

void InputManager::SubscribeToMouse ( Uint8 pButton,
IInputListener * pListener )

Subscribes a listener to a specific mouse button event.

Parameters
pButtonThe SDL mouse button to subscribe to (e.g., SDL_BUTTON_LEFT).
pListenerThe listener that will be notified when the mouse button event occurs.

◆ UnSubscribeToAllEvents()

void InputManager::UnSubscribeToAllEvents ( IInputListener * pListener)

Unsubscribes from a listener.

Parameters
pListenerThe listener that we want to unsubscribe of.

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