From 652722e760fab2959c74e2fa65452f334c8b8478 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 7 Nov 2019 11:02:00 +0100 Subject: 3DS: Rework mouse cursor movement - Fix clipping the cursor position - Ensure the mouse has the same vertical and horizontal speed --- backends/platform/3ds/osystem-graphics.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'backends/platform/3ds/osystem-graphics.cpp') diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp index 8fb92f4d48..c3864c143f 100644 --- a/backends/platform/3ds/osystem-graphics.cpp +++ b/backends/platform/3ds/osystem-graphics.cpp @@ -233,6 +233,16 @@ OSystem::TransactionError OSystem_3DS::endGFXTransaction() { return OSystem::kTransactionSuccess; } +float OSystem_3DS::getScaleRatio() const { + if (_overlayVisible) { + return 1.0; + } else if (config.screen == kScreenTop) { + return _gameTopTexture.getScaleX(); + } else { + return _gameBottomTexture.getScaleX(); + } +} + void OSystem_3DS::setPalette(const byte *colors, uint start, uint num) { assert(start + num <= 256); memcpy(_palette + 3 * start, colors, 3 * num); @@ -578,18 +588,17 @@ void OSystem_3DS::warpMouse(int x, int y) { _cursorY = y; // TODO: adjust for _cursorScalable ? - int offsetx = 0; - int offsety = 0; x -= _cursorHotspotX; y -= _cursorHotspotY; + + int offsetx = 0; + int offsety = 0; if (!_overlayVisible) { - offsetx += config.screen == kScreenTop ? _gameTopX : _gameBottomX; - offsety += config.screen == kScreenTop ? _gameTopY : _gameBottomY; + offsetx = config.screen == kScreenTop ? _gameTopTexture.getPosX() : _gameBottomTexture.getPosX(); + offsety = config.screen == kScreenTop ? _gameTopTexture.getPosY() : _gameBottomTexture.getPosY(); } - float scalex = config.screen == kScreenTop ? (float)_gameTopTexture.actualWidth / _gameWidth : 1.f; - float scaley = config.screen == kScreenTop ? (float)_gameTopTexture.actualHeight / _gameHeight : 1.f; - _cursorTexture.setPosition(scalex * x + offsetx, - scaley * y + offsety); + + _cursorTexture.setPosition(x + offsetx, y + offsety); } void OSystem_3DS::setCursorDelta(float deltaX, float deltaY) { -- cgit v1.2.3