00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __keyboardKey_h__
00022 #define __keyboardKey_h__
00023
00024 #include <string>
00025 #include <list>
00026 #include <vector>
00027
00028 class KeyboardKey
00029 {
00030 public:
00031 struct KeyEntry
00032 {
00033 unsigned int key;
00034 unsigned int state;
00035 };
00036
00037 KeyboardKey(const char *name,
00038 const char *title,
00039 const char *description,
00040 int group,
00041 bool command);
00042 virtual ~KeyboardKey();
00043
00044 bool keyDown(char *buffer, unsigned int keyState, bool repeat = true);
00045 bool keyMatch(unsigned key);
00046
00047 bool addKeys(std::list<std::string> &keyNames,
00048 std::list<std::string> &keyStates);
00049 void addKey(unsigned int position,
00050 unsigned int key, unsigned int state);
00051 void removeKey(unsigned int position);
00052 int keyIndex(unsigned int key, unsigned int state);
00053
00054 std::vector<KeyEntry> &getKeys() { return keys_; }
00055 const char *getName() { return name_.c_str(); }
00056 const char *getTitle() { return title_.c_str(); }
00057 const char *getDescription() { return description_.c_str(); }
00058 int getGroup() { return group_; }
00059 bool getNameIsCommand() { return command_; }
00060 bool getChanged() { return changed_; }
00061 void setChanged(bool changed) { changed_ = changed; }
00062
00063 static bool translateKeyName(const char *name, unsigned int &key);
00064 static bool translateKeyState(const char *name, unsigned int &state);
00065 static bool translateKeyNameValue(unsigned int key, const char *&name);
00066 static bool translateKeyStateValue(unsigned int state, const char *&name);
00067
00068 protected:
00069 std::string name_;
00070 std::string title_;
00071 std::string description_;
00072 std::vector<KeyEntry> keys_;
00073 int group_;
00074 bool keyToogle_;
00075 bool command_;
00076 bool changed_;
00077
00078 private:
00079 KeyboardKey(const KeyboardKey &);
00080 const KeyboardKey & operator=(const KeyboardKey &);
00081
00082 };
00083
00084 #endif // __keyboardKey_h__
00085