2014-01-05 17:22:29 +00:00
|
|
|
#ifndef SDL4OGRE_SDLINPUTWRAPPER_H
|
|
|
|
#define SDL4OGRE_SDLINPUTWRAPPER_H
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2014-06-05 17:52:41 +00:00
|
|
|
#define NOMINMAX
|
|
|
|
|
2013-01-12 21:52:26 +00:00
|
|
|
#include <SDL_events.h>
|
2013-01-12 15:57:29 +00:00
|
|
|
|
2013-01-12 21:52:26 +00:00
|
|
|
#include <OgreRenderWindow.h>
|
2013-01-10 21:21:47 +00:00
|
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
|
|
|
|
#include "OISCompat.h"
|
|
|
|
#include "events.h"
|
|
|
|
|
|
|
|
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
namespace SFO
|
|
|
|
{
|
2013-01-12 15:57:29 +00:00
|
|
|
class InputWrapper
|
2013-01-10 21:21:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-11-29 19:06:54 +00:00
|
|
|
InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow, bool grab);
|
2013-01-12 15:57:29 +00:00
|
|
|
~InputWrapper();
|
2013-01-10 21:21:47 +00:00
|
|
|
|
|
|
|
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
|
|
|
|
void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; }
|
|
|
|
void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; }
|
2013-07-29 00:32:08 +00:00
|
|
|
void setJoyEventCallback(JoyListener* listen) { mJoyListener = listen; }
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
void capture(bool windowEventsOnly);
|
2013-07-29 00:32:08 +00:00
|
|
|
bool isModifierHeld(SDL_Keymod mod);
|
|
|
|
bool isKeyDown(SDL_Scancode key);
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2013-11-20 15:05:24 +00:00
|
|
|
void setMouseVisible (bool visible);
|
2013-01-10 21:21:47 +00:00
|
|
|
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 12:27:59 +00:00
|
|
|
|
2013-11-20 15:05:24 +00:00
|
|
|
void updateMouseSettings();
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
private:
|
2013-01-11 03:29:51 +00:00
|
|
|
|
2013-06-15 13:33:47 +00:00
|
|
|
void handleWindowEvent(const SDL_Event& evt);
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
bool _handleWarpMotion(const SDL_MouseMotionEvent& evt);
|
|
|
|
void _wrapMousePointer(const SDL_MouseMotionEvent &evt);
|
|
|
|
MouseMotionEvent _packageMouseMotion(const SDL_Event& evt);
|
|
|
|
|
|
|
|
void _setupOISKeys();
|
|
|
|
|
|
|
|
SFO::MouseListener* mMouseListener;
|
|
|
|
SFO::KeyListener* mKeyboardListener;
|
|
|
|
SFO::WindowListener* mWindowListener;
|
2013-07-29 00:32:08 +00:00
|
|
|
SFO::JoyListener* mJoyListener;
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2013-01-11 04:37:04 +00:00
|
|
|
typedef boost::unordered_map<SDL_Keycode, OIS::KeyCode> KeyMap;
|
2013-01-10 21:21:47 +00:00
|
|
|
KeyMap mKeyMap;
|
|
|
|
|
|
|
|
Uint16 mWarpX;
|
|
|
|
Uint16 mWarpY;
|
|
|
|
bool mWarpCompensate;
|
|
|
|
bool mWrapPointer;
|
2013-11-20 15:05:24 +00:00
|
|
|
|
2013-11-29 19:06:54 +00:00
|
|
|
bool mAllowGrab;
|
2013-11-20 15:05:24 +00:00
|
|
|
bool mWantMouseVisible;
|
|
|
|
bool mWantGrab;
|
|
|
|
bool mWantRelative;
|
2013-01-10 21:21:47 +00:00
|
|
|
bool mGrabPointer;
|
2013-11-20 15:05:24 +00:00
|
|
|
bool mMouseRelative;
|
2013-01-10 21:21:47 +00:00
|
|
|
|
|
|
|
Sint32 mMouseZ;
|
|
|
|
Sint32 mMouseX;
|
|
|
|
Sint32 mMouseY;
|
|
|
|
|
2013-11-20 15:05:24 +00:00
|
|
|
bool mWindowHasFocus;
|
2013-06-15 13:33:47 +00:00
|
|
|
bool mMouseInWindow;
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
SDL_Window* mSDLWindow;
|
2013-06-15 11:22:29 +00:00
|
|
|
Ogre::RenderWindow* mOgreWindow;
|
2013-01-10 21:21:47 +00:00
|
|
|
};
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|