Unify cursor enabling

pull/578/head
Andrei Kortunov 5 years ago
parent b33c4c920c
commit 3328775eff

@ -48,7 +48,6 @@ namespace MWInput
const std::string& userFile, bool userFileExists, const std::string& userControllerBindingsFile,
const std::string& controllerBindingsFile, bool grab)
: mGrabCursor(Settings::Manager::getBool("grab cursor", "Input"))
, mGuiCursorEnabled(true)
{
mInputWrapper = new SDLUtil::InputWrapper(window, viewer, grab);
mInputWrapper->setWindowEventCallback(MWBase::Environment::get().getWindowManager());
@ -144,7 +143,7 @@ namespace MWInput
bool controllerMove = mControllerManager->update(dt, disableControls);
mMouseManager->update(dt, disableControls);
mSensorManager->update(dt, mGuiCursorEnabled);
mSensorManager->update(dt);
mActionManager->update(dt, controllerMove);
}
@ -160,10 +159,10 @@ namespace MWInput
void InputManager::changeInputMode(bool guiMode)
{
mGuiCursorEnabled = guiMode;
mControllerManager->setGuiCursorEnabled(mGuiCursorEnabled);
mMouseManager->setGuiCursorEnabled(mGuiCursorEnabled);
mMouseManager->setMouseLookEnabled(!mGuiCursorEnabled);
mControllerManager->setGuiCursorEnabled(guiMode);
mMouseManager->setGuiCursorEnabled(guiMode);
mSensorManager->setGuiCursorEnabled(guiMode);
mMouseManager->setMouseLookEnabled(!guiMode);
if (guiMode)
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (!mControllerManager->joystickLastUsed() || mControllerManager->gamepadGuiCursorEnabled()));

@ -111,8 +111,6 @@ namespace MWInput
bool mGrabCursor;
bool mGuiCursorEnabled;
ControlSwitch* mControlSwitch;
ActionManager* mActionManager;

@ -22,6 +22,7 @@ namespace MWInput
, mGyroVAxis(GyroscopeAxis::Y)
, mGyroInputThreshold(Settings::Manager::getFloat("gyro input threshold", "Input"))
, mGyroscope(nullptr)
, mGuiCursorEnabled(true)
{
init();
}
@ -235,7 +236,7 @@ namespace MWInput
}
}
void SensorManager::update(float dt, bool isCursorEnabled)
void SensorManager::update(float dt)
{
if (mGyroXSpeed == 0.f && mGyroYSpeed == 0.f)
return;
@ -252,7 +253,7 @@ namespace MWInput
mGyroUpdateTimer += dt;
if (!isCursorEnabled)
if (!mGuiCursorEnabled)
{
float rot[3];
rot[0] = mGyroYSpeed * dt * mGyroVSensitivity * 4 * (mInvertY ? -1 : 1);

@ -29,12 +29,14 @@ namespace MWInput
void clear();
void update(float dt, bool isCursorEnabled);
void update(float dt);
virtual void sensorUpdated(const SDL_SensorEvent &arg);
virtual void displayOrientationChanged();
void processChangedSettings(const Settings::CategorySettingVector& changed);
void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; }
private:
enum GyroscopeAxis
{
@ -66,6 +68,8 @@ namespace MWInput
float mGyroInputThreshold;
SDL_Sensor* mGyroscope;
bool mGuiCursorEnabled;
};
}
#endif

Loading…
Cancel
Save