mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Move cursor update to the MouseManager
This commit is contained in:
parent
b3b8480d49
commit
b00d72b9e4
@ -30,8 +30,7 @@ namespace MWInput
|
||||
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
|
||||
const std::string& userFile, bool userFileExists, const std::string& userControllerBindingsFile,
|
||||
const std::string& controllerBindingsFile, bool grab)
|
||||
: mGrabCursor(Settings::Manager::getBool("grab cursor", "Input"))
|
||||
, mControlsDisabled(false)
|
||||
: mControlsDisabled(false)
|
||||
{
|
||||
mInputWrapper = new SDLUtil::InputWrapper(window, viewer, grab);
|
||||
mInputWrapper->setWindowEventCallback(MWBase::Environment::get().getWindowManager());
|
||||
@ -81,29 +80,6 @@ namespace MWInput
|
||||
mActionManager->setAttemptJump(jumping);
|
||||
}
|
||||
|
||||
void InputManager::updateCursorMode()
|
||||
{
|
||||
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
||||
&& !MWBase::Environment::get().getWindowManager()->isConsoleMode();
|
||||
|
||||
bool wasRelative = mInputWrapper->getMouseRelative();
|
||||
bool isRelative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
|
||||
// don't keep the pointer away from the window edge in gui mode
|
||||
// stop using raw mouse motions and switch to system cursor movements
|
||||
mInputWrapper->setMouseRelative(isRelative);
|
||||
|
||||
//we let the mouse escape in the main menu
|
||||
mInputWrapper->setGrabPointer(grab && (mGrabCursor || isRelative));
|
||||
|
||||
//we switched to non-relative mode, move our cursor to where the in-game
|
||||
//cursor is
|
||||
if (!isRelative && wasRelative != isRelative)
|
||||
{
|
||||
mMouseManager->warpMouse();
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::update(float dt, bool disableControls, bool disableEvents)
|
||||
{
|
||||
mControlsDisabled = disableControls;
|
||||
@ -113,13 +89,13 @@ namespace MWInput
|
||||
|
||||
if (disableControls)
|
||||
{
|
||||
updateCursorMode();
|
||||
mMouseManager->updateCursorMode();
|
||||
return;
|
||||
}
|
||||
|
||||
mBindingsManager->update(dt);
|
||||
|
||||
updateCursorMode();
|
||||
mMouseManager->updateCursorMode();
|
||||
|
||||
bool controllerMove = mControllerManager->update(dt);
|
||||
mMouseManager->update(dt);
|
||||
@ -153,12 +129,6 @@ namespace MWInput
|
||||
|
||||
void InputManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||
{
|
||||
for (const auto& setting : changed)
|
||||
{
|
||||
if (setting.first == "Input" && setting.second == "grab cursor")
|
||||
mGrabCursor = Settings::Manager::getBool("grab cursor", "Input");
|
||||
}
|
||||
|
||||
mMouseManager->processChangedSettings(changed);
|
||||
mSensorManager->processChangedSettings(changed);
|
||||
}
|
||||
|
@ -101,8 +101,6 @@ namespace MWInput
|
||||
|
||||
void handleGuiArrowKey(int action);
|
||||
|
||||
void updateCursorMode();
|
||||
|
||||
void quickKey(int index);
|
||||
void showQuickKeysMenu();
|
||||
|
||||
@ -111,7 +109,6 @@ namespace MWInput
|
||||
|
||||
SDLUtil::InputWrapper* mInputWrapper;
|
||||
|
||||
bool mGrabCursor;
|
||||
bool mControlsDisabled;
|
||||
|
||||
ControlSwitch* mControlSwitch;
|
||||
|
@ -24,8 +24,9 @@ namespace MWInput
|
||||
MouseManager::MouseManager(BindingsManager* bindingsManager, SDLUtil::InputWrapper* inputWrapper, SDL_Window* window)
|
||||
: mInvertX(Settings::Manager::getBool("invert x axis", "Input"))
|
||||
, mInvertY(Settings::Manager::getBool("invert y axis", "Input"))
|
||||
, mCameraSensitivity (Settings::Manager::getFloat("camera sensitivity", "Input"))
|
||||
, mCameraYMultiplier (Settings::Manager::getFloat("camera y multiplier", "Input"))
|
||||
, mGrabCursor(Settings::Manager::getBool("grab cursor", "Input"))
|
||||
, mCameraSensitivity(Settings::Manager::getFloat("camera sensitivity", "Input"))
|
||||
, mCameraYMultiplier(Settings::Manager::getFloat("camera y multiplier", "Input"))
|
||||
, mBindingsManager(bindingsManager)
|
||||
, mInputWrapper(inputWrapper)
|
||||
, mInvUiScalingFactor(1.f)
|
||||
@ -58,6 +59,9 @@ namespace MWInput
|
||||
|
||||
if (setting.first == "Input" && setting.second == "camera sensitivity")
|
||||
mCameraSensitivity = Settings::Manager::getFloat("camera sensitivity", "Input");
|
||||
|
||||
if (setting.first == "Input" && setting.second == "grab cursor")
|
||||
mGrabCursor = Settings::Manager::getBool("grab cursor", "Input");
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,6 +173,29 @@ namespace MWInput
|
||||
mBindingsManager->mousePressed(arg, id);
|
||||
}
|
||||
|
||||
void MouseManager::updateCursorMode()
|
||||
{
|
||||
bool grab = !MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)
|
||||
&& !MWBase::Environment::get().getWindowManager()->isConsoleMode();
|
||||
|
||||
bool wasRelative = mInputWrapper->getMouseRelative();
|
||||
bool isRelative = !MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
|
||||
// don't keep the pointer away from the window edge in gui mode
|
||||
// stop using raw mouse motions and switch to system cursor movements
|
||||
mInputWrapper->setMouseRelative(isRelative);
|
||||
|
||||
//we let the mouse escape in the main menu
|
||||
mInputWrapper->setGrabPointer(grab && (mGrabCursor || isRelative));
|
||||
|
||||
//we switched to non-relative mode, move our cursor to where the in-game
|
||||
//cursor is
|
||||
if (!isRelative && wasRelative != isRelative)
|
||||
{
|
||||
warpMouse();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseManager::update(float dt)
|
||||
{
|
||||
if (!mMouseLookEnabled)
|
||||
|
@ -20,6 +20,7 @@ namespace MWInput
|
||||
|
||||
virtual ~MouseManager() = default;
|
||||
|
||||
void updateCursorMode();
|
||||
void update(float dt);
|
||||
|
||||
virtual void mouseMoved(const SDLUtil::MouseMotionEvent &arg);
|
||||
@ -40,6 +41,7 @@ namespace MWInput
|
||||
private:
|
||||
bool mInvertX;
|
||||
bool mInvertY;
|
||||
bool mGrabCursor;
|
||||
float mCameraSensitivity;
|
||||
float mCameraYMultiplier;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user