10#include <IEventReceiver.h>
49 KeyPress(
const SEvent::SKeyInput &in);
50 KeyPress(
const SEvent::SMouseInput &in);
51 KeyPress(
const SEvent::SGamepadButtonEvent &in);
52 KeyPress(
const SEvent::SGamepadAxisEvent &in);
56 std::string
sym()
const;
59 std::string
name()
const;
93 operator bool()
const;
101 using value_type = std::variant<u32, u32, GameKeyType, GamepadButton, GamepadAxis, GamepadAxis>;
103 template<InputType I>
106 template<InputType I>
109 void loadFromKey(EKEY_CODE keycode,
wchar_t keychar);
113 template<InputType I>
115 return std::get<static_cast<size_t>(I)>(
value);
118 template<InputType I,
typename T>
120 return static_cast<T
>(
get<I>());
123 template<InputType I>
124 std::add_pointer_t<const value_alternative_t<I>>
getIf()
const {
125 return std::get_if<static_cast<size_t>(I)>(&
value);
128 template<InputType I>
130 value.emplace<
static_cast<size_t>(I)>(newValue);
133 friend std::hash<KeyPress>;
140 return std::hash<KeyPress::value_type>{}(kp.value);
147#define EscapeKey KeyPress::getSpecialKey("KEY_ESCAPE")
153const std::vector<KeyPress> &
getKeySetting(
const std::string &settingname);
169 operator bool()
const {
void loadFromKey(EKEY_CODE keycode, wchar_t keychar)
Definition keycode.cpp:278
KeyPress getOppositeAxisDirection() const
Get the joystick axis in the opposite direction (if available).
Definition keycode.cpp:511
u32 getScancode() const
Definition keycode.h:62
KeyPress(GameKeyType key)
Definition keycode.h:53
value_alternative_t< I > get() const
Definition keycode.h:114
std::add_pointer_t< const value_alternative_t< I > > getIf() const
Definition keycode.h:124
bool loadFromScancode(const std::string &name)
static KeyPress getSpecialKey(const std::string &name)
Definition keycode.cpp:568
std::string sym() const
Definition keycode.cpp:339
std::string name() const
Definition keycode.cpp:357
std::variant_alternative_t< static_cast< size_t >(I), value_type > value_alternative_t
Definition keycode.h:104
std::variant< u32, u32, GameKeyType, GamepadButton, GamepadAxis, GamepadAxis > value_type
Definition keycode.h:101
bool operator!=(KeyPress o) const
Definition keycode.h:72
bool operator==(KeyPress o) const
Definition keycode.h:69
bool operator<(KeyPress o) const
Definition keycode.h:77
InputType getType() const
Definition keycode.h:82
InputSourceType getSourceType() const
Get the source type of input.
Definition keycode.cpp:547
value_type value
Definition keycode.h:111
T getCast() const
Definition keycode.h:119
bool loadUnsignedFromPrefix(const std::string &name, const std::string &prefix)
Definition keycode.cpp:499
InputSourceType
Type of the input device.
Definition keycode.h:37
@ GAMEPAD
Definition keycode.h:42
@ TOUCHSCREEN
Definition keycode.h:41
@ MOUSE
Definition keycode.h:40
@ INVALID
Definition keycode.h:38
InputType
The type of the input value.
Definition keycode.h:27
@ GAME_ACTION
GameKeyType input passed by touchscreen buttons.
Definition keycode.h:30
@ GAMEPAD_AXIS_PLUS
Gamepad axis in the positive direction.
Definition keycode.h:32
@ MOUSE_BUTTON
Mouse button input.
Definition keycode.h:29
@ GAMEPAD_AXIS_MINUS
Gamepad axis in the negative direction.
Definition keycode.h:33
@ GAMEPAD_BUTTON
Gamepad button.
Definition keycode.h:31
@ KEYBOARD
Keyboard input (scancodes).
Definition keycode.h:28
void emplace(value_alternative_t< I > newValue)
Definition keycode.h:129
const std::vector< KeyPress > & getKeySetting(const std::string &settingname)
Definition keycode.cpp:583
bool keySettingHasMatch(const std::string &settingname, KeyPress kp)
Definition keycode.cpp:601
void clearKeyCache()
Definition keycode.cpp:607
KeyType::T GameKeyType
Definition keys.h:109
KeyPressEvent(const SEvent &event)
Construct a KeyPressEvent from an Irrlicht event. User events (e.g. touchscreen input) is not handled...
Definition keycode.cpp:612
KeyPress key
Definition keycode.h:163
bool isPressed() const
Definition keycode.h:173
float analog_value
Definition keycode.h:164
size_t operator()(KeyPress kp) const noexcept
Definition keycode.h:139