Luanti 5.16.0-dev
Loading...
Searching...
No Matches
KeyPress Class Reference

#include <keycode.h>

Public Types

enum class  InputType { KEYBOARD , MOUSE_BUTTON , GAME_ACTION }

Public Member Functions

 KeyPress ()=default
 KeyPress (const std::string &name)
 KeyPress (const SEvent::SKeyInput &in)
 KeyPress (const SEvent::SMouseInput &in)
 KeyPress (GameKeyType key)
std::string sym () const
std::string name () const
u32 getScancode () const
bool operator== (KeyPress o) const
bool operator!= (KeyPress o) const
bool operator< (KeyPress o) const
InputType getType () const
 operator bool () const

Static Public Member Functions

static KeyPress getSpecialKey (const std::string &name)

Private Types

using value_type = std::variant<u32, u32, GameKeyType>
template<InputType I>
using value_alternative_t = std::variant_alternative_t<static_cast<size_t>(I), value_type>

Private Member Functions

template<InputType I>
bool loadUnsignedFromPrefix (const std::string &name, const std::string &prefix)
bool loadFromScancode (const std::string &name)
void loadFromKey (EKEY_CODE keycode, wchar_t keychar)
template<InputType I>
value_alternative_t< I > get () const
template<InputType I>
std::add_pointer_t< const value_alternative_t< I > > getIf () const
template<InputType I>
void emplace (value_alternative_t< I > newValue)

Private Attributes

value_type value

Member Typedef Documentation

◆ value_alternative_t

template<InputType I>
using KeyPress::value_alternative_t = std::variant_alternative_t<static_cast<size_t>(I), value_type>
private

◆ value_type

using KeyPress::value_type = std::variant<u32, u32, GameKeyType>
private

Member Enumeration Documentation

◆ InputType

enum class KeyPress::InputType
strong
Enumerator
KEYBOARD 
MOUSE_BUTTON 
GAME_ACTION 

Constructor & Destructor Documentation

◆ KeyPress() [1/5]

KeyPress::KeyPress ( )
default

References name().

Referenced by getSpecialKey(), operator!=(), operator<(), and operator==().

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

◆ KeyPress() [2/5]

KeyPress::KeyPress ( const std::string & name)

References loadFromKey(), loadUnsignedFromPrefix(), lookup_keyname(), and name().

Here is the call graph for this function:

◆ KeyPress() [3/5]

KeyPress::KeyPress ( const SEvent::SKeyInput & in)

References emplace(), and loadFromKey().

Here is the call graph for this function:

◆ KeyPress() [4/5]

KeyPress::KeyPress ( const SEvent::SMouseInput & in)

References emplace().

Here is the call graph for this function:

◆ KeyPress() [5/5]

KeyPress::KeyPress ( GameKeyType key)
inline

References value.

Member Function Documentation

◆ emplace()

template<InputType I>
void KeyPress::emplace ( value_alternative_t< I > newValue)
inlineprivate

References value.

Referenced by KeyPress(), KeyPress(), loadFromKey(), and loadUnsignedFromPrefix().

Here is the caller graph for this function:

◆ get()

template<InputType I>
value_alternative_t< I > KeyPress::get ( ) const
inlineprivate

References value.

Referenced by name(), operator bool(), and sym().

Here is the caller graph for this function:

◆ getIf()

template<InputType I>
std::add_pointer_t< const value_alternative_t< I > > KeyPress::getIf ( ) const
inlineprivate

References value.

Referenced by getScancode().

Here is the caller graph for this function:

◆ getScancode()

u32 KeyPress::getScancode ( ) const
inline

References getIf().

Referenced by name().

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

◆ getSpecialKey()

KeyPress KeyPress::getSpecialKey ( const std::string & name)
static

References KeyPress(), name(), and specialKeyCache.

Here is the call graph for this function:

◆ getType()

InputType KeyPress::getType ( ) const
inline

References value.

Referenced by name(), operator bool(), and sym().

Here is the caller graph for this function:

◆ loadFromKey()

void KeyPress::loadFromKey ( EKEY_CODE keycode,
wchar_t keychar )
private

References emplace(), and RenderingEngine::get_raw_device().

Referenced by KeyPress(), and KeyPress().

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

◆ loadFromScancode()

bool KeyPress::loadFromScancode ( const std::string & name)
private

References name().

Here is the call graph for this function:

◆ loadUnsignedFromPrefix()

template<KeyPress::InputType I>
bool KeyPress::loadUnsignedFromPrefix ( const std::string & name,
const std::string & prefix )
private

References emplace(), name(), p(), and str_starts_with().

Referenced by KeyPress().

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

◆ name()

std::string KeyPress::name ( ) const

References fmtgettext(), get(), getScancode(), getType(), KEYBOARD, table_key::LangName, lookup_scancode(), MOUSE_BUTTON, name(), and strgettext().

Referenced by KeyPress(), KeyPress(), getSpecialKey(), ModApiMenuCommon::l_get_key_description(), loadFromScancode(), loadUnsignedFromPrefix(), name(), and GUIButtonKey::setKey().

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

◆ operator bool()

KeyPress::operator bool ( ) const

References GAME_ACTION, get(), getType(), KeyType::INTERNAL_ENUM_COUNT, KEYBOARD, and MOUSE_BUTTON.

Here is the call graph for this function:

◆ operator!=()

bool KeyPress::operator!= ( KeyPress o) const
inline

References KeyPress().

Here is the call graph for this function:

◆ operator<()

bool KeyPress::operator< ( KeyPress o) const
inline

References KeyPress(), and value.

Here is the call graph for this function:

◆ operator==()

bool KeyPress::operator== ( KeyPress o) const
inline

References KeyPress(), and value.

Here is the call graph for this function:

◆ sym()

std::string KeyPress::sym ( ) const

References get(), getType(), KEYBOARD, and MOUSE_BUTTON.

Referenced by GUIButtonKey::setKey().

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

Member Data Documentation

◆ value

value_type KeyPress::value
private

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