2013-01-12 11:57:29 -04:00
|
|
|
#ifndef _SDL4OGRE_SDLINPUTWRAPPER_H
|
|
|
|
#define _SDL4OGRE_SDLINPUTWRAPPER_H
|
2013-01-10 17:21:47 -04:00
|
|
|
|
2013-01-12 17:52:26 -04:00
|
|
|
#include <SDL_events.h>
|
2013-01-12 11:57:29 -04:00
|
|
|
|
2013-01-12 17:52:26 -04:00
|
|
|
#include <OgreRenderWindow.h>
|
2013-01-10 17:21:47 -04:00
|
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
|
|
|
|
#include "OISCompat.h"
|
|
|
|
#include "events.h"
|
|
|
|
|
|
|
|
|
2013-01-11 08:27:59 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
namespace SFO
|
|
|
|
{
|
2013-01-12 11:57:29 -04:00
|
|
|
class InputWrapper
|
2013-01-10 17:21:47 -04:00
|
|
|
{
|
|
|
|
public:
|
2013-01-13 23:38:46 -04:00
|
|
|
InputWrapper(SDL_Window *window=NULL);
|
2013-01-12 11:57:29 -04:00
|
|
|
~InputWrapper();
|
2013-01-10 17:21:47 -04:00
|
|
|
|
2013-06-12 12:34:33 +02:00
|
|
|
//void initFromRenderWindow(Ogre::RenderWindow* win);
|
2013-01-13 23:38:46 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
|
|
|
|
void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; }
|
|
|
|
void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; }
|
|
|
|
|
|
|
|
void capture();
|
|
|
|
bool isModifierHeld(int mod);
|
|
|
|
|
|
|
|
void setMouseRelative(bool relative);
|
|
|
|
bool getMouseRelative() { return mMouseRelative; }
|
|
|
|
void setGrabPointer(bool grab);
|
|
|
|
|
|
|
|
OIS::KeyCode sdl2OISKeyCode(SDL_Keycode code);
|
|
|
|
|
|
|
|
void warpMouse(int x, int y);
|
2013-01-11 08:27:59 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
private:
|
2013-01-10 23:29:51 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
|
|
|
|
void _wrapMousePointer(const SDL_MouseMotionEvent &evt);
|
|
|
|
MouseMotionEvent _packageMouseMotion(const SDL_Event& evt);
|
|
|
|
|
2013-01-10 23:29:51 -04:00
|
|
|
void _handleKeyPress(SDL_KeyboardEvent& evt);
|
|
|
|
Uint32 _UTF8ToUTF32(const unsigned char *buf);
|
2013-01-10 17:21:47 -04:00
|
|
|
void _setupOISKeys();
|
|
|
|
|
|
|
|
SFO::MouseListener* mMouseListener;
|
|
|
|
SFO::KeyListener* mKeyboardListener;
|
|
|
|
SFO::WindowListener* mWindowListener;
|
|
|
|
|
2013-01-11 00:37:04 -04:00
|
|
|
typedef boost::unordered_map<SDL_Keycode, OIS::KeyCode> KeyMap;
|
2013-01-10 17:21:47 -04:00
|
|
|
KeyMap mKeyMap;
|
|
|
|
|
|
|
|
Uint16 mWarpX;
|
|
|
|
Uint16 mWarpY;
|
|
|
|
bool mWarpCompensate;
|
|
|
|
bool mMouseRelative;
|
|
|
|
bool mWrapPointer;
|
|
|
|
bool mGrabPointer;
|
|
|
|
|
|
|
|
Sint32 mMouseZ;
|
|
|
|
Sint32 mMouseX;
|
|
|
|
Sint32 mMouseY;
|
|
|
|
|
|
|
|
SDL_Window* mSDLWindow;
|
2013-01-13 23:38:46 -04:00
|
|
|
bool mOwnWindow;
|
2013-01-10 17:21:47 -04:00
|
|
|
};
|
2013-01-11 08:27:59 -04:00
|
|
|
|
2013-01-10 17:21:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|