[Scummvm-git-logs] scummvm master -> 26cd7d44e2c181c96d83125012c0d829fc596db4
aquadran
aquadran at gmail.com
Tue Oct 13 19:31:15 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
26cd7d44e2 SDL: Implement lockMouse() in the 2D graphics managers (#2517)
Commit: 26cd7d44e2c181c96d83125012c0d829fc596db4
https://github.com/scummvm/scummvm/commit/26cd7d44e2c181c96d83125012c0d829fc596db4
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-10-13T21:31:10+02:00
Commit Message:
SDL: Implement lockMouse() in the 2D graphics managers (#2517)
Changed paths:
backends/graphics/sdl/sdl-graphics.cpp
backends/graphics/sdl/sdl-graphics.h
backends/graphics3d/sdl/sdl-graphics3d.cpp
backends/platform/sdl/sdl-window.cpp
backends/platform/sdl/sdl-window.h
diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp
index 38cf0dea7e..cd22a61234 100644
--- a/backends/graphics/sdl/sdl-graphics.cpp
+++ b/backends/graphics/sdl/sdl-graphics.cpp
@@ -191,6 +191,10 @@ bool SdlGraphicsManager::showMouse(bool visible) {
return WindowedGraphicsManager::showMouse(visible);
}
+bool SdlGraphicsManager::lockMouse(bool lock) {
+ return _window->lockMouse(lock);
+}
+
bool SdlGraphicsManager::notifyMousePosition(Common::Point &mouse) {
mouse.x = CLIP<int16>(mouse.x, 0, _windowWidth - 1);
mouse.y = CLIP<int16>(mouse.y, 0, _windowHeight - 1);
diff --git a/backends/graphics/sdl/sdl-graphics.h b/backends/graphics/sdl/sdl-graphics.h
index f32c5fc2e1..3d2baefc7f 100644
--- a/backends/graphics/sdl/sdl-graphics.h
+++ b/backends/graphics/sdl/sdl-graphics.h
@@ -95,6 +95,7 @@ public:
virtual bool notifyMousePosition(Common::Point &mouse);
virtual bool showMouse(bool visible) override;
+ virtual bool lockMouse(bool lock) override;
virtual bool saveScreenshot(const Common::String &filename) const { return false; }
void saveScreenshot() override;
diff --git a/backends/graphics3d/sdl/sdl-graphics3d.cpp b/backends/graphics3d/sdl/sdl-graphics3d.cpp
index c66340b794..3b6455c7b0 100644
--- a/backends/graphics3d/sdl/sdl-graphics3d.cpp
+++ b/backends/graphics3d/sdl/sdl-graphics3d.cpp
@@ -192,21 +192,9 @@ bool SdlGraphics3dManager::showMouse(bool visible) {
}
bool SdlGraphics3dManager::lockMouse(bool lock) {
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- if (lock)
- SDL_SetRelativeMouseMode(SDL_TRUE);
- else
- SDL_SetRelativeMouseMode(SDL_FALSE);
-#else
- if (lock)
- SDL_WM_GrabInput(SDL_GRAB_ON);
- else
- SDL_WM_GrabInput(SDL_GRAB_OFF);
-#endif
- return true;
+ return _window->lockMouse(lock);
}
-
bool SdlGraphics3dManager::notifyMousePosition(Common::Point &mouse) {
transformMouseCoordinates(mouse);
diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp
index 217734bd44..8e7efb6eaa 100644
--- a/backends/platform/sdl/sdl-window.cpp
+++ b/backends/platform/sdl/sdl-window.cpp
@@ -162,6 +162,21 @@ void SdlWindow::toggleMouseGrab() {
#endif
}
+bool SdlWindow::lockMouse(bool lock) {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ if (lock)
+ SDL_SetRelativeMouseMode(SDL_TRUE);
+ else
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+#else
+ if (lock)
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ else
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+#endif
+ return true;
+}
+
bool SdlWindow::hasMouseFocus() const {
#if SDL_VERSION_ATLEAST(2, 0, 0)
if (_window) {
diff --git a/backends/platform/sdl/sdl-window.h b/backends/platform/sdl/sdl-window.h
index b46ae7015b..598f18ffb8 100644
--- a/backends/platform/sdl/sdl-window.h
+++ b/backends/platform/sdl/sdl-window.h
@@ -51,6 +51,11 @@ public:
*/
void toggleMouseGrab();
+ /**
+ * Lock or unlock the mouse cursor within the window.
+ */
+ bool lockMouse(bool lock);
+
/**
* Check whether the application has mouse focus.
*/
More information about the Scummvm-git-logs
mailing list