1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-08 09:37:53 +00:00
OpenMW/extern/oics/OISCompat.h
Jordan Milne 02ccb75894 Wrap the mouse to the window (except in debug mode)
Grab the mouse when not in the main menu (except in debug mode)
Always hide the cursor when it's over the window
Allow warping the mouse around
Handle ^C properly
2013-01-09 06:10:05 -04:00

108 lines
2.4 KiB
C++

#ifndef _OIS_SDL_COMPAT_H
#define _OIS_SDL_COMPAT_H
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_types.h>
//TODO: Remove this. Right now we want to remain as close to OIS as possible
//So we can easily test the SDL backend
////////////
// Events //
////////////
namespace ICS {
/** Extended mouse event struct where we treat the wheel like an axis, like everyone expects */
struct MWSDLMouseMotionEvent : SDL_MouseMotionEvent {
Sint16 zrel;
MWSDLMouseMotionEvent()
{
_init();
}
MWSDLMouseMotionEvent( const SDL_MouseMotionEvent& evt)
{
_init();
x = evt.x;
y = evt.y;
xrel = evt.xrel;
yrel = evt.yrel;
state = evt.state;
}
MWSDLMouseMotionEvent (const SDL_MouseWheelEvent& evt)
{
_init();
zrel = evt.y;
}
void _init()
{
x = 0;
y = 0;
xrel = 0;
yrel = 0;
state = 0;
zrel = 0;
}
};
///////////////
// Listeners //
///////////////
class MWSDLMouseListener
{
public:
virtual ~MWSDLMouseListener() {}
virtual bool mouseMoved( const MWSDLMouseMotionEvent &arg ) = 0;
virtual bool mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0;
virtual bool mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0;
};
class MWSDLKeyListener
{
public:
virtual ~MWSDLKeyListener() {}
virtual bool keyPressed(const SDL_KeyboardEvent &arg) = 0;
virtual bool keyReleased(const SDL_KeyboardEvent &arg) = 0;
};
class MWSDLJoyStickListener
{
public:
virtual ~MWSDLJoyStickListener() {}
/** @remarks Joystick button down event */
virtual bool buttonPressed( const SDL_JoyButtonEvent &evt, int button ) = 0;
/** @remarks Joystick button up event */
virtual bool buttonReleased( const SDL_JoyButtonEvent &evt, int button ) = 0;
/** @remarks Joystick axis moved event */
virtual bool axisMoved( const SDL_JoyAxisEvent &arg, int axis ) = 0;
//-- Not so common control events, so are not required --//
//! Joystick Event, and povID
virtual bool povMoved( const SDL_JoyHatEvent &arg, int index) {return true;}
};
class MWSDLWindowListener
{
public:
virtual ~MWSDLWindowListener() {}
/** @remarks The window's visibility changed */
virtual bool windowVisibilityChange( bool visible ) = 0;
/** @remarks The window got / lost input focus */
virtual bool windowFocusChange( bool have_focus ) = 0;
};
}
#endif