KeyboardKey.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3