X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fkeycode.h;h=51d9adf72ecd65eec95882af5a791826fabc618f;hb=58bed83d03bbe53f8286640fbc33043800e1c318;hp=300682b121d7fded978b9638bdfebde227b46bfe;hpb=6c2d95f8686a7c08ed8648aa111accef50f58f73;p=dragonfireclient.git diff --git a/src/keycode.h b/src/keycode.h index 300682b12..51d9adf72 100644 --- a/src/keycode.h +++ b/src/keycode.h @@ -23,11 +23,43 @@ 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); -std::string keycode_to_keyname(s32 keycode); +/* 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 (Char > 0 && Char == o.Char) || + (valid_kcode(Key) && Key == o.Key); + } + + 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); +KeyPress getKeySetting(const char *settingname); // Clear fast lookup cache void clearKeyCache();