X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fkeycode.h;h=28fb3f1fb86ccaf7ba7e3e85c0dd077b82407a65;hb=e278742c5e0fc644c571aa5a688ea72c34aaea25;hp=9c62004d8f744644185d61ad4ded8bfab9abb4a1;hpb=308d8613276ef695d587e72773f0b96253cdb328;p=oweals%2Fminetest.git diff --git a/src/keycode.h b/src/keycode.h index 9c62004d8..28fb3f1fb 100644 --- a/src/keycode.h +++ b/src/keycode.h @@ -23,12 +23,45 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include -irr::EKEY_CODE keyname_to_keycode(const char *name); +/* A key press, consisting of either an Irrlicht keycode + or an actual char */ + +class KeyPress +{ +public: + KeyPress(); + KeyPress(const char *name); + + KeyPress(const irr::SEvent::SKeyInput &in); + + bool operator==(const KeyPress &o) const + { + return valid_kcode(Key) ? Key == o.Key : Char == o.Char; + } + + const char *sym() const; + const char *name() const; + + std::string debug() const; +protected: + static bool valid_kcode(irr::EKEY_CODE k) + { + return k > 0 && k < irr::KEY_KEY_CODES_COUNT; + } + + irr::EKEY_CODE Key; + wchar_t Char; + std::string m_name; +}; + +extern const KeyPress EscapeKey; +extern const KeyPress NumberKey[10]; // Key configuration getter -irr::EKEY_CODE getKeySetting(const char *settingname); -std::string keycode_to_keyname(s32 keycode); -void clearCache(); +KeyPress getKeySetting(const char *settingname); + +// Clear fast lookup cache +void clearKeyCache(); #endif