From 005b97194f866adcdaa5269cc0393945283b9c40 Mon Sep 17 00:00:00 2001 From: kdmcser Date: Sun, 24 Nov 2024 14:06:39 +0800 Subject: [PATCH 1/2] fix joystick cursor position in xbrz --- client/eventsSDL/InputSourceGameController.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/eventsSDL/InputSourceGameController.cpp b/client/eventsSDL/InputSourceGameController.cpp index 94e3ac450..9716bdf4a 100644 --- a/client/eventsSDL/InputSourceGameController.cpp +++ b/client/eventsSDL/InputSourceGameController.cpp @@ -18,6 +18,7 @@ #include "../gui/CursorHandler.h" #include "../gui/EventDispatcher.h" #include "../gui/ShortcutHandler.h" +#include "../render/IScreenHandler.h" #include "../../lib/CConfigHandler.h" @@ -198,9 +199,10 @@ void InputSourceGameController::tryToConvertCursor() assert(CCS->curh); if(CCS->curh->getShowType() == Cursor::ShowType::HARDWARE) { + int ScaleFactor = GH.screenHandler().getScalingFactor(); const Point & cursorPosition = GH.getCursorPosition(); CCS->curh->changeCursor(Cursor::ShowType::SOFTWARE); - CCS->curh->cursorMove(cursorPosition.x, cursorPosition.y); + CCS->curh->cursorMove(cursorPosition.x * ScaleFactor, cursorPosition.y * ScaleFactor); GH.input().setCursorPosition(cursorPosition); } } @@ -225,12 +227,13 @@ void InputSourceGameController::doCursorMove(int deltaX, int deltaY) return; const Point & screenSize = GH.screenDimensions(); const Point & cursorPosition = GH.getCursorPosition(); + int ScaleFactor = GH.screenHandler().getScalingFactor(); int newX = std::min(std::max(cursorPosition.x + deltaX, 0), screenSize.x); int newY = std::min(std::max(cursorPosition.y + deltaY, 0), screenSize.y); Point targetPosition{newX, newY}; GH.input().setCursorPosition(targetPosition); if(CCS && CCS->curh) - CCS->curh->cursorMove(GH.getCursorPosition().x, GH.getCursorPosition().y); + CCS->curh->cursorMove(GH.getCursorPosition().x * ScaleFactor, GH.getCursorPosition().y * ScaleFactor); } int InputSourceGameController::getMoveDis(float planDis) From d0e33a2cf880be809812ffeb33215ee95b6c1cdb Mon Sep 17 00:00:00 2001 From: kdmcser Date: Tue, 26 Nov 2024 23:16:36 +0800 Subject: [PATCH 2/2] Update client/eventsSDL/InputSourceGameController.cpp Co-authored-by: Ivan Savenko --- client/eventsSDL/InputSourceGameController.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/eventsSDL/InputSourceGameController.cpp b/client/eventsSDL/InputSourceGameController.cpp index 9716bdf4a..5d4ff29ec 100644 --- a/client/eventsSDL/InputSourceGameController.cpp +++ b/client/eventsSDL/InputSourceGameController.cpp @@ -199,10 +199,10 @@ void InputSourceGameController::tryToConvertCursor() assert(CCS->curh); if(CCS->curh->getShowType() == Cursor::ShowType::HARDWARE) { - int ScaleFactor = GH.screenHandler().getScalingFactor(); + int scalingFactor = GH.screenHandler().getScalingFactor(); const Point & cursorPosition = GH.getCursorPosition(); CCS->curh->changeCursor(Cursor::ShowType::SOFTWARE); - CCS->curh->cursorMove(cursorPosition.x * ScaleFactor, cursorPosition.y * ScaleFactor); + CCS->curh->cursorMove(cursorPosition.x * scalingFactor, cursorPosition.y * scalingFactor); GH.input().setCursorPosition(cursorPosition); } } @@ -227,13 +227,13 @@ void InputSourceGameController::doCursorMove(int deltaX, int deltaY) return; const Point & screenSize = GH.screenDimensions(); const Point & cursorPosition = GH.getCursorPosition(); - int ScaleFactor = GH.screenHandler().getScalingFactor(); + int scalingFactor = GH.screenHandler().getScalingFactor(); int newX = std::min(std::max(cursorPosition.x + deltaX, 0), screenSize.x); int newY = std::min(std::max(cursorPosition.y + deltaY, 0), screenSize.y); Point targetPosition{newX, newY}; GH.input().setCursorPosition(targetPosition); if(CCS && CCS->curh) - CCS->curh->cursorMove(GH.getCursorPosition().x * ScaleFactor, GH.getCursorPosition().y * ScaleFactor); + CCS->curh->cursorMove(GH.getCursorPosition().x * scalingFactor, GH.getCursorPosition().y * scalingFactor); } int InputSourceGameController::getMoveDis(float planDis)