summaryrefslogtreecommitdiff
path: root/src/keycode.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-08-22 14:46:52 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-08-22 14:46:52 +0300
commit836e43db60ff1f3c9d160d0d58ba5a631c4293fc (patch)
tree89096c3ffd4128694542ebdbfabe94b6a618e16d /src/keycode.h
parent6596e585fe844ce87a957bb7deaf2bf92d828592 (diff)
parent7e610aece52ad547d4ae263aff5297342d5a4bff (diff)
downloadminetest-836e43db60ff1f3c9d160d0d58ba5a631c4293fc.tar.gz
minetest-836e43db60ff1f3c9d160d0d58ba5a631c4293fc.tar.bz2
minetest-836e43db60ff1f3c9d160d0d58ba5a631c4293fc.zip
Merge remote-tracking branch 'oblomov/new_input'
Diffstat (limited to 'src/keycode.h')
-rw-r--r--src/keycode.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/keycode.h b/src/keycode.h
index e64cb362c..28fb3f1fb 100644
--- a/src/keycode.h
+++ b/src/keycode.h
@@ -23,11 +23,42 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h"
#include <string>
-irr::EKEY_CODE keyname_to_keycode(const char *name);
-const char *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 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);
+KeyPress getKeySetting(const char *settingname);
// Clear fast lookup cache
void clearKeyCache();