1 /*! 2 @file 3 @author Albert Semenov 4 @date 09/2009 5 @module 6 */ 7 8 #ifndef INPUT_MANAGER_H_ 9 #define INPUT_MANAGER_H_ 10 11 #include <MyGUI.h> 12 #include <windows.h> 13 #include <OIS.h> 14 15 namespace input 16 { 17 18 class InputManager : 19 public OIS::KeyListener 20 { 21 public: 22 InputManager(); 23 virtual ~InputManager(); 24 25 void createInput(size_t _handle); 26 void destroyInput(); 27 void captureInput(); 28 void setInputViewSize(int _width, int _height); 29 injectMouseMove(int _absx,int _absy,int _absz)30 virtual void injectMouseMove(int _absx, int _absy, int _absz) { } injectMousePress(int _absx,int _absy,MyGUI::MouseButton _id)31 virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id) { } injectMouseRelease(int _absx,int _absy,MyGUI::MouseButton _id)32 virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id) { } injectKeyPress(MyGUI::KeyCode _key,MyGUI::Char _text)33 virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text) { } injectKeyRelease(MyGUI::KeyCode _key)34 virtual void injectKeyRelease(MyGUI::KeyCode _key) { } 35 onFileDrop(const std::wstring & _filename)36 virtual void onFileDrop(const std::wstring& _filename) { } onWindowClose(size_t _handle)37 virtual bool onWindowClose(size_t _handle) { return true; } 38 39 void setMousePosition(int _x, int _y); 40 void updateCursorPosition(); 41 42 private: 43 static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 44 45 virtual bool keyPressed(const OIS::KeyEvent& _arg); 46 virtual bool keyReleased(const OIS::KeyEvent& _arg); 47 48 void frameEvent(float _time); 49 void computeMouseMove(); 50 51 void mouseMove(int _absx, int _absy, int _absz); 52 void mousePress(int _absx, int _absy, MyGUI::MouseButton _id); 53 void mouseRelease(int _absx, int _absy, MyGUI::MouseButton _id); 54 55 private: 56 static InputManager* msInputManager; 57 HWND mHwnd; 58 static LRESULT msOldWindowProc; 59 int mWidth; 60 int mHeight; 61 static bool msSkipMove; 62 int mMouseX; 63 int mMouseY; 64 int mMouseZ; 65 bool mMouseMove; 66 67 OIS::InputManager* mInputManager; 68 OIS::Keyboard* mKeyboard; 69 }; 70 71 } // namespace input 72 73 #endif // INPUT_MANAGER_H_ 74