2013-01-10 21:21:47 +00:00
|
|
|
#ifndef _SFO_EVENTS_H
|
|
|
|
#define _SFO_EVENTS_H
|
2013-01-08 10:19:05 +00:00
|
|
|
|
2013-01-12 21:52:26 +00:00
|
|
|
#include <SDL.h>
|
2013-01-08 10:19:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
////////////
|
|
|
|
// Events //
|
|
|
|
////////////
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
namespace SFO {
|
2013-01-08 10:19:05 +00:00
|
|
|
|
|
|
|
/** Extended mouse event struct where we treat the wheel like an axis, like everyone expects */
|
2013-01-10 21:21:47 +00:00
|
|
|
struct MouseMotionEvent : SDL_MouseMotionEvent {
|
|
|
|
|
|
|
|
Sint32 zrel;
|
|
|
|
Sint32 z;
|
2013-01-08 10:19:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
// Listeners //
|
|
|
|
///////////////
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
class MouseListener
|
2013-01-08 10:19:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-10 21:21:47 +00:00
|
|
|
virtual ~MouseListener() {}
|
|
|
|
virtual bool mouseMoved( const MouseMotionEvent &arg ) = 0;
|
2013-01-08 10:19:05 +00:00
|
|
|
virtual bool mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0;
|
|
|
|
virtual bool mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id ) = 0;
|
|
|
|
};
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
class KeyListener
|
2013-01-08 10:19:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-10 21:21:47 +00:00
|
|
|
virtual ~KeyListener() {}
|
2013-01-08 10:19:05 +00:00
|
|
|
virtual bool keyPressed(const SDL_KeyboardEvent &arg) = 0;
|
|
|
|
virtual bool keyReleased(const SDL_KeyboardEvent &arg) = 0;
|
|
|
|
};
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
class JoyListener
|
2013-01-08 10:19:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-10 21:21:47 +00:00
|
|
|
virtual ~JoyListener() {}
|
2013-01-08 10:19:05 +00:00
|
|
|
/** @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;}
|
|
|
|
};
|
|
|
|
|
2013-01-10 21:21:47 +00:00
|
|
|
class WindowListener
|
2013-01-09 10:10:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-01-10 21:21:47 +00:00
|
|
|
virtual ~WindowListener() {}
|
2013-01-09 10:10:05 +00:00
|
|
|
|
|
|
|
/** @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;
|
|
|
|
};
|
|
|
|
|
2013-01-08 10:19:05 +00:00
|
|
|
}
|
2013-01-10 21:21:47 +00:00
|
|
|
|
2013-01-08 10:19:05 +00:00
|
|
|
#endif
|