Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
keycode.cpp File Reference
#include "keycode.h"
#include "gettext.h"
#include "settings.h"
#include "log.h"
#include "renderingengine.h"
#include "util/string.h"
#include <unordered_map>
#include <vector>
+ Include dependency graph for keycode.cpp:

Classes

struct  table_key
 

Macros

#define DEFINEKEY1(x, lang)
 
#define DEFINEKEY2(x, ch, lang)
 
#define DEFINEKEY3(ch)
 
#define DEFINEKEY4(ch)
 
#define DEFINEKEY5(ch)
 

Functions

static const table_keylookup_keychar (wchar_t Char)
 
static const table_keylookup_keykey (EKEY_CODE key)
 
static const table_keylookup_keyname (std::string_view name)
 
static const table_keylookup_scancode (const u32 scancode)
 
static const table_keylookup_scancode (const std::variant< u32, EKEY_CODE > &scancode)
 
KeyPress getKeySetting (const std::string &settingname)
 
void clearKeyCache ()
 

Variables

static std::vector< table_keytable
 
static const table_key invalid_key = {"", KEY_UNKNOWN, L'\0', ""}
 
std::unordered_map< std::string, KeyPressspecialKeyCache
 
static std::unordered_map< std::string, KeyPressg_key_setting_cache
 

Macro Definition Documentation

◆ DEFINEKEY1

#define DEFINEKEY1 ( x,
lang )
Value:
/* Irrlicht key without character */ \
{ #x, x, L'\0', lang },
constexpr v3f x
Definition test_irr_matrix4.cpp:18

◆ DEFINEKEY2

#define DEFINEKEY2 ( x,
ch,
lang )
Value:
/* Irrlicht key with character */ \
{ #x, x, ch, lang },

◆ DEFINEKEY3

#define DEFINEKEY3 ( ch)
Value:
/* single Irrlicht key (e.g. KEY_KEY_X) */ \
{ "KEY_KEY_" TOSTRING(ch), KEY_KEY_ ## ch, static_cast<wchar_t>(*TOSTRING(ch)), TOSTRING(ch) },
#define TOSTRING(x)
Definition string.h:28

◆ DEFINEKEY4

#define DEFINEKEY4 ( ch)
Value:
/* single Irrlicht function key (e.g. KEY_F3) */ \
{ "KEY_F" TOSTRING(ch), KEY_F ## ch, L'\0', "F" TOSTRING(ch) },

◆ DEFINEKEY5

#define DEFINEKEY5 ( ch)
Value:
/* key without Irrlicht keycode */ \
{ ch, KEY_KEY_CODES_COUNT, static_cast<wchar_t>(*ch), ch },

Function Documentation

◆ clearKeyCache()

void clearKeyCache ( )

References g_key_setting_cache.

Referenced by MyEventReceiver::reloadKeybindings().

+ Here is the caller graph for this function:

◆ getKeySetting()

KeyPress getKeySetting ( const std::string & settingname)

References g_key_setting_cache, g_settings, Settings::get(), and warningstream.

Referenced by id_to_keypress(), GUIChatConsole::OnEvent(), GUIFormSpecMenu::OnEvent(), MyEventReceiver::OnEvent(), GUIFormSpecMenu::preprocessEvent(), and MyEventReceiver::reloadKeybindings().

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

◆ lookup_keychar()

static const table_key & lookup_keychar ( wchar_t Char)
static

References table_key::Char, invalid_key, table, and wide_to_utf8().

Referenced by lookup_keyname(), and lookup_scancode().

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

◆ lookup_keykey()

static const table_key & lookup_keykey ( EKEY_CODE key)
static

References invalid_key, table_key::Key, and table.

Referenced by lookup_scancode(), and lookup_scancode().

+ Here is the caller graph for this function:

◆ lookup_keyname()

static const table_key & lookup_keyname ( std::string_view name)
static

References invalid_key, lookup_keychar(), table_key::Name, table, and utf8_to_wide().

Referenced by KeyPress::KeyPress().

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

◆ lookup_scancode() [1/2]

static const table_key & lookup_scancode ( const std::variant< u32, EKEY_CODE > & scancode)
static

References lookup_keykey(), and lookup_scancode().

+ Here is the call graph for this function:

◆ lookup_scancode() [2/2]

static const table_key & lookup_scancode ( const u32 scancode)
static

References RenderingEngine::get_raw_device(), lookup_keychar(), and lookup_keykey().

Referenced by KeyPress::getKeychar(), KeyPress::getKeycode(), lookup_scancode(), KeyPress::name(), and KeyPress::sym().

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

Variable Documentation

◆ g_key_setting_cache

std::unordered_map<std::string, KeyPress> g_key_setting_cache
static

Referenced by clearKeyCache(), and getKeySetting().

◆ invalid_key

const table_key invalid_key = {"", KEY_UNKNOWN, L'\0', ""}
static

◆ specialKeyCache

std::unordered_map<std::string, KeyPress> specialKeyCache

Referenced by KeyPress::getSpecialKey().

◆ table