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

#include <JoystickManager.h>

Classes

struct  JoystickInfo
 
struct  JoystickState
 

Public Member Functions

 JoystickManager ()
 
virtual ~JoystickManager ()
 
void Initialize ()
 
void Scan_Joysticks ()
 
void Shutdown ()
 
void Process (float dt)
 
void HandleEvent (const SDL_Event *ev)
 
std::vector< SDL_JoystickIDGetConnectedJoysticks ()
 
bool IsJoystickConnected (SDL_JoystickID id)
 
void BeginFrame ()
 
bool GetButton (SDL_JoystickID id, int button)
 
bool IsButtonPressed (SDL_JoystickID id, int button)
 
bool IsButtonReleased (SDL_JoystickID id, int button)
 
float GetAxis (SDL_JoystickID id, int axis)
 

Static Public Member Functions

static JoystickManagerGetInstance ()
 
static JoystickManagerGet ()
 

Static Public Attributes

static constexpr int MAX_BUTTONS = 16
 
static constexpr int MAX_AXES = 6
 

Private Member Functions

void OpenJoystick (SDL_JoystickID instance_id)
 
void CloseJoystick (SDL_JoystickID instance_id)
 
void PostJoystickButtonEvent (SDL_JoystickID which, int button, bool down)
 
void PostJoystickAxisEvent (SDL_JoystickID which, int axis, Sint16 value)
 
void PostJoystickConnectedEvent (SDL_JoystickID which, bool bconnected)
 

Private Attributes

std::string name
 
std::unordered_map< SDL_JoystickID, JoystickInfom_joysticks
 
std::unordered_map< SDL_JoystickID, JoystickStatem_joyStates
 
std::mutex m_mutex
 

Detailed Description

Definition at line 13 of file JoystickManager.h.

Constructor & Destructor Documentation

◆ JoystickManager()

JoystickManager::JoystickManager ( )
inline

Definition at line 19 of file JoystickManager.h.

References Initialize(), and name.

Referenced by GetInstance().

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

◆ ~JoystickManager()

virtual JoystickManager::~JoystickManager ( )
inlinevirtual

Definition at line 24 of file JoystickManager.h.

References Shutdown().

+ Here is the call graph for this function:

Member Function Documentation

◆ BeginFrame()

void JoystickManager::BeginFrame ( )

Definition at line 18 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, and m_mutex.

Referenced by SDL_AppEvent(), and SDL_AppIterate().

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

◆ CloseJoystick()

void JoystickManager::CloseJoystick ( SDL_JoystickID  instance_id)
private

Definition at line 335 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, m_joysticks, and m_mutex.

Referenced by HandleEvent().

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

◆ Get()

static JoystickManager & JoystickManager::Get ( )
inlinestatic

◆ GetAxis()

float JoystickManager::GetAxis ( SDL_JoystickID  id,
int  axis 
)

Definition at line 56 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, m_mutex, and MAX_AXES.

+ Here is the call graph for this function:

◆ GetButton()

bool JoystickManager::GetButton ( SDL_JoystickID  id,
int  button 
)

Definition at line 29 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, m_mutex, and MAX_BUTTONS.

+ Here is the call graph for this function:

◆ GetConnectedJoysticks()

std::vector< SDL_JoystickID > JoystickManager::GetConnectedJoysticks ( )

Definition at line 283 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joysticks, and m_mutex.

Referenced by InputsManager::AutoBindControllerToPlayer(), InputsManager::GetAvailableJoystickCount(), InputsManager::GetConnectedJoysticksCount(), and InputsManager::GetDevicesStatusUpdate().

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

◆ GetInstance()

JoystickManager & JoystickManager::GetInstance ( )
static

Definition at line 12 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), and JoystickManager().

Referenced by Get().

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

◆ HandleEvent()

void JoystickManager::HandleEvent ( const SDL_Event ev)

◆ Initialize()

void JoystickManager::Initialize ( )

Definition at line 65 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joysticks, Scan_Joysticks(), and SYSTEM_LOG.

Referenced by JoystickManager().

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

◆ IsButtonPressed()

bool JoystickManager::IsButtonPressed ( SDL_JoystickID  id,
int  button 
)

Definition at line 38 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, m_mutex, and MAX_BUTTONS.

+ Here is the call graph for this function:

◆ IsButtonReleased()

bool JoystickManager::IsButtonReleased ( SDL_JoystickID  id,
int  button 
)

Definition at line 47 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joyStates, m_mutex, and MAX_BUTTONS.

+ Here is the call graph for this function:

◆ IsJoystickConnected()

bool JoystickManager::IsJoystickConnected ( SDL_JoystickID  id)

Definition at line 292 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joysticks, and m_mutex.

+ Here is the call graph for this function:

◆ OpenJoystick()

void JoystickManager::OpenJoystick ( SDL_JoystickID  instance_id)
private

Definition at line 298 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), JoystickManager::JoystickInfo::joystick, m_joysticks, m_mutex, name, and SYSTEM_LOG.

Referenced by HandleEvent(), and Scan_Joysticks().

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

◆ PostJoystickAxisEvent()

void JoystickManager::PostJoystickAxisEvent ( SDL_JoystickID  which,
int  axis,
Sint16  value 
)
private

Definition at line 367 of file JoystickManager.cpp.

References Message::Create(), EventQueue::Get(), GetComponentTypeID_Static(), Input, Olympe_EventType_Joystick_AxisMotion, and EventQueue::Push().

Referenced by HandleEvent().

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

◆ PostJoystickButtonEvent()

void JoystickManager::PostJoystickButtonEvent ( SDL_JoystickID  which,
int  button,
bool  down 
)
private

Definition at line 353 of file JoystickManager.cpp.

References Message::Create(), EventQueue::Get(), GetComponentTypeID_Static(), Input, Olympe_EventType_Joystick_ButtonDown, Olympe_EventType_Joystick_ButtonUp, and EventQueue::Push().

Referenced by HandleEvent().

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

◆ PostJoystickConnectedEvent()

void JoystickManager::PostJoystickConnectedEvent ( SDL_JoystickID  which,
bool  bconnected 
)
private

◆ Process()

void JoystickManager::Process ( float  dt)

Definition at line 105 of file JoystickManager.cpp.

◆ Scan_Joysticks()

void JoystickManager::Scan_Joysticks ( )

Definition at line 77 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), and OpenJoystick().

Referenced by Initialize().

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

◆ Shutdown()

void JoystickManager::Shutdown ( )

Definition at line 91 of file JoystickManager.cpp.

References GetComponentTypeID_Static(), m_joysticks, m_mutex, and SYSTEM_LOG.

Referenced by InputsManager::Shutdown(), and ~JoystickManager().

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

Member Data Documentation

◆ m_joyStates

std::unordered_map<SDL_JoystickID, JoystickState> JoystickManager::m_joyStates
private

◆ m_joysticks

std::unordered_map<SDL_JoystickID, JoystickInfo> JoystickManager::m_joysticks
private

◆ m_mutex

std::mutex JoystickManager::m_mutex
private

◆ MAX_AXES

constexpr int JoystickManager::MAX_AXES = 6
staticconstexpr

Definition at line 17 of file JoystickManager.h.

Referenced by GetAxis(), and HandleEvent().

◆ MAX_BUTTONS

constexpr int JoystickManager::MAX_BUTTONS = 16
staticconstexpr

Definition at line 16 of file JoystickManager.h.

Referenced by GetButton(), HandleEvent(), IsButtonPressed(), and IsButtonReleased().

◆ name

std::string JoystickManager::name
private

Definition at line 55 of file JoystickManager.h.

Referenced by JoystickManager(), and OpenJoystick().


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