Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

scancodemap.cpp

Go to the documentation of this file.
00001 #include "scancodemap.h"
00002 
00003 using namespace kerosin;
00004 
00005 ScanCodeMap::ScanCodeMap()
00006 {
00007 }
00008 
00009 ScanCodeMap::~ScanCodeMap()
00010 {
00011 }
00012 
00013 kerosin::InputServer::TInputCode ScanCodeMap::GetCode(const std::string &name) const
00014 {
00015     // loop through all entries in the map and find the one, which matches the symbolic name
00016     for (TScanCodeEntryMap::const_iterator i = mScanCodes.begin(); i != mScanCodes.end(); ++i)
00017     {
00018         if ((*i).second->name == name) return (*i).first;
00019     }
00020 
00021     return 0;
00022 }
00023 
00024 bool ScanCodeMap::TranslateCode(kerosin::InputServer::TInputCode code, unsigned long state, char &ch) const
00025 {
00026     if ((state & InputServer::eShift) && (state & InputServer::eAlt)) return false;
00027 
00028     TScanCodeEntryMap::const_iterator entry = mScanCodes.find(code);
00029 
00030     if (entry != mScanCodes.end())
00031     {
00032         if (state & InputServer::eShift)
00033         {
00034             ch = (*entry).second->shiftModifier;
00035             return ch != 0;
00036         }
00037         if (state & InputServer::eAlt)
00038         {
00039             ch = (*entry).second->altModifier;
00040             return ch != 0;
00041         }
00042         ch = (*entry).second->noModifier;
00043         return ch != 0;
00044     }
00045 
00046     return false;
00047 }
00048 
00049 void ScanCodeMap::Reset()
00050 {
00051     for (TScanCodeEntryMap::iterator i = mScanCodes.begin(); i != mScanCodes.end(); ++i)
00052     {
00053         delete (*i).second;
00054     }
00055 }
00056 
00057 void ScanCodeMap::AddCode(InputServer::TInputCode ic, const std::string &name, char noMod, char shiftMod, char altMod)
00058 {
00059     TScanCodeEntry *entry = new TScanCodeEntry();
00060     entry->Set(name, noMod, shiftMod, altMod);
00061     mScanCodes[ic] = entry;
00062 }

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4