K3dKeyMap.h

Go to the documentation of this file.
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 #pragma once
00033 
00034 #include <iostream>
00035 #include <map>
00036 using namespace std;
00037 #include "K3dKeyboard.h"
00038 #include "../System/K3dString.h"
00039 #include "../System/GameData/K3dGameData.h"
00040 
00041 enum EKeyMapAction
00042 {
00043         K_GO_FORWARD=0,
00044         K_GO_BACKWARD,
00045         K_GO_UP,
00046         K_GO_DOWN,
00047         K_STRAFE_LEFT,
00048         K_STRAFE_RIGHT,
00049         K_LURCH_LEFT,
00050         K_LURCH_RIGHT,
00051         K_TURN_LEFT,
00052         K_TURN_RIGHT,
00053         K_TURN_UP,
00054         K_TURN_DOWN,
00055         K_NUM_ACTION
00056 };
00057 
00058 typedef std::map<EKeyMapAction, int> TKeyMap;
00059 
00060 class K3dKeyMap: public K3dKeyboard
00061 {
00062                 K3dGameData *m_pGameData;       
00063                 TKeyMap m_tKeyMap;      
00064         public:
00065                 K3dKeyMap ( K3dGameData *_pGameData );
00066                 ~K3dKeyMap();
00067 
00069                 void InsertKeyMap ( EKeyMapAction _eAction, int _iSDLKey )
00070                 {
00071                         m_tKeyMap.insert ( pair<EKeyMapAction, int> ( _eAction, _iSDLKey ) );
00072                 }
00073                 bool IsKeyPressed ( EKeyMapAction _eKey );
00074 
00076                 void DeleteKeyMap()
00077                 {
00078                         m_tKeyMap.clear();
00079                 }
00080                 EKeyMapAction FindKeyMapAction ( const int _iVal );
00081 
00084                 int FindMapValue ( EKeyMapAction _eAction )
00085                 {
00086                         return m_tKeyMap[_eAction];
00087                 }
00088 };

Generated on Thu Aug 16 23:53:25 2007 for K3dEngine by  doxygen 1.5.0