Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
InputsManager Class Reference

#include <InputsManager.h>

Public Member Functions

 InputsManager ()
 
virtual ~InputsManager ()
 
void Shutdown ()
 
void InitializeInputSystem (const std::string &configPath="Config/olympe-config.json")
 
InputDeviceManagerGetDeviceManager ()
 
InputContextManagerGetContextManager ()
 
virtual void HandleEvent (const SDL_Event *ev)
 
bool IsKeyboardAssigned () const
 
string GetDevicesStatusUpdate ()
 
int GetConnectedJoysticksCount () const
 
int GetConnectedKeyboardsCount () const
 
int GetMaxDevices () const
 
int GetAvailableJoystickCount () const
 
short AutoBindControllerToPlayer (short playerID)
 
bool AddPlayerEntityIndex (short playerID, EntityID eID)
 
bool BindControllerToPlayer (short playerID, SDL_JoystickID controller)
 
bool UnbindControllerFromPlayer (short playerID)
 
bool AddDisconnectedPlayer (short playerID, SDL_JoystickID old_controller)
 
bool RemoveDisconnectedPlayer (short playerID)
 
bool IsPlayerDisconnected (short playerID) const
 
short GetDisconnectedPlayersCount () const
 
short GetFirstDisconnectedPlayerID () const
 
bool IsPlayerBound (short playerID) const
 
SDL_JoystickID GetPlayerBinding (short playerID) const
 
short GetPlayerForController (SDL_JoystickID controller) const
 
void PushContext (InputContext ctx)
 
void PopContext ()
 
InputContext GetActiveContext () const
 
void RegisterInputEntity (EntityID e)
 
void UnregisterInputEntity (EntityID e)
 
const std::vector< EntityID > & GetInputEntities () const
 

Static Public Member Functions

static InputsManagerGetInstance ()
 
static InputsManagerGet ()
 

Private Attributes

std::string name
 
std::unordered_map< short, SDL_JoystickIDm_playerBindings
 
std::unordered_map< short, SDL_JoystickIDm_playerDisconnected
 
std::unordered_map< short, EntityIDm_playerEntityIndex
 
bool m_keyboardAssigned = false
 
std::ostringstream m_devicesStatus
 
std::vector< InputContextm_contextStack = { InputContext::Gameplay }
 
std::vector< EntityIDm_inputEntities
 

Detailed Description

Definition at line 16 of file InputsManager.h.

Constructor & Destructor Documentation

◆ InputsManager()

InputsManager::InputsManager ( )

Definition at line 6 of file InputsManager.cpp.

References name, and SYSTEM_LOG.

◆ ~InputsManager()

InputsManager::~InputsManager ( )
virtual

Definition at line 13 of file InputsManager.cpp.

References Shutdown(), and SYSTEM_LOG.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddDisconnectedPlayer()

bool InputsManager::AddDisconnectedPlayer ( short  playerID,
SDL_JoystickID  old_controller 
)
inline

Definition at line 191 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerDisconnected.

Referenced by JoystickManager::HandleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPlayerEntityIndex()

bool InputsManager::AddPlayerEntityIndex ( short  playerID,
EntityID  eID 
)
inline

Definition at line 120 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerEntityIndex.

Referenced by VideoGame::AddPlayerEntity(), and VideoGame::RegisterLoadedPlayerEntity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AutoBindControllerToPlayer()

short InputsManager::AutoBindControllerToPlayer ( short  playerID)
inline

◆ BindControllerToPlayer()

bool InputsManager::BindControllerToPlayer ( short  playerID,
SDL_JoystickID  controller 
)
inline

Definition at line 128 of file InputsManager.h.

References PlayerBinding_data::controllerID, JoystickManager::Get(), World::Get(), World::GetComponent(), GetComponentTypeID_Static(), m_keyboardAssigned, m_playerBindings, m_playerEntityIndex, and SYSTEM_LOG.

Referenced by AutoBindControllerToPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get()

static InputsManager & InputsManager::Get ( )
inlinestatic

◆ GetActiveContext()

InputContext InputsManager::GetActiveContext ( ) const

Definition at line 168 of file InputsManager.cpp.

References m_contextStack.

Referenced by InputMappingSystem::Process().

+ Here is the caller graph for this function:

◆ GetAvailableJoystickCount()

int InputsManager::GetAvailableJoystickCount ( ) const
inline

Definition at line 69 of file InputsManager.h.

References JoystickManager::Get(), GetComponentTypeID_Static(), JoystickManager::GetConnectedJoysticks(), and m_playerBindings.

Referenced by VideoGame::AddPlayerEntity(), GetDevicesStatusUpdate(), and VideoGame::IsInputDeviceAvailable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConnectedJoysticksCount()

int InputsManager::GetConnectedJoysticksCount ( ) const
inline

Definition at line 53 of file InputsManager.h.

References JoystickManager::Get(), and JoystickManager::GetConnectedJoysticks().

Referenced by GetDevicesStatusUpdate(), and GetMaxDevices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConnectedKeyboardsCount()

int InputsManager::GetConnectedKeyboardsCount ( ) const
inline

Definition at line 58 of file InputsManager.h.

References m_keyboardAssigned.

Referenced by GetMaxDevices().

+ Here is the caller graph for this function:

◆ GetContextManager()

InputContextManager & InputsManager::GetContextManager ( )
inline

Definition at line 44 of file InputsManager.h.

References InputContextManager::Get().

+ Here is the call graph for this function:

◆ GetDeviceManager()

InputDeviceManager & InputsManager::GetDeviceManager ( )
inline

Definition at line 43 of file InputsManager.h.

References InputDeviceManager::Get().

Referenced by InputMappingSystem::Process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDevicesStatusUpdate()

string InputsManager::GetDevicesStatusUpdate ( )

◆ GetDisconnectedPlayersCount()

short InputsManager::GetDisconnectedPlayersCount ( ) const
inline

Definition at line 208 of file InputsManager.h.

References m_playerDisconnected.

Referenced by InputEventConsumeSystem::Process().

+ Here is the caller graph for this function:

◆ GetFirstDisconnectedPlayerID()

short InputsManager::GetFirstDisconnectedPlayerID ( ) const
inline

Definition at line 212 of file InputsManager.h.

References m_playerDisconnected.

Referenced by InputEventConsumeSystem::Process().

+ Here is the caller graph for this function:

◆ GetInputEntities()

const std::vector< EntityID > & InputsManager::GetInputEntities ( ) const

Definition at line 195 of file InputsManager.cpp.

References m_inputEntities.

Referenced by InputEventConsumeSystem::Process().

+ Here is the caller graph for this function:

◆ GetInstance()

static InputsManager & InputsManager::GetInstance ( )
inlinestatic

Definition at line 22 of file InputsManager.h.

References GetComponentTypeID_Static().

Referenced by Get(), and GameEngine::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMaxDevices()

int InputsManager::GetMaxDevices ( ) const
inline

Definition at line 63 of file InputsManager.h.

References GetConnectedJoysticksCount(), and GetConnectedKeyboardsCount().

+ Here is the call graph for this function:

◆ GetPlayerBinding()

SDL_JoystickID InputsManager::GetPlayerBinding ( short  playerID) const
inline

Definition at line 221 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerBindings.

Referenced by AI_Player::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPlayerForController()

short InputsManager::GetPlayerForController ( SDL_JoystickID  controller) const
inline

Definition at line 227 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerBindings.

Referenced by AutoBindControllerToPlayer(), and JoystickManager::HandleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleEvent()

void InputsManager::HandleEvent ( const SDL_Event ev)
virtual

◆ InitializeInputSystem()

void InputsManager::InitializeInputSystem ( const std::string &  configPath = "Config/olympe-config.json")

◆ IsKeyboardAssigned()

bool InputsManager::IsKeyboardAssigned ( ) const
inline

Definition at line 48 of file InputsManager.h.

References m_keyboardAssigned.

Referenced by VideoGame::IsInputDeviceAvailable().

+ Here is the caller graph for this function:

◆ IsPlayerBound()

bool InputsManager::IsPlayerBound ( short  playerID) const
inline

Definition at line 220 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerBindings.

+ Here is the call graph for this function:

◆ IsPlayerDisconnected()

bool InputsManager::IsPlayerDisconnected ( short  playerID) const
inline

Definition at line 204 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerDisconnected.

+ Here is the call graph for this function:

◆ PopContext()

void InputsManager::PopContext ( )

Definition at line 155 of file InputsManager.cpp.

References m_contextStack, and SYSTEM_LOG.

◆ PushContext()

void InputsManager::PushContext ( InputContext  ctx)

Definition at line 149 of file InputsManager.cpp.

References GetComponentTypeID_Static(), m_contextStack, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ RegisterInputEntity()

void InputsManager::RegisterInputEntity ( EntityID  e)

Definition at line 174 of file InputsManager.cpp.

References GetComponentTypeID_Static(), m_inputEntities, and SYSTEM_LOG.

Referenced by RegisterInputEntityWithManager().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveDisconnectedPlayer()

bool InputsManager::RemoveDisconnectedPlayer ( short  playerID)
inline

Definition at line 197 of file InputsManager.h.

References GetComponentTypeID_Static(), and m_playerDisconnected.

Referenced by InputEventConsumeSystem::Process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Shutdown()

void InputsManager::Shutdown ( )
inline

Definition at line 29 of file InputsManager.h.

References JoystickManager::Get(), KeyboardManager::Get(), MouseManager::Get(), m_keyboardAssigned, m_playerBindings, JoystickManager::Shutdown(), KeyboardManager::Shutdown(), and MouseManager::Shutdown().

Referenced by ~InputsManager().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnbindControllerFromPlayer()

bool InputsManager::UnbindControllerFromPlayer ( short  playerID)
inline

Definition at line 168 of file InputsManager.h.

References PlayerBinding_data::controllerID, World::Get(), World::GetComponent(), GetComponentTypeID_Static(), m_keyboardAssigned, m_playerBindings, m_playerEntityIndex, and SYSTEM_LOG.

Referenced by JoystickManager::HandleEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnregisterInputEntity()

void InputsManager::UnregisterInputEntity ( EntityID  e)

Definition at line 185 of file InputsManager.cpp.

References GetComponentTypeID_Static(), m_inputEntities, and SYSTEM_LOG.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_contextStack

std::vector<InputContext> InputsManager::m_contextStack = { InputContext::Gameplay }
private

Definition at line 259 of file InputsManager.h.

Referenced by GetActiveContext(), PopContext(), and PushContext().

◆ m_devicesStatus

std::ostringstream InputsManager::m_devicesStatus
private

Definition at line 256 of file InputsManager.h.

Referenced by GetDevicesStatusUpdate().

◆ m_inputEntities

std::vector<EntityID> InputsManager::m_inputEntities
private

Definition at line 262 of file InputsManager.h.

Referenced by GetInputEntities(), RegisterInputEntity(), and UnregisterInputEntity().

◆ m_keyboardAssigned

bool InputsManager::m_keyboardAssigned = false
private

◆ m_playerBindings

std::unordered_map<short, SDL_JoystickID> InputsManager::m_playerBindings
private

◆ m_playerDisconnected

std::unordered_map<short, SDL_JoystickID> InputsManager::m_playerDisconnected
private

◆ m_playerEntityIndex

std::unordered_map<short, EntityID> InputsManager::m_playerEntityIndex
private

◆ name

std::string InputsManager::name
private

Definition at line 247 of file InputsManager.h.

Referenced by HandleEvent(), and InputsManager().


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