aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp62
-rw-r--r--backends/graphics/opengl/opengl-graphics.h9
2 files changed, 38 insertions, 33 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index cee80f9dc0..a1b2e00f51 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1165,40 +1165,33 @@ uint OpenGLGraphicsManager::getAspectRatio() {
return _videoMode.screenWidth * 10000 / _videoMode.screenHeight;
}
-void OpenGLGraphicsManager::adjustMouseEvent(const Common::Event &event) {
- if (!event.synthetic) {
- Common::Event newEvent(event);
- newEvent.synthetic = true;
-
- if (_videoMode.mode == OpenGL::GFX_NORMAL) {
- if (_videoMode.hardwareWidth != _videoMode.overlayWidth)
- newEvent.mouse.x = newEvent.mouse.x * _videoMode.overlayWidth / _videoMode.hardwareWidth;
- if (_videoMode.hardwareHeight != _videoMode.overlayHeight)
- newEvent.mouse.y = newEvent.mouse.y * _videoMode.overlayHeight / _videoMode.hardwareHeight;
-
- if (!_overlayVisible) {
- newEvent.mouse.x /= _videoMode.scaleFactor;
- newEvent.mouse.y /= _videoMode.scaleFactor;
- }
+void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) {
+ if (_videoMode.mode == OpenGL::GFX_NORMAL) {
+ if (_videoMode.hardwareWidth != _videoMode.overlayWidth)
+ x = x * _videoMode.overlayWidth / _videoMode.hardwareWidth;
+ if (_videoMode.hardwareHeight != _videoMode.overlayHeight)
+ y = y * _videoMode.overlayHeight / _videoMode.hardwareHeight;
+
+ if (!_overlayVisible) {
+ x /= _videoMode.scaleFactor;
+ y /= _videoMode.scaleFactor;
+ }
+ } else {
+ x -= _displayX;
+ y -= _displayY;
+
+ if (_overlayVisible) {
+ if (_displayWidth != _videoMode.overlayWidth)
+ x = x * _videoMode.overlayWidth / _displayWidth;
+ if (_displayHeight != _videoMode.overlayHeight)
+ y = y * _videoMode.overlayHeight / _displayHeight;
} else {
- newEvent.mouse.x -= _displayX;
- newEvent.mouse.y -= _displayY;
-
- if (_overlayVisible) {
- if (_displayWidth != _videoMode.overlayWidth)
- newEvent.mouse.x = newEvent.mouse.x * _videoMode.overlayWidth / _displayWidth;
- if (_displayHeight != _videoMode.overlayHeight)
- newEvent.mouse.y = newEvent.mouse.y * _videoMode.overlayHeight / _displayHeight;
- } else {
- if (_displayWidth != _videoMode.screenWidth)
- newEvent.mouse.x = newEvent.mouse.x * _videoMode.screenWidth / _displayWidth;
- if (_displayHeight != _videoMode.screenHeight)
- newEvent.mouse.y = newEvent.mouse.y * _videoMode.screenHeight / _displayHeight;
- }
+ if (_displayWidth != _videoMode.screenWidth)
+ x = x * _videoMode.screenWidth / _displayWidth;
+ if (_displayHeight != _videoMode.screenHeight)
+ y = y * _videoMode.screenHeight / _displayHeight;
}
-
- g_system->getEventManager()->pushEvent(newEvent);
}
}
@@ -1215,7 +1208,12 @@ bool OpenGLGraphicsManager::notifyEvent(const Common::Event &event) {
case Common::EVENT_LBUTTONUP:
case Common::EVENT_RBUTTONUP:
case Common::EVENT_MBUTTONUP:
- adjustMouseEvent(event);
+ if (!event.synthetic) {
+ Common::Event newEvent(event);
+ newEvent.synthetic = true;
+ adjustMousePosition(newEvent.mouse.x, newEvent.mouse.y);
+ g_system->getEventManager()->pushEvent(newEvent);
+ }
return !event.synthetic;
default:
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 30b19d5d70..b4084e8e41 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -272,7 +272,14 @@ protected:
virtual void refreshCursor();
virtual void refreshCursorScale();
- virtual void adjustMouseEvent(const Common::Event &event);
+ /**
+ * Adjusts hardware screen coordinates to either overlay or game screen
+ * coordinates depending on whether the overlay is visible or not.
+ *
+ * @param x X coordinate of the mouse position.
+ * @param y Y coordinate of the mouse position.
+ */
+ virtual void adjustMousePosition(int16 &x, int16 &y);
virtual void setMousePos(int x, int y);
//