/* client/keyboard.h This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #ifndef __INCLUDED_CLIENT_KEYBOARD_H__ #define __INCLUDED_CLIENT_KEYBOARD_H__ #include #include #include #include "SDL/SDL.h" #include "client/action.h" #include "client/key.h" namespace client { class Keyboard { public: Keyboard(); ~Keyboard(); /// find a key on a keysym Key *find(unsigned int keysym); /// find a key on name Key *find(std::string const & name); /// bind a string to a key, if str is empty, just list void bind(std::string const &name, const std::string str); /// clear the string bound to a key void unbind(std::string const &name); /// celar all key binds void unbindall(); /// list keyboard key names void list_keys(); /// list actions void list_actions(); /// list keyboard binds void list_binds(); /// load keyboard binds void load_binds(); /// save keyboard binds void save_binds(); /// a key has been pressed Key *press(unsigned int sym); /// a key has been pressed Key *press(Key *key); /// 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); 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); std::map keys; std::list actions; bool numlock; bool capslock; }; /// set the keyboard input mode /** @param input true for console input, false for game input */ //void setkeyboardmode(bool input); } #endif // __INCLUDED_CLIENT_KEYBOARD_H__