From 7eb48ea83bf9d13f2600a87ffbfd6885a4eefcb2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 4 Mar 2017 21:25:07 +0100 Subject: [PATCH] Don't wrap mouse to window bounds when the gamepad axis did not move and fix off-by-one error --- apps/openmw/mwinput/inputmanagerimp.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 6577add5a..b09c45860 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -398,15 +398,20 @@ namespace MWInput // We keep track of our own mouse position, so that moving the mouse while in // game mode does not move the position of the GUI cursor - mGuiCursorX += xAxis * dt * 1500.0f * mInvUiScalingFactor; - mGuiCursorY += yAxis * dt * 1500.0f * mInvUiScalingFactor; - mMouseWheel -= static_cast(zAxis * dt * 1500.0f); + float xmove = xAxis * dt * 1500.0f * mInvUiScalingFactor; + float ymove = yAxis * dt * 1500.0f * mInvUiScalingFactor; + if (xmove != 0|| ymove != 0) + { + mGuiCursorX += xmove; + mGuiCursorY += ymove; + mMouseWheel -= static_cast(zAxis * dt * 1500.0f); - mGuiCursorX = std::max(0.f, std::min(mGuiCursorX, float(viewSize.width))); - mGuiCursorY = std::max(0.f, std::min(mGuiCursorY, float(viewSize.height))); + mGuiCursorX = std::max(0.f, std::min(mGuiCursorX, float(viewSize.width-1))); + mGuiCursorY = std::max(0.f, std::min(mGuiCursorY, float(viewSize.height-1))); - MyGUI::InputManager::getInstance().injectMouseMove(static_cast(mGuiCursorX), static_cast(mGuiCursorY), mMouseWheel); - mInputManager->warpMouse(static_cast(mGuiCursorX/mInvUiScalingFactor), static_cast(mGuiCursorY/mInvUiScalingFactor)); + MyGUI::InputManager::getInstance().injectMouseMove(static_cast(mGuiCursorX), static_cast(mGuiCursorY), mMouseWheel); + mInputManager->warpMouse(static_cast(mGuiCursorX/mInvUiScalingFactor), static_cast(mGuiCursorY/mInvUiScalingFactor)); + } } if (mMouseLookEnabled) {