Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/key.h')
-rw-r--r--src/client/key.h22
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;