An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.
C++
Options with a controller: the gold frame alone is the pointer, and a warp's echo isn't the mouse
Alan Saundersce92a79fd089
diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cppindex 2f2f8c2..c8d87d0 100644--- a/apps/openmw/mwgui/settingswindow.cpp+++ b/apps/openmw/mwgui/settingswindow.cpp@@ -1324,9 +1324,11 @@ namespace MWGuiconst MyGUI::IntCoord coord = target->getAbsoluteCoord();MyGUI::InputManager::getInstance().injectMouseMove(coord.left + coord.width / 2, coord.top + static_cast<int>(coord.height * yFraction), 0);+ // The frame (frameControl) is the pointer: the mouse cursor stays hidden, as in the other menus made for the+ // controller, until the mouse itself moves. The setting's description still shows, at the frame.MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();- winMgr->setCursorVisible(true);- winMgr->setCursorActive(true);+ winMgr->setCursorVisible(false);+ winMgr->setControllerTooltipVisible(Settings::gui().mControllerTooltips);frameControl(control);}diff --git a/apps/openmw/mwinput/mousemanager.cpp b/apps/openmw/mwinput/mousemanager.cppindex 9c0399a..1150380 100644--- a/apps/openmw/mwinput/mousemanager.cpp+++ b/apps/openmw/mwinput/mousemanager.cpp@@ -23,6 +23,13 @@namespace MWInput{+ namespace+ {+ // Isowind: a mouse move landing this near (GUI pixels) to where the game last warped the pointer is the+ // warp coming back from the window system, not the player's hand+ constexpr float sWarpTolerance = 2.f;+ }+MouseManager::MouseManager(BindingsManager* bindingsManager, SDLUtil::InputWrapper* inputWrapper, SDL_Window* window): mBindingsManager(bindingsManager)@@ -50,6 +57,28 @@ namespace MWInputmBindingsManager->mouseMoved(arg);MWBase::InputManager* input = MWBase::Environment::get().getInputManager();+ MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();+ const float uiScale = winMgr->getScalingFactor();++ // Isowind: a move the game made itself, warping the pointer onto a control for the controller (warpMouse),+ // comes back from the window system as a mouse move on some of them (Windows, with the display scaled or a+ // stream in between, not always to the pixel; the SDL wrapper only eats an exact echo). It says nothing about+ // what the player is using: it only tells the GUI where the pointer is, and neither brings the pointer up nor+ // makes the mouse the device in use, which would have the pointer show over the menus made for the controller+ // at each step of the D-pad.+ if (mGuiCursorEnabled && mLastWarpX >= 0 && mLastWarpY >= 0+ && std::abs(static_cast<float>(arg.x) / uiScale - mLastWarpX) <= sWarpTolerance+ && std::abs(static_cast<float>(arg.y) / uiScale - mLastWarpY) <= sWarpTolerance)+ {+ mLastWarpX = -1;+ mLastWarpY = -1;+ mGuiCursorX = static_cast<float>(arg.x) / uiScale;+ mGuiCursorY = static_cast<float>(arg.y) / uiScale;+ MyGUI::InputManager::getInstance().injectMouseMove(+ static_cast<int>(mGuiCursorX), static_cast<int>(mGuiCursorY), mMouseWheel);+ return;+ }+input->setJoystickLastUsed(false);input->resetIdleTime();@@ -59,8 +88,6 @@ 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- MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();- float uiScale = winMgr->getScalingFactor();mGuiCursorX = static_cast<float>(arg.x) / uiScale;mGuiCursorY = static_cast<float>(arg.y) / uiScale;@@ -75,19 +102,15 @@ namespace MWInputwinMgr->setCursorActive(true);- // Check if this movement is from our recent mouse warp- bool isFromWarp = (mLastWarpX >= 0 && mLastWarpY >= 0 && std::abs(mGuiCursorX - mLastWarpX) < 0.5f- && std::abs(mGuiCursorY - mLastWarpY) < 0.5f);-if (Settings::gui().mControllerMenus && !winMgr->getCursorVisible()- && (std::abs(arg.xrel) > 1 || std::abs(arg.yrel) > 1) && !isFromWarp)+ && (std::abs(arg.xrel) > 1 || std::abs(arg.yrel) > 1)){// Unhide the cursor if it was hidden to show a controller tooltip.winMgr->setControllerTooltipVisible(false);winMgr->setCursorVisible(true);}- // Clear warp tracking after processing+ // A move of the mouse itself: a warp still to come back is no longer told apartmLastWarpX = -1;mLastWarpY = -1;}@@ -286,6 +309,10 @@ namespace MWInput// Isowind: the scale the window reports (the setting times the drawable to window ratio), the same one// mouseMoved divides by, or the warp lands off target where the compositor scalesfloat guiUiScale = MWBase::Environment::get().getWindowManager()->getScalingFactor();+ // Where it went, so the move it may come back as is known for one (mouseMoved); the stick moving the pointer+ // warps every frame+ mLastWarpX = mGuiCursorX;+ mLastWarpY = mGuiCursorY;mInputWrapper->warpMouse(static_cast<int>(mGuiCursorX * guiUiScale), static_cast<int>(mGuiCursorY * guiUiScale));}@@ -298,10 +325,7 @@ namespace MWInput{mGuiCursorX = widgetX;mGuiCursorY = widgetY;- // Remember where we warped to so we can ignore movement from this warp- mLastWarpX = widgetX;- mLastWarpY = widgetY;- warpMouse();+ warpMouse(); // (remembers where to, so the move this may come back as is ignored)}}diff --git a/isowind/README.txt b/isowind/README.txtindex 46bfa61..4e3f97c 100644--- a/isowind/README.txt+++ b/isowind/README.txt@@ -145,8 +145,8 @@ screen's pages (Map, Inventory, Magic, Stats; one at a time, as with the mouse awindows are open side by side (a chest, a shop), between them, the one in use lit, while the triggers switchthe tabs within a window. The right stick pressed in shows an item's info, and in the inventory and magicwindows Y puts the item or spell on a quick key. In Options the bumpers switch tabs,-the D-pad steps a pointer through the settings (up / down) and adjusts the one it is on (left / right), and A-works it, on the Scripts tab's pages too. The legend along the bottom of each menu says what the buttons do+the D-pad steps a gold frame through the settings (up / down) and adjusts the one it is on (left / right), and A+works it, on the Scripts tab's pages too; the mouse pointer stays away until the mouse moves. The legend along the bottom of each menu says what the buttons dothere. To type something (your name, a server's password, a save's, potion's, spell's or class's name, a mapnote), move onto the box with the D-pad - up from the top of the list or the buttons under it - and press X:a keyboard comes up on the screen (never by itself). Start or Back puts it away when you are done; in a box