From 85671408eed36060f5ff4799f2ee153d66e16282 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 3 Jan 2015 16:54:18 +0000 Subject: Minor cleanup of client::Action and client::Keyboard code, added Action::FreeLook defintions. --- src/client/keyboard.h | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'src/client/keyboard.h') diff --git a/src/client/keyboard.h b/src/client/keyboard.h index f533838..0742b9c 100644 --- a/src/client/keyboard.h +++ b/src/client/keyboard.h @@ -21,7 +21,11 @@ namespace client class Keyboard { -public: +public: + typedef std::map Keys; + + typedef std::list Actions; + Keyboard(); ~Keyboard(); @@ -39,21 +43,24 @@ public: /// celar all key binds void unbindall(); + + /// reset key states + void reset(); /// list keyboard key names - void list_keys(); + void list_keys() const; /// list actions - void list_actions(); + void list_actions() const; /// list keyboard binds - void list_binds(); + void list_binds() const; /// load keyboard binds - void load_binds(); + void load_binds() const; /// save keyboard binds - void save_binds(); + void save_binds() const; /// a key has been pressed Key *press(unsigned int sym); @@ -64,36 +71,23 @@ public: /// a key has been pressed Key *release(unsigned int sym); - typedef std::map::iterator iterator; - - inline iterator begin() { - return keys.begin(); - } - - inline iterator end() { - return keys.end(); - } - /// convert SDL_keysym to a keystroke - static unsigned int translate_keysym(int keysym, int modifier); + static unsigned int translate_keysym(const int keysym, const int modifiers); + + inline Keys & keys() + { + return _keys; + } private: Key *add_key(const char *name, const unsigned int keysym, const char ascii = 0, const char *bind = 0); - Action *add_action(const char *name, Action::Identifier action, const char *info = 0); + Action *add_action(const char *name, Action::Identifier id, const char *description = 0); - std::map keys; - std::list actions; - - bool numlock; - bool capslock; + Keys _keys; + Actions _actions; }; -/// set the keyboard input mode -/** @param input true for console input, false for game input - */ -//void setkeyboardmode(bool input); - } #endif // __INCLUDED_CLIENT_KEYBOARD_H__ -- cgit v1.2.3