diff options
author | Stijn Buys <ingar@osirion.org> | 2010-02-21 19:45:50 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-02-21 19:45:50 +0000 |
commit | fe229598d7437a85988eb9255cd0f6bdb6e07cb7 (patch) | |
tree | db45ca0f0732f3dbb3fd2546dc5881a1aec6ae61 /src/client/key.h | |
parent | 730c452ff5896ed66114e6b2153add9379edef5c (diff) |
optimized keyboard input handling routines
Diffstat (limited to 'src/client/key.h')
-rw-r--r-- | src/client/key.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/client/key.h b/src/client/key.h index 3bb3e2b..3d97dd1 100644 --- a/src/client/key.h +++ b/src/client/key.h @@ -11,19 +11,24 @@ #include <string> +#include "client/action.h" + namespace client { -/// a pressable key /** + * @brief a key on the keyboard * a Key instance can contain any kind of 'key' like a keyboard key, - * a mouse button, or a joystick button + * a mouse button, or a joystick button. Any key can be bound to + * a command string or an action. + * @see Action + * @see Keyboard */ class Key { public: /// define a new key - Key(const char *name, int keysym, char ascii = 0, const char *bind = 0); + Key(const char *name, int keysym, char ascii = 0); ~Key(); /// key modifiers @@ -33,7 +38,7 @@ public: void clear(); /// set the bind for a specific modifier - void assign(Modifier mod, const char *bind); + void assign(Modifier mod, const char *bind, Action *action = 0); /// clear the bind for a specific modifier void clear(Modifier mod); @@ -41,6 +46,11 @@ public: /// return the bind for a specific modifier std::string const & bind(Modifier mod) const; + /// return the action this key is bound to, 0 if unbound + inline Action *action() const { + return key_action; + } + /// first time the key was pressed since previous release inline float pressed() const { return key_pressed; @@ -74,8 +84,10 @@ public: private: std::string key_name; - int key_sym; + int key_sym; char key_ascii; + + Action *key_action; std::string key_bind; std::string key_bind_shift; |