00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _OgreBulletInputListener_H_
00019 #define _OgreBulletInputListener_H_
00020
00021 #include "Ogre.h"
00022
00023 #if (OGRE_VERSION < ((1 << 16) | (3 << 8) | 0))
00024
00025 #include "OgreInput.h"
00026 #include "OgreKeyEvent.h"
00027 #include "OgreEventListeners.h"
00028
00029
00030 #define BULLET_KEY_CODE int
00031 #define BULLET_KEY_EVENT Ogre::KeyEvent*
00032 #define BULLET_MOUSE_EVENT Ogre::MouseEvent*
00033 #define BULLET_KC Ogre::KC
00034 #define BULLET_LISTENER_IMPLEMENTATION_RETURN void
00035 #define BULLET_LISTENER_IMPLEMENTATION_RETURN_CODE
00036
00037
00038 #define BULLET_GETKEY e->getKey()
00039
00040 #define BULLET_BUTTON0_DOWN e->getButtonID() == e->BUTTON0_MASK
00041 #define BULLET_BUTTON1_DOWN e->getButtonID() == e->BUTTON1_MASK
00042 #define BULLET_BUTTON2_DOWN e->getButtonID() == e->BUTTON2_MASK
00043
00044 #define BULLET_BUTTON0_UP e->getButtonID() == e->BUTTON0_MASK
00045 #define BULLET_BUTTON1_UP e->getButtonID() == e->BUTTON1_MASK
00046 #define BULLET_BUTTON2_UP e->getButtonID() == e->BUTTON2_MASK
00047
00048 #define BULLET_GETRELX e->getRelX()
00049 #define BULLET_GETRELY e->getRelY()
00050
00051 #define BULLET_GETX e->getX()
00052 #define BULLET_GETY e->getY()
00053
00054 #else
00055
00056 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
00057 #include "OIS.h"
00058 #else
00059 #include "OIS.h"
00060 #endif
00061 namespace OIS
00062 {
00063 class Keyboard;
00064 class Mouse;
00065 };
00066
00067 #define BULLET_KEY_CODE OIS::KeyCode
00068 #define BULLET_KEY_EVENT const OIS::KeyEvent&
00069 #define BULLET_MOUSE_EVENT const OIS::MouseEvent&
00070 #define BULLET_KC OIS::KC
00071 #define BULLET_LISTENER_IMPLEMENTATION_RETURN bool
00072 #define BULLET_LISTENER_IMPLEMENTATION_RETURN_CODE return true;
00073
00074 #define BULLET_GETKEY e.key
00075
00076 #define BULLET_BUTTON0_DOWN buttonid == OIS::MB_Left
00077 #define BULLET_BUTTON1_DOWN buttonid == OIS::MB_Middle
00078 #define BULLET_BUTTON2_DOWN buttonid == OIS::MB_Right
00079
00080 #define BULLET_BUTTON0_UP buttonid == OIS::MB_Left
00081 #define BULLET_BUTTON1_UP buttonid == OIS::MB_Middle
00082 #define BULLET_BUTTON2_UP buttonid == OIS::MB_Right
00083
00084
00085 #define BULLET_GETRELX e.state.X.rel
00086 #define BULLET_GETRELY e.state.Y.rel
00087
00088 #define BULLET_GETX e.state.X.abs
00089 #define BULLET_GETY e.state.Y.abs
00090
00091 #endif //OGRE_VERSION not Eihort
00092
00093 #include "OgreBulletGuiListener.h"
00094 class OgreBulletListener;
00095
00096
00097
00098
00099 class OgreBulletInputListener :
00100 #if (OGRE_VERSION < ((1 << 16) | (3 << 8) | 0))
00101 public Ogre::MouseMotionListener,
00102 public Ogre::MouseListener,
00103 public Ogre::KeyListener
00104 #else
00105 public OIS::MouseListener,
00106 public OIS::KeyListener
00107 #endif
00108 {
00109 public:
00110 static const Ogre::Real KEY_DELAY;
00111
00112
00113 OgreBulletInputListener(OgreBulletListener * ogreBulletListener,
00114 Ogre::RenderWindow *win);
00115 virtual ~OgreBulletInputListener(){};
00116
00117
00118 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseDragged (BULLET_MOUSE_EVENT e);
00119 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseMoved (BULLET_MOUSE_EVENT e);
00120
00121
00122 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseClicked (BULLET_MOUSE_EVENT e);
00123 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseEntered (BULLET_MOUSE_EVENT e);
00124 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseExited (BULLET_MOUSE_EVENT e);
00125
00126 BULLET_LISTENER_IMPLEMENTATION_RETURN mousePressed (BULLET_MOUSE_EVENT e
00127 #if !(OGRE_VERSION < ((1 << 16) | (3 << 8) | 0))
00128 , OIS::MouseButtonID buttonid
00129 #endif
00130 );
00131 BULLET_LISTENER_IMPLEMENTATION_RETURN mouseReleased(BULLET_MOUSE_EVENT e
00132 #if !(OGRE_VERSION < ((1 << 16) | (3 << 8) | 0))
00133 , OIS::MouseButtonID buttonid
00134 #endif
00135 );
00136
00137
00138 BULLET_LISTENER_IMPLEMENTATION_RETURN keyClicked(BULLET_KEY_EVENT e);
00139 BULLET_LISTENER_IMPLEMENTATION_RETURN keyPressed(BULLET_KEY_EVENT e);
00140 BULLET_LISTENER_IMPLEMENTATION_RETURN keyReleased(BULLET_KEY_EVENT e);
00141
00142 Ogre::Real getRelMouseX() const {return mRelX;}
00143 Ogre::Real getRelMouseY() const {return mRelY;}
00144
00145 Ogre::Real getAbsMouseX() const {return mMouseCursorX;}
00146 Ogre::Real getAbsMouseY() const {return mMouseCursorY;}
00147
00148
00149 bool getButton0Pressed() const {return mButton0Pressed;}
00150 bool getButton1Pressed() const {return mButton1Pressed;}
00151 bool getButton2Pressed() const {return mButton2Pressed;}
00152
00153
00154 protected:
00155
00156
00157 Ogre::Real mRelX;
00158 Ogre::Real mRelY;
00159 Ogre::Real mMouseCursorX;
00160 Ogre::Real mMouseCursorY;
00161
00162 bool mButton0Pressed;
00163 bool mButton1Pressed;
00164 bool mButton2Pressed;
00165
00166
00167 Ogre::RenderWindow *mWindow;
00168 OgreBulletListener *mListener;
00169 };
00170
00171 #endif
00172