mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
SDL: Implement lockMouse() in the 2D graphics managers (#2517)
This commit is contained in:
parent
59ba9cb715
commit
26cd7d44e2
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user