ECSTASY
All in the name
Loading...
Searching...
No Matches
ecstasy::integration::user_action::ActionBinding Class Reference

Action binding class, represent a binding between an input and a given action. More...

#include <ActionBinding.hpp>

Public Types

enum class  Type {
  MouseButton , Key , GamepadButton , GamepadAxis ,
  Count
}
 Binding types. More...
 

Public Member Functions

constexpr ActionBinding () noexcept
 Construct an empty action binding.
 
template<typename E , typename = is_valid_action_id<E>>
constexpr ActionBinding (E id, event::Mouse::Button input) noexcept
 Construct a mouse button action binding.
 
template<typename E , typename = is_valid_action_id<E>>
constexpr ActionBinding (E id, event::Keyboard::Key input)
 Construct a key action binding.
 
template<typename E , typename = is_valid_action_id<E>>
constexpr ActionBinding (E id, event::Gamepad::Button input)
 Construct a gamepad button action binding.
 
template<typename E , typename = is_valid_action_id<E>>
constexpr ActionBinding (E id, event::Gamepad::Axis input)
 Construct a gamepad axis action binding.
 
constexpr bool operator== (const ActionBinding &other) const noexcept
 Equality operator overload.
 

Public Attributes

Type type
 Type of the binding stored.
 
Action::Id actionId
 Associated action id.
 
union { 
 
   event::Mouse::Button   mouseButton 
 Type::MouseButton associated data. More...
 
   event::Keyboard::Key   key 
 Type::Key associated data. More...
 
   event::Gamepad::Button   gamepadButton 
 Type::GamepadButton associated data. More...
 
   event::Gamepad::Axis   gamepadAxis 
 Type::GamepadAxis associated data. More...
 
};  
 Anonymous union to ease facilitate the wrapped data access.
 

Detailed Description

Action binding class, represent a binding between an input and a given action.

Holds the binding type (set to Type::Count if empty), the associated data type and the action id.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 52 of file ActionBinding.hpp.

Member Enumeration Documentation

◆ Type

Binding types.

Enumerator
MouseButton 

The action is bound to a mouse button state.

Key 

The action is bound to a keyboard key state.

GamepadButton 

The action is bound to a gamepad button state.

GamepadAxis 

The action is bound to a gamepad axis state.

Count 

Keep last - the total number of bindings.

Definition at line 61 of file ActionBinding.hpp.

61 {
63 Key,
66
67 Count
68 };
@ GamepadButton
The action is bound to a gamepad button state.
@ MouseButton
The action is bound to a mouse button state.
@ Key
The action is bound to a keyboard key state.
@ GamepadAxis
The action is bound to a gamepad axis state.
@ Count
Keep last - the total number of bindings.

Constructor & Destructor Documentation

◆ ActionBinding() [1/5]

constexpr ecstasy::integration::user_action::ActionBinding::ActionBinding ( )
inlineconstexprnoexcept

Construct an empty action binding.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 77 of file ActionBinding.hpp.

78 {
79 }

◆ ActionBinding() [2/5]

template<typename E , typename = is_valid_action_id<E>>
constexpr ecstasy::integration::user_action::ActionBinding::ActionBinding ( id,
event::Mouse::Button  input 
)
inlineconstexprnoexcept

Construct a mouse button action binding.

Template Parameters
EEnum or size_t type.
Parameters
[in]idId of the associated action.
[in]inputSource input.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 93 of file ActionBinding.hpp.

94 : type(Type::MouseButton), actionId(static_cast<Action::Id>(id)), mouseButton(input)
95 {
96 }
event::Mouse::Button mouseButton
Type::MouseButton associated data.
size_t Id
Action identifier type.
Definition Action.hpp:27

◆ ActionBinding() [3/5]

template<typename E , typename = is_valid_action_id<E>>
constexpr ecstasy::integration::user_action::ActionBinding::ActionBinding ( id,
event::Keyboard::Key  input 
)
inlineconstexpr

Construct a key action binding.

Template Parameters
EEnum or size_t type.
Parameters
[in]idId of the associated action.
[in]inputSource input.
Exceptions
std::invalid_argumentIf the key is invalid.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 112 of file ActionBinding.hpp.

113 : type(Type::Key), actionId(static_cast<Action::Id>(id)), key(input)
114 {
116 }
static constexpr void assertKeyValid(Key key, bool allowUnknown=false)
Check whether a key is valid.
Definition Keyboard.hpp:236
event::Keyboard::Key key
Type::Key associated data.

◆ ActionBinding() [4/5]

template<typename E , typename = is_valid_action_id<E>>
constexpr ecstasy::integration::user_action::ActionBinding::ActionBinding ( id,
event::Gamepad::Button  input 
)
inlineconstexpr

Construct a gamepad button action binding.

Template Parameters
EEnum or size_t type.
Parameters
[in]idId of the associated action.
[in]inputSource input.
Exceptions
std::invalid_argumentIf the button is invalid.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 132 of file ActionBinding.hpp.

133 : type(Type::GamepadButton), actionId(static_cast<Action::Id>(id)), gamepadButton(input)
134 {
136 }
static constexpr void assertButtonValid(Button button, bool allowUnknown=false)
Check whether a button is valid.
Definition Gamepad.hpp:269
event::Gamepad::Button gamepadButton
Type::GamepadButton associated data.

◆ ActionBinding() [5/5]

template<typename E , typename = is_valid_action_id<E>>
constexpr ecstasy::integration::user_action::ActionBinding::ActionBinding ( id,
event::Gamepad::Axis  input 
)
inlineconstexpr

Construct a gamepad axis action binding.

Template Parameters
EEnum or size_t type.
Parameters
[in]idId of the associated action.
[in]inputSource input.
Exceptions
std::invalid_argumentIf the axis is invalid.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 152 of file ActionBinding.hpp.

153 : type(Type::GamepadAxis), actionId(static_cast<Action::Id>(id)), gamepadAxis(input)
154 {
156 }
static constexpr void assertAxisValid(Axis axis, bool allowUnknown=false)
Check whether an axis is valid.
Definition Gamepad.hpp:287
event::Gamepad::Axis gamepadAxis
Type::GamepadAxis associated data.

Member Function Documentation

◆ operator==()

constexpr bool ecstasy::integration::user_action::ActionBinding::operator== ( const ActionBinding other) const
inlineconstexprnoexcept

Equality operator overload.

Parameters
[in]otherOther binding.
Returns
bool Whether the two bindings are equal.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-02)

Definition at line 168 of file ActionBinding.hpp.

169 {
170 if (type != other.type || actionId != other.actionId)
171 return false;
172
173 switch (type) {
174 case Type::MouseButton: return mouseButton == other.mouseButton;
175 case Type::Key: return key == other.key;
176 case Type::GamepadButton: return gamepadButton == other.gamepadButton;
177 case Type::GamepadAxis: return gamepadAxis == other.gamepadAxis;
178 default: return true;
179 }
180 }

Member Data Documentation

◆ [union]

Anonymous union to ease facilitate the wrapped data access.

Warning
Only the member associated to the current type is valid.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

◆ actionId

Action::Id ecstasy::integration::user_action::ActionBinding::actionId

Associated action id.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 198 of file ActionBinding.hpp.

◆ gamepadAxis

event::Gamepad::Axis ecstasy::integration::user_action::ActionBinding::gamepadAxis

Type::GamepadAxis associated data.

Definition at line 212 of file ActionBinding.hpp.

◆ gamepadButton

event::Gamepad::Button ecstasy::integration::user_action::ActionBinding::gamepadButton

Type::GamepadButton associated data.

Definition at line 211 of file ActionBinding.hpp.

◆ key

event::Keyboard::Key ecstasy::integration::user_action::ActionBinding::key

Type::Key associated data.

Definition at line 210 of file ActionBinding.hpp.

◆ mouseButton

event::Mouse::Button ecstasy::integration::user_action::ActionBinding::mouseButton

Type::MouseButton associated data.

Definition at line 209 of file ActionBinding.hpp.

◆ type

Type ecstasy::integration::user_action::ActionBinding::type

Type of the binding stored.

Note
Type::Count means the binding is invalid.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-11-25)

Definition at line 190 of file ActionBinding.hpp.


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