1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-12 10:03:53 +02:00

Merge pull request #4969 from kdmcser/joystick_fix

fix joystick cursor position in xbrz
This commit is contained in:
Ivan Savenko 2024-11-27 16:41:07 +02:00 committed by GitHub
commit b47d4ce8e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 scalingFactor = 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 * scalingFactor, cursorPosition.y * scalingFactor);
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 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, GH.getCursorPosition().y);
CCS->curh->cursorMove(GH.getCursorPosition().x * scalingFactor, GH.getCursorPosition().y * scalingFactor);
}
int InputSourceGameController::getMoveDis(float planDis)