Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-06-02 16:20:47 +0000
committerStijn Buys <ingar@osirion.org>2008-06-02 16:20:47 +0000
commit8c17868585e2a12f947ec387947c4521ef21d775 (patch)
tree83d36d3dc36698aa0d36a3b9b9a8bb0826520586 /src/client/keyboard.h
parent0f87d2fd05786f7ab128d4a041673f6fb085139f (diff)
keyboard binds
Diffstat (limited to 'src/client/keyboard.h')
-rw-r--r--src/client/keyboard.h66
1 files changed, 61 insertions, 5 deletions
diff --git a/src/client/keyboard.h b/src/client/keyboard.h
index 6805818..fb9efaf 100644
--- a/src/client/keyboard.h
+++ b/src/client/keyboard.h
@@ -4,21 +4,77 @@
the terms and conditions of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_CLIENT_KEYS_H__
-#define __INCLUDED_CLIENT_KEYS_H__
+#ifndef __INCLUDED_CLIENT_KEYBOARD_H__
+#define __INCLUDED_CLIENT_KEYBOARD_H__
+
+#include <string>
+#include <map>
#include "SDL/SDL.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
+ void bind(std::string const &name, const std::string str);
+
+ /// clear the string bound to a key
+ void unbind(std::string const &name);
+
+ /// list keyboard key names
+ void list_keys();
+
+ /// 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 *release(unsigned int sym);
+
+private:
+ typedef std::map<unsigned int, Key *>::iterator iterator;
+
+ inline iterator begin() { return keys.begin(); }
+
+ inline iterator end() { return keys.end(); }
+
+ void add_key(const char *name, const unsigned int keysym, const char ascii=0, const char *bind=0);
+
+ std::map<unsigned int, Key *> keys;
+
+ bool numlock;
+ bool capslock;
+};
+
/// convert SDL_keysym to a keystroke
-int translate_keysym(const SDL_keysym &keysym);
+unsigned int translate_keysym(const SDL_keysym &keysym);
/// set the keyboard input mode
/** @param input true for console input, false for game input
*/
void setkeyboardmode(bool input);
-} // namespace client
+}
-#endif // __INCLUDED_CLIENT_KEYS_H__
+#endif // __INCLUDED_CLIENT_KEYBOARD_H__