2015-05-13 14:50:47 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_SDLUTIL_SDLINPUTWRAPPER_H
|
|
|
|
#define OPENMW_COMPONENTS_SDLUTIL_SDLINPUTWRAPPER_H
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
#include <map>
|
2014-06-05 17:52:41 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
#include <osg/ref_ptr>
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
#include <SDL_events.h>
|
2016-12-17 10:52:17 +00:00
|
|
|
#include <SDL_version.h>
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
#include "events.hpp"
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
namespace osgViewer
|
|
|
|
{
|
|
|
|
class Viewer;
|
|
|
|
}
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
namespace SDLUtil
|
2013-01-10 21:21:47 +00:00
|
|
|
{
|
2015-05-13 14:50:47 +00:00
|
|
|
/// \brief A wrapper around SDL's event queue, mostly used for handling input-related events.
|
2013-01-12 15:57:29 +00:00
|
|
|
class InputWrapper
|
2013-01-10 21:21:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-05-13 14:50:47 +00:00
|
|
|
InputWrapper(SDL_Window *window, osg::ref_ptr<osgViewer::Viewer> viewer, 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; }
|
2020-03-14 18:24:36 +00:00
|
|
|
void setSensorEventCallback(SensorListener* listen) { mSensorListener = listen; }
|
2013-01-10 21:21:47 +00:00
|
|
|
void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; }
|
|
|
|
void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; }
|
2014-12-09 03:57:32 +00:00
|
|
|
void setControllerEventCallback(ControllerListener* listen) { mConListener = listen; }
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2013-08-27 13:48:13 +00:00
|
|
|
void capture(bool windowEventsOnly);
|
2017-03-05 12:58:45 +00:00
|
|
|
bool isModifierHeld(int mod);
|
2015-09-16 18:45:37 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
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-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);
|
|
|
|
|
2015-05-13 14:50:47 +00:00
|
|
|
SDL_Window* mSDLWindow;
|
|
|
|
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
|
|
|
|
|
|
|
MouseListener* mMouseListener;
|
2020-03-14 18:24:36 +00:00
|
|
|
SensorListener* mSensorListener;
|
2015-05-13 14:50:47 +00:00
|
|
|
KeyListener* mKeyboardListener;
|
|
|
|
WindowListener* mWindowListener;
|
|
|
|
ControllerListener* mConListener;
|
2013-01-10 21:21:47 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2015-01-24 16:28:05 +00:00
|
|
|
bool mFirstMouseMove;
|
|
|
|
|
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
|
|
|
};
|
2013-01-11 12:27:59 +00:00
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|