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

High-level API for collections of input action maps. More...

#include <InputStateMapper.hpp>

Public Types

typedef InputStateMapper SelfType
typedef std::pair< std::string, InputActionStatePair
typedef std::map< std::string, InputActionStateInputStateMap

Public Member Functions

 InputStateMapper (void)
 Default constructor.
 ~InputStateMapper (void)
 Destructor.
bool active (const std::string &key) const
 Obtain active state status.
bool insert (const std::string &key, const InputActionMapper &map, bool active)
 Add action mappings to an input state.
bool erase (const std::string &key)
 Remove a state.
bool activate (const std::string &key)
 Activate a state.
bool disable (const std::string &key)
 Disable a state.
void disable (void)
 Disable all input states.
bool activate_only (const std::string &key)
 Enable only a particular state.
void clear (void)
 Empty the container of input states.
void dump ()
 Diagnostic output.
void set_event_handler (EventHandler &evt_handler)
 Install the event handler used by the interface.

Private Member Functions

void on_event (const Event &ev)
 Internal event handler for triggering mapped action states.
bool on_key_press (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a keyboard action to a keyboard event.
bool on_mouse_button (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a mouse button action to a mouse button event.
bool on_mouse_wheel (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a mouse wheel action to a mouse wheel event.
bool on_joystick_button (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a joystick button action to a joystick button event.
bool on_joystick_axis (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a joystick axis action to a joystick axis event.
bool on_joystick_hat (const InputAction &mapping, const Event &ev)
bool on_game_controller_button (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a game controller button action to an equivalent event.
bool on_game_controller_axis (const InputAction &mapping, const Event &ev)
 Internal event handler for matching a game controller axis action to an equivalent event.

Private Attributes

EventHandlerevent_handler_ = nullptr
InputStateMap states_

Detailed Description

High-level API for collections of input action maps.

Remarks
See also, nom::InputActionMapper, nom::InputAction.

Definition at line 53 of file InputStateMapper.hpp.

Member Typedef Documentation

◆ InputStateMap

typedef std::map<std::string, InputActionState> nom::InputStateMapper::InputStateMap

Definition at line 58 of file InputStateMapper.hpp.

◆ Pair

typedef std::pair<std::string, InputActionState> nom::InputStateMapper::Pair

Definition at line 57 of file InputStateMapper.hpp.

◆ SelfType

typedef InputStateMapper nom::InputStateMapper::SelfType

Definition at line 56 of file InputStateMapper.hpp.

Member Function Documentation

◆ activate()

bool nom::InputStateMapper::activate ( const std::string & key)

Activate a state.

Parameters
keyThe state string index to activate.

◆ activate_only()

bool nom::InputStateMapper::activate_only ( const std::string & key)

Enable only a particular state.

Remarks
All other states, less and except specified state, will be marked inactive.

◆ active()

bool nom::InputStateMapper::active ( const std::string & key) const

Obtain active state status.

Parameters
keyThe state string index to query.

◆ disable()

bool nom::InputStateMapper::disable ( const std::string & key)

Disable a state.

Parameters
keyThe state string index to disable.

◆ dump()

void nom::InputStateMapper::dump ( )

Diagnostic output.

remarks Dumps only the active states.

◆ erase()

bool nom::InputStateMapper::erase ( const std::string & key)

Remove a state.

Parameters
keyThe state string index to remove.

◆ insert()

bool nom::InputStateMapper::insert ( const std::string & key,
const InputActionMapper & map,
bool active )

Add action mappings to an input state.

Parameters
keyThe state string index associated with the input action container.
mapA nom::InputActionMapper object with your input action maps to be assigned to a state.
activeToggle the active state of the input mappings.

◆ set_event_handler()

void nom::InputStateMapper::set_event_handler ( EventHandler & evt_handler)

Install the event handler used by the interface.

Remarks
The application's events will not be processed until a call is made to the event handler's ::poll_event method.
Note
The installed event handler must outlive the destruction of this interface!

Member Data Documentation

◆ event_handler_

EventHandler* nom::InputStateMapper::event_handler_ = nullptr
private

Definition at line 160 of file InputStateMapper.hpp.

◆ states_

InputStateMap nom::InputStateMapper::states_
private

Definition at line 162 of file InputStateMapper.hpp.


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