nomlib
Loading...
Searching...
No Matches
nom::GameControllerEventHandler Class Reference

Internal management of hot-pluggable joystick devices handling. More...

#include <GameControllerEventHandler.hpp>

Public Member Functions

nom::size_type num_joysticks () const
 Get the number of accessible joysticks.
GameControllerjoystick (JoystickID dev_id) const
bool joystick_exists (JoystickID dev_id) const
 Query for the existence of an attached joystick.
GameControlleradd_joystick (JoystickIndex device_index)
 Append a game controller to the active devices pool.
bool remove_joystick (JoystickID dev_id)
 Remove a connected joystick from the joystick event pool.
void remove_joysticks ()
 Remove all joystick connection IDs from the joystick event pool.

Private Types

typedef std::map< JoystickID, std::unique_ptr< GameController > > joysticks

Private Attributes

joysticks joysticks_
 Active game controllers event pool.

Detailed Description

Internal management of hot-pluggable joystick devices handling.

Definition at line 44 of file GameControllerEventHandler.hpp.

Member Typedef Documentation

◆ joysticks

typedef std::map<JoystickID, std::unique_ptr<GameController> > nom::GameControllerEventHandler::joysticks
private

Definition at line 80 of file GameControllerEventHandler.hpp.

Member Function Documentation

◆ add_joystick()

GameController * nom::GameControllerEventHandler::add_joystick ( JoystickIndex device_index)

Append a game controller to the active devices pool.

Returns
A non-owned pointer to the game controller device on success, or NULL on failure, such as when the device can not be opened.

◆ joystick_exists()

bool nom::GameControllerEventHandler::joystick_exists ( JoystickID dev_id) const

Query for the existence of an attached joystick.

Returns
Boolean TRUE when the joystick exists, and boolean FALSE when the joystick does not exist.

◆ remove_joystick()

bool nom::GameControllerEventHandler::remove_joystick ( JoystickID dev_id)

Remove a connected joystick from the joystick event pool.

Returns
Boolean TRUE when the joystick exists, and boolean FALSE when the joystick does not exist.

◆ remove_joysticks()

void nom::GameControllerEventHandler::remove_joysticks ( )

Remove all joystick connection IDs from the joystick event pool.

Returns
void

Member Data Documentation

◆ joysticks_

joysticks nom::GameControllerEventHandler::joysticks_
private

Active game controllers event pool.

Remarks
This is a mapping of the current joysticks that are available to the end-user for use. Without this mapping, the end-user would be responsible for the management of each joystick's life-time; we must hold onto the device reference at the time of the SDL event, else we aren't able to use it beyond that frame – the same is true of removal events.

Definition at line 90 of file GameControllerEventHandler.hpp.


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