aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/events/sdl/sdl-events.cpp45
-rw-r--r--backends/events/sdl/sdl-events.h14
-rw-r--r--backends/graphics/sdl/sdl-graphics.cpp2
-rw-r--r--backends/modular-backend.h2
-rw-r--r--backends/platform/sdl/sdl.cpp7
-rw-r--r--backends/platform/sdl/sdl.h4
6 files changed, 32 insertions, 42 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index 20b7b7e957..deea8d35ca 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -48,13 +48,8 @@
#define JOY_BUT_SPACE 4
#define JOY_BUT_F5 5
-SdlEventManager::SdlEventManager(Common::EventSource *boss)
- :
- _scrollLock(false),
- _joystick(0),
- _lastScreenID(0),
- DefaultEventManager(boss) {
-
+SdlEventSource::SdlEventSource()
+ : _scrollLock(false), _joystick(0), _lastScreenID(0), EventSource() {
// Reset mouse state
memset(&_km, 0, sizeof(_km));
@@ -73,12 +68,12 @@ SdlEventManager::SdlEventManager(Common::EventSource *boss)
}
}
-SdlEventManager::~SdlEventManager() {
+SdlEventSource::~SdlEventSource() {
if (_joystick)
SDL_JoystickClose(_joystick);
}
-int SdlEventManager::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+int SdlEventSource::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
if (key >= SDLK_F1 && key <= SDLK_F9) {
return key - SDLK_F1 + Common::ASCII_F1;
} else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
@@ -95,7 +90,7 @@ int SdlEventManager::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
return key;
}
-void SdlEventManager::fillMouseEvent(Common::Event &event, int x, int y) {
+void SdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
event.mouse.x = x;
event.mouse.y = y;
@@ -104,7 +99,7 @@ void SdlEventManager::fillMouseEvent(Common::Event &event, int x, int y) {
_km.y = y;
}
-void SdlEventManager::handleKbdMouse() {
+void SdlEventSource::handleKbdMouse() {
uint32 curTime = g_system->getMillis();
if (curTime >= _km.last_time + _km.delay_time) {
_km.last_time = curTime;
@@ -173,7 +168,7 @@ void SdlEventManager::handleKbdMouse() {
}
}
-void SdlEventManager::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
event.kbd.flags = 0;
@@ -198,7 +193,7 @@ void SdlEventManager::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event)
event.kbd.flags |= Common::KBD_CAPS;
}
-bool SdlEventManager::pollSdlEvent(Common::Event &event) {
+bool SdlEventSource::pollEvent(Common::Event &event) {
handleKbdMouse();
// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
@@ -219,7 +214,7 @@ bool SdlEventManager::pollSdlEvent(Common::Event &event) {
return false;
}
-bool SdlEventManager::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
switch (ev.type) {
case SDL_KEYDOWN:
return handleKeyDown(ev, event);
@@ -260,7 +255,7 @@ bool SdlEventManager::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
}
-bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
SDLModToOSystemKeyFlags(SDL_GetModState(), event);
@@ -312,7 +307,7 @@ bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::handleKeyUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
if (remapKey(ev, event))
return true;
@@ -330,14 +325,14 @@ bool SdlEventManager::handleKeyUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
return true;
}
-bool SdlEventManager::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONDOWN;
else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -360,7 +355,7 @@ bool SdlEventManager::handleMouseButtonDown(SDL_Event &ev, Common::Event &event)
return true;
}
-bool SdlEventManager::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONUP;
else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -376,7 +371,7 @@ bool SdlEventManager::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
@@ -407,7 +402,7 @@ bool SdlEventManager::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
@@ -438,7 +433,7 @@ bool SdlEventManager::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
int axis = ev.jaxis.value;
if ( axis > JOY_DEADZONE) {
axis -= JOY_DEADZONE;
@@ -486,7 +481,7 @@ bool SdlEventManager::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool SdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
#ifdef LINUPY
// On Yopy map the End button to quit
if ((ev.key.keysym.sym == 293)) {
@@ -554,14 +549,14 @@ bool SdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
-void SdlEventManager::toggleMouseGrab() {
+void SdlEventSource::toggleMouseGrab() {
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
SDL_WM_GrabInput(SDL_GRAB_ON);
else
SDL_WM_GrabInput(SDL_GRAB_OFF);
}
-void SdlEventManager::resetKeyboadEmulation(int16 x_max, int16 y_max) {
+void SdlEventSource::resetKeyboadEmulation(int16 x_max, int16 y_max) {
_km.x_max = x_max;
_km.y_max = y_max;
_km.delay_time = 25;
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index 4bc2277fcd..2c00ab0669 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -35,17 +35,17 @@
#endif
/**
- * The SDL event manager class.
+ * The SDL event source.
*/
-class SdlEventManager : public DefaultEventManager {
-public:
- SdlEventManager(Common::EventSource *boss);
- virtual ~SdlEventManager();
+class SdlEventSource : public virtual Common::EventSource {
+public:
+ SdlEventSource();
+ virtual ~SdlEventSource();
/**
- * Gets and proccess SDL events
+ * Gets and processes SDL events.
*/
- virtual bool pollSdlEvent(Common::Event &event);
+ virtual bool pollEvent(Common::Event &event);
/**
* Resets keyboard emulation after a video screen change
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index d4aad34c1e..2c0320f5d0 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -821,7 +821,7 @@ bool SdlGraphicsManager::loadGFXMode() {
SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey);
#endif
- ((SdlEventManager *)g_system->getEventManager())->resetKeyboadEmulation(
+ ((SdlEventSource *)g_system)->resetKeyboadEmulation(
_videoMode.screenWidth * _videoMode.scaleFactor - 1,
effectiveScreenHeight() - 1);
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index b7920d9d71..ed638fe303 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -52,7 +52,7 @@
* And, it should also initialize all the managers variables
* declared in this class, or override their related functions.
*/
-class ModularBackend : public OSystem, public Common::EventSource {
+class ModularBackend : public OSystem, public virtual Common::EventSource {
public:
ModularBackend();
virtual ~ModularBackend();
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 5b38cbb9b4..38bf4d0ba9 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -112,7 +112,7 @@ void OSystem_SDL::initBackend() {
// Creates the backend managers, if they don't exist yet (we check
// for this to allow subclasses to provide their own).
if (_eventManager == 0)
- _eventManager = new SdlEventManager(this);
+ _eventManager = new DefaultEventManager(this);
// We have to initialize the graphics manager before the event manager
// so the virtual keyboard can be initialized, but we have to add the
@@ -289,11 +289,6 @@ void OSystem_SDL::setupIcon() {
free(icon);
}
-bool OSystem_SDL::pollEvent(Common::Event &event) {
- assert(_eventManager);
- return ((SdlEventManager *)_eventManager)->pollSdlEvent(event);
-}
-
uint32 OSystem_SDL::getMillis() {
uint32 millis = SDL_GetTicks();
g_eventRec.processMillis(millis);
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 17d4dc4ed9..9ef2573dad 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -34,11 +34,12 @@
#include "backends/modular-backend.h"
#include "backends/mixer/sdl/sdl-mixer.h"
+#include "backends/events/sdl/sdl-events.h"
/**
* Base OSystem class for all SDL ports.
*/
-class OSystem_SDL : public ModularBackend {
+class OSystem_SDL : public ModularBackend, public SdlEventSource {
public:
OSystem_SDL();
virtual ~OSystem_SDL();
@@ -66,7 +67,6 @@ public:
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
virtual Common::SeekableReadStream *createConfigReadStream();
virtual Common::WriteStream *createConfigWriteStream();
- virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &td) const;