Fixed llack of precision in mouse look mode

This commit is contained in:
ksuprynowicz 2023-09-01 23:43:22 +02:00
parent 51a26522b9
commit c49c947984
3 changed files with 13 additions and 3 deletions

View file

@ -6326,6 +6326,9 @@ void Application::update(float deltaTime) {
if (QCursor::pos() != point) {
_mouseCaptureTarget = point;
_ignoreMouseMove = true;
if (_captureMouse) {
_keyboardMouseDevice->updateMousePositionForCapture(QCursor::pos(), _mouseCaptureTarget);
}
QCursor::setPos(point);
}
}

View file

@ -113,14 +113,18 @@ void KeyboardMouseDevice::eraseMouseClicked() {
_inputDevice->_buttonPressedMap.erase(_inputDevice->makeInput(Qt::RightButton, true).getChannel());
}
void KeyboardMouseDevice::updateMousePositionForCapture(QPoint globalPos, QPointF captureTarget) {
if (!isNaN(captureTarget.x())) {
QPointF change = globalPos - captureTarget;
_accumulatedMove += QPoint(change.x(), change.y());
}
}
void KeyboardMouseDevice::mouseMoveEvent(QMouseEvent* event, bool capture, QPointF captureTarget) {
QPoint currentPos = event->pos();
if (!capture) {
_accumulatedMove += currentPos - _lastCursor;
} else if (!isNaN(captureTarget.x())) {
QPointF change = event->globalPos() - captureTarget;
_accumulatedMove += QPoint(change.x(), change.y());
}
// FIXME - this has the characteristic that it will show large jumps when you move the cursor

View file

@ -93,6 +93,9 @@ public:
void wheelEvent(QWheelEvent* event);
bool isWheelByTouchPad(QWheelEvent* event);
// This gets called from Application::update just before resetting cursor position when mouse capture is enabled
void updateMousePositionForCapture(QPoint globalPos, QPointF captureTarget);
static void enableTouch(bool enableTouch) { _enableTouch = enableTouch; }
static const char* NAME;