diff options
Diffstat (limited to 'backends/graphics/surfacesdl')
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 56 | ||||
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.h | 11 |
2 files changed, 29 insertions, 38 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 2d41ecead4..81c439e7e2 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -122,7 +122,7 @@ static AspectRatio getDesiredAspectRatio() { SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource) : - _sdlEventSource(sdlEventSource), + SdlGraphicsManager(sdlEventSource), #ifdef USE_OSD _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), #endif @@ -846,7 +846,7 @@ bool SurfaceSdlGraphicsManager::loadGFXMode() { SDL_SetColorKey(_osdSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kOSDColorKey); #endif - _sdlEventSource->resetKeyboadEmulation( + _eventSource->resetKeyboadEmulation( _videoMode.screenWidth * _videoMode.scaleFactor - 1, effectiveScreenHeight() - 1); @@ -2235,20 +2235,6 @@ bool SurfaceSdlGraphicsManager::isScalerHotkey(const Common::Event &event) { return false; } -void SurfaceSdlGraphicsManager::adjustMouseEvent(const Common::Event &event) { - if (!event.synthetic) { - Common::Event newEvent(event); - newEvent.synthetic = true; - if (!_overlayVisible) { - newEvent.mouse.x /= _videoMode.scaleFactor; - newEvent.mouse.y /= _videoMode.scaleFactor; - if (_videoMode.aspectRatioCorrection) - newEvent.mouse.y = aspect2Real(newEvent.mouse.y); - } - g_system->getEventManager()->pushEvent(newEvent); - } -} - void SurfaceSdlGraphicsManager::toggleFullScreen() { beginGFXTransaction(); setFullscreenMode(!_videoMode.fullscreen); @@ -2297,26 +2283,10 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) { if (handleScalerHotkeys(event.kbd.keycode)) return true; } + case Common::EVENT_KEYUP: return isScalerHotkey(event); - case Common::EVENT_MOUSEMOVE: - if (event.synthetic) - setMousePos(event.mouse.x, event.mouse.y); - case Common::EVENT_LBUTTONDOWN: - case Common::EVENT_RBUTTONDOWN: - case Common::EVENT_WHEELUP: - case Common::EVENT_WHEELDOWN: - case Common::EVENT_MBUTTONDOWN: - case Common::EVENT_LBUTTONUP: - case Common::EVENT_RBUTTONUP: - case Common::EVENT_MBUTTONUP: - adjustMouseEvent(event); - return !event.synthetic; - - // HACK: Handle special SDL event - case OSystem_SDL::kSdlEventExpose: - _forceFull = true; - return false; + default: break; } @@ -2324,4 +2294,22 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) { return false; } +void SurfaceSdlGraphicsManager::notifyVideoExpose() { + _forceFull = true; +} + +void SurfaceSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { + if (!_overlayVisible) { + point.x /= _videoMode.scaleFactor; + point.y /= _videoMode.scaleFactor; + if (_videoMode.aspectRatioCorrection) + point.y = aspect2Real(point.y); + } +} + +void SurfaceSdlGraphicsManager::notifyMousePos(Common::Point mouse) { + transformMouseCoordinates(mouse); + setMousePos(mouse.x, mouse.y); +} + #endif diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index cd8710d443..f71096d43e 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -24,6 +24,7 @@ #define BACKENDS_GRAPHICS_SURFACESDL_GRAPHICS_H #include "backends/graphics/graphics.h" +#include "backends/graphics/sdl/sdl-graphics.h" #include "graphics/pixelformat.h" #include "graphics/scaler.h" #include "common/events.h" @@ -74,7 +75,7 @@ public: /** * SDL graphics manager */ -class SurfaceSdlGraphicsManager : public GraphicsManager, public Common::EventObserver { +class SurfaceSdlGraphicsManager : public GraphicsManager, public SdlGraphicsManager, public Common::EventObserver { public: SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSource); virtual ~SurfaceSdlGraphicsManager(); @@ -140,9 +141,12 @@ public: // Override from Common::EventObserver bool notifyEvent(const Common::Event &event); -protected: - SdlEventSource *_sdlEventSource; + // SdlGraphicsManager interface + virtual void notifyVideoExpose(); + virtual void transformMouseCoordinates(Common::Point &point); + virtual void notifyMousePos(Common::Point mouse); +protected: #ifdef USE_OSD /** Surface containing the OSD message */ SDL_Surface *_osdSurface; @@ -329,7 +333,6 @@ protected: virtual bool handleScalerHotkeys(Common::KeyCode key); virtual bool isScalerHotkey(const Common::Event &event); - virtual void adjustMouseEvent(const Common::Event &event); virtual void setMousePos(int x, int y); virtual void toggleFullScreen(); virtual bool saveScreenshot(const char *filename); |