mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-11 06:40:34 +00:00
Unify cursor enabling
This commit is contained in:
parent
b33c4c920c
commit
3328775eff
@ -48,7 +48,6 @@ namespace MWInput
|
|||||||
const std::string& userFile, bool userFileExists, const std::string& userControllerBindingsFile,
|
const std::string& userFile, bool userFileExists, const std::string& userControllerBindingsFile,
|
||||||
const std::string& controllerBindingsFile, bool grab)
|
const std::string& controllerBindingsFile, bool grab)
|
||||||
: mGrabCursor(Settings::Manager::getBool("grab cursor", "Input"))
|
: mGrabCursor(Settings::Manager::getBool("grab cursor", "Input"))
|
||||||
, mGuiCursorEnabled(true)
|
|
||||||
{
|
{
|
||||||
mInputWrapper = new SDLUtil::InputWrapper(window, viewer, grab);
|
mInputWrapper = new SDLUtil::InputWrapper(window, viewer, grab);
|
||||||
mInputWrapper->setWindowEventCallback(MWBase::Environment::get().getWindowManager());
|
mInputWrapper->setWindowEventCallback(MWBase::Environment::get().getWindowManager());
|
||||||
@ -144,7 +143,7 @@ namespace MWInput
|
|||||||
|
|
||||||
bool controllerMove = mControllerManager->update(dt, disableControls);
|
bool controllerMove = mControllerManager->update(dt, disableControls);
|
||||||
mMouseManager->update(dt, disableControls);
|
mMouseManager->update(dt, disableControls);
|
||||||
mSensorManager->update(dt, mGuiCursorEnabled);
|
mSensorManager->update(dt);
|
||||||
mActionManager->update(dt, controllerMove);
|
mActionManager->update(dt, controllerMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,10 +159,10 @@ namespace MWInput
|
|||||||
|
|
||||||
void InputManager::changeInputMode(bool guiMode)
|
void InputManager::changeInputMode(bool guiMode)
|
||||||
{
|
{
|
||||||
mGuiCursorEnabled = guiMode;
|
mControllerManager->setGuiCursorEnabled(guiMode);
|
||||||
mControllerManager->setGuiCursorEnabled(mGuiCursorEnabled);
|
mMouseManager->setGuiCursorEnabled(guiMode);
|
||||||
mMouseManager->setGuiCursorEnabled(mGuiCursorEnabled);
|
mSensorManager->setGuiCursorEnabled(guiMode);
|
||||||
mMouseManager->setMouseLookEnabled(!mGuiCursorEnabled);
|
mMouseManager->setMouseLookEnabled(!guiMode);
|
||||||
if (guiMode)
|
if (guiMode)
|
||||||
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
MWBase::Environment::get().getWindowManager()->showCrosshair(false);
|
||||||
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (!mControllerManager->joystickLastUsed() || mControllerManager->gamepadGuiCursorEnabled()));
|
MWBase::Environment::get().getWindowManager()->setCursorVisible(guiMode && (!mControllerManager->joystickLastUsed() || mControllerManager->gamepadGuiCursorEnabled()));
|
||||||
|
@ -111,8 +111,6 @@ namespace MWInput
|
|||||||
|
|
||||||
bool mGrabCursor;
|
bool mGrabCursor;
|
||||||
|
|
||||||
bool mGuiCursorEnabled;
|
|
||||||
|
|
||||||
ControlSwitch* mControlSwitch;
|
ControlSwitch* mControlSwitch;
|
||||||
|
|
||||||
ActionManager* mActionManager;
|
ActionManager* mActionManager;
|
||||||
|
@ -22,6 +22,7 @@ namespace MWInput
|
|||||||
, mGyroVAxis(GyroscopeAxis::Y)
|
, mGyroVAxis(GyroscopeAxis::Y)
|
||||||
, mGyroInputThreshold(Settings::Manager::getFloat("gyro input threshold", "Input"))
|
, mGyroInputThreshold(Settings::Manager::getFloat("gyro input threshold", "Input"))
|
||||||
, mGyroscope(nullptr)
|
, mGyroscope(nullptr)
|
||||||
|
, mGuiCursorEnabled(true)
|
||||||
{
|
{
|
||||||
init();
|
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)
|
if (mGyroXSpeed == 0.f && mGyroYSpeed == 0.f)
|
||||||
return;
|
return;
|
||||||
@ -252,7 +253,7 @@ namespace MWInput
|
|||||||
|
|
||||||
mGyroUpdateTimer += dt;
|
mGyroUpdateTimer += dt;
|
||||||
|
|
||||||
if (!isCursorEnabled)
|
if (!mGuiCursorEnabled)
|
||||||
{
|
{
|
||||||
float rot[3];
|
float rot[3];
|
||||||
rot[0] = mGyroYSpeed * dt * mGyroVSensitivity * 4 * (mInvertY ? -1 : 1);
|
rot[0] = mGyroYSpeed * dt * mGyroVSensitivity * 4 * (mInvertY ? -1 : 1);
|
||||||
|
@ -29,12 +29,14 @@ namespace MWInput
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void update(float dt, bool isCursorEnabled);
|
void update(float dt);
|
||||||
|
|
||||||
virtual void sensorUpdated(const SDL_SensorEvent &arg);
|
virtual void sensorUpdated(const SDL_SensorEvent &arg);
|
||||||
virtual void displayOrientationChanged();
|
virtual void displayOrientationChanged();
|
||||||
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
||||||
|
|
||||||
|
void setGuiCursorEnabled(bool enabled) { mGuiCursorEnabled = enabled; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum GyroscopeAxis
|
enum GyroscopeAxis
|
||||||
{
|
{
|
||||||
@ -66,6 +68,8 @@ namespace MWInput
|
|||||||
float mGyroInputThreshold;
|
float mGyroInputThreshold;
|
||||||
|
|
||||||
SDL_Sensor* mGyroscope;
|
SDL_Sensor* mGyroscope;
|
||||||
|
|
||||||
|
bool mGuiCursorEnabled;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user