C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/include/InputManager.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #ifndef INPUTMANAGER_H
00022 #define INPUTMANAGER_H
00023 
00024 #include "GameEnginePrerequisites.h"
00025 #include "Process.h"
00026 #include "Event.h"
00027 #include "EventManager.h"
00028 #include "Singleton.h"
00029 #include "GameApp.h"
00030 
00031 namespace GameEngine {
00032         
00033         class GameApp;
00034 
00037         class ENGINE_DECL InputManager : public Process, public OIS::KeyListener, public OIS::MouseListener, public GameEngine::Singleton<InputManager>
00038         {
00039         public:
00044                 InputManager(GameApp* application);
00045 
00048                 ~InputManager();
00049 
00054                 bool init();
00055 
00060                 void update(const double& dt);
00061 
00062 
00067                 CEGUI::MouseButton convertOisButtonToCegui(OIS::MouseButtonID buttonId) const; // Convert OIS ids to CEGUI ids
00068 
00069         private:
00070                 GameApp* mApplication;
00071 
00072                 OIS::InputManager* mInputManager;
00073                 OIS::Keyboard* mKeyboard;
00074                 OIS::Mouse* mMouse;
00075 
00082                 bool keyPressed (const OIS::KeyEvent& arg);
00083 
00090                 bool keyReleased (const OIS::KeyEvent& arg);
00091 
00092 
00099                 bool mouseMoved (const OIS::MouseEvent &arg);
00100 
00107                 bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00108 
00115                 bool mouseReleased (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
00116 
00117         };
00118 
00119 
00120         // Events and event data ////////////////////////////////////////////////////
00121 
00124         class KeyboardEventData : public IEventData
00125         {
00126         public:
00127                 KeyboardEventData(const OIS::KeyEvent& event) : mEvent(event) {}
00128 
00129                 const OIS::KeyEvent mEvent;
00130         };
00131 
00134         class KeyPressedEvent : public Event
00135         {
00136                 static char const * const eventName;
00137 
00138         public:
00139                 KeyPressedEvent(const OIS::KeyEvent& event) : Event(eventName, 0, IEventDataPtr(new KeyboardEventData(event)) ) {}
00140 
00141         };
00142 
00145         class KeyReleasedEvent : public Event
00146         {
00147                 static char const * const eventName;
00148 
00149         public:
00150                 KeyReleasedEvent(const OIS::KeyEvent& event) : Event(eventName, 0, IEventDataPtr(new KeyboardEventData(event)) ) {}
00151 
00152         };
00153 
00154         
00155 
00156 
00159         class MouseMovedEventData : public IEventData
00160         {
00161         public:
00162                 MouseMovedEventData(const OIS::MouseEvent& event) : mEvent(event) {}
00163 
00164                 const OIS::MouseEvent mEvent;
00165         };
00166 
00169         class MouseButtonEventData : public IEventData
00170         {
00171         public:
00172                 MouseButtonEventData(const OIS::MouseEvent& event, OIS::MouseButtonID id) : mEvent(event), mButtonId(id) {}
00173                 
00174                 const OIS::MouseEvent mEvent;
00175                 OIS::MouseButtonID mButtonId;
00176         };
00177 
00178 
00181         class MouseMovedEvent : public Event
00182         {
00183                 static char const * const eventName;
00184 
00185         public:
00186                 MouseMovedEvent(const OIS::MouseEvent &event) : Event(eventName, 0, IEventDataPtr(new MouseMovedEventData(event)) ) {}
00187         };
00188 
00189 
00192         class MouseButtonPressedEvent : public Event
00193         {
00194                 static char const * const eventName;
00195 
00196         public:
00197                 MouseButtonPressedEvent(const OIS::MouseEvent &event, OIS::MouseButtonID id) : Event(eventName, 0, IEventDataPtr(new MouseButtonEventData(event, id)) ) {}
00198 
00199         };
00200 
00203         class MouseButtonReleasedEvent : public Event
00204         {
00205                 static char const * const eventName;
00206 
00207         public:
00208                 MouseButtonReleasedEvent(const OIS::MouseEvent &event, OIS::MouseButtonID id) : Event(eventName, 0, IEventDataPtr(new MouseButtonEventData(event, id)) ) {}
00209 
00210         };
00211 
00212 
00213 }
00214 
00215 #endif

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2