1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +02:00

change hardware cursor to software cursor when joystick available

This commit is contained in:
kdmcser
2024-04-21 11:40:24 +08:00
parent 876bae0b73
commit 60c4ddb515
11 changed files with 80 additions and 2 deletions

View File

@ -200,13 +200,19 @@ void InputSourceGameController::doCursorMove(int deltaX, int deltaY)
if(deltaX == 0 && deltaY == 0)
return;
const Point & screenSize = GH.screenDimensions();
const Point &cursorPosition = GH.getCursorPosition();
// if joystick is connected when intro video plays, using hardware position will move cursor to the right position.
bool isHardwareCursor = CCS && CCS->curh && CCS->curh->getShowType() == Cursor::ShowType::HARDWARE;
const Point & cursorPosition = isHardwareCursor ? CCS->curh->getCursorPosition() : GH.getCursorPosition();
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)
if(CCS && CCS->curh) {
if(CCS->curh->getShowType() == Cursor::ShowType::HARDWARE)
CCS->curh->ChangeCursor(Cursor::ShowType::SOFTWARE);
CCS->curh->cursorMove(GH.getCursorPosition().x, GH.getCursorPosition().y);
}
}
int InputSourceGameController::getMoveDis(float planDis)