00001 00011 /*************************************************************************** 00012 * Copyright (C) 2007 by Jan Koci * 00013 * honza.koci@email.cz * 00014 * http://kengine.sourceforge.net/tutorial/ 00015 * * 00016 * This program is free software; you can redistribute it and/or modify * 00017 * it under the terms of the GNU General Public License as published by * 00018 * the Free Software Foundation; either version 2 of the License, or * 00019 * (at your option) any later version. * 00020 * * 00021 * This program is distributed in the hope that it will be useful, * 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00024 * GNU General Public License for more details. * 00025 * * 00026 * You should have received a copy of the GNU General Public License * 00027 * along with this program; if not, write to the * 00028 * Free Software Foundation, Inc., * 00029 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00030 ***************************************************************************/ 00031 00032 #include "K3dKeyMap.h" 00033 00034 K3dKeyMap::K3dKeyMap(K3dGameData *_pGameData) 00035 { 00036 m_pGameData = _pGameData; 00037 // Set this class to the global data 00038 m_pGameData->SetKeyMap(this); 00039 } 00040 00041 K3dKeyMap::~K3dKeyMap() 00042 { 00043 DeleteKeyMap(); 00044 } 00045 00047 bool K3dKeyMap::IsKeyPressed(EKeyMapAction _eKey) 00048 { 00049 return IsSdlKeyPressed(m_tKeyMap[_eKey]); 00050 } 00051 00054 EKeyMapAction K3dKeyMap::FindKeyMapAction(const int _iVal) 00055 { 00056 for(TKeyMap::iterator i = m_tKeyMap.begin(); i!=m_tKeyMap.end(); ++i) 00057 { 00058 // Get value 00059 int iVal = i->second; 00060 if(iVal == _iVal) 00061 { 00062 // Get key 00063 EKeyMapAction e = i->first; 00064 return e; 00065 } 00066 } 00067 K3dString strNum; 00068 strNum.SetNum(_iVal); 00069 cerr << "Error in EKeyMapAction FindKeyMapAction( ) -- Error - Value " + strNum.GetString() + " Doesn`t exists" << endl; 00070 return K_NUM_ACTION; 00071 }