mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-09 03:57:51 +03:00
Use settings values for Input settings
This commit is contained in:
parent
5a27ccacb7
commit
6c18723bc7
13 changed files with 138 additions and 185 deletions
|
@ -30,10 +30,8 @@ namespace Settings
|
|||
SettingValue<float> mJoystickDeadZone{ mIndex, "Input", "joystick dead zone",
|
||||
makeClampSanitizerFloat(0, 0.5f) };
|
||||
SettingValue<bool> mEnableGyroscope{ mIndex, "Input", "enable gyroscope" };
|
||||
SettingValue<std::string> mGyroHorizontalAxis{ mIndex, "Input", "gyro horizontal axis",
|
||||
makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) };
|
||||
SettingValue<std::string> mGyroVerticalAxis{ mIndex, "Input", "gyro vertical axis",
|
||||
makeEnumSanitizerString({ "x", "y", "z", "-x", "-y", "-z" }) };
|
||||
SettingValue<GyroscopeAxis> mGyroHorizontalAxis{ mIndex, "Input", "gyro horizontal axis" };
|
||||
SettingValue<GyroscopeAxis> mGyroVerticalAxis{ mIndex, "Input", "gyro vertical axis" };
|
||||
SettingValue<float> mGyroInputThreshold{ mIndex, "Input", "gyro input threshold", makeMaxSanitizerFloat(0) };
|
||||
SettingValue<float> mGyroHorizontalSensitivity{ mIndex, "Input", "gyro horizontal sensitivity",
|
||||
makeMaxStrictSanitizerFloat(0) };
|
||||
|
|
17
components/settings/gyroscopeaxis.hpp
Normal file
17
components/settings/gyroscopeaxis.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef OPENMW_COMPONENTS_SETTINGS_GYROSCOPEAXIS_H
|
||||
#define OPENMW_COMPONENTS_SETTINGS_GYROSCOPEAXIS_H
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
enum class GyroscopeAxis
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
MinusX,
|
||||
MinusY,
|
||||
MinusZ,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -464,4 +464,21 @@ namespace Settings
|
|||
sInitialized.emplace(category, setting);
|
||||
}
|
||||
|
||||
GyroscopeAxis parseGyroscopeAxis(std::string_view value)
|
||||
{
|
||||
if (value == "x")
|
||||
return GyroscopeAxis::X;
|
||||
else if (value == "y")
|
||||
return GyroscopeAxis::Y;
|
||||
else if (value == "z")
|
||||
return GyroscopeAxis::Z;
|
||||
else if (value == "-x")
|
||||
return GyroscopeAxis::MinusX;
|
||||
else if (value == "-y")
|
||||
return GyroscopeAxis::MinusY;
|
||||
else if (value == "-z")
|
||||
return GyroscopeAxis::MinusZ;
|
||||
|
||||
throw std::runtime_error("Invalid gyroscope axis: " + std::string(value));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COMPONENTS_SETTINGS_H
|
||||
|
||||
#include "categories.hpp"
|
||||
#include "gyroscopeaxis.hpp"
|
||||
|
||||
#include "components/detournavigator/collisionshapetype.hpp"
|
||||
|
||||
|
@ -197,6 +198,14 @@ namespace Settings
|
|||
{
|
||||
return MyGUI::Colour::parse(getString(setting, category));
|
||||
}
|
||||
|
||||
GyroscopeAxis parseGyroscopeAxis(std::string_view value);
|
||||
|
||||
template <>
|
||||
inline GyroscopeAxis Manager::getImpl<GyroscopeAxis>(std::string_view setting, std::string_view category)
|
||||
{
|
||||
return parseGyroscopeAxis(getString(setting, category));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_SETTINGS_H
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef OPENMW_COMPONENTS_SETTINGS_SETTINGVALUE_H
|
||||
#define OPENMW_COMPONENTS_SETTINGS_SETTINGVALUE_H
|
||||
|
||||
#include "gyroscopeaxis.hpp"
|
||||
#include "sanitizer.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
|
@ -36,6 +37,7 @@ namespace Settings
|
|||
CollisionShapeType,
|
||||
StringArray,
|
||||
MyGuiColour,
|
||||
GyroscopeAxis,
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@ -131,6 +133,12 @@ namespace Settings
|
|||
return SettingValueType::MyGuiColour;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline constexpr SettingValueType getSettingValueType<GyroscopeAxis>()
|
||||
{
|
||||
return SettingValueType::GyroscopeAxis;
|
||||
}
|
||||
|
||||
inline constexpr std::string_view getSettingValueTypeName(SettingValueType type)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -165,6 +173,8 @@ namespace Settings
|
|||
return "string array";
|
||||
case SettingValueType::MyGuiColour:
|
||||
return "colour";
|
||||
case SettingValueType::GyroscopeAxis:
|
||||
return "gyroscope axis";
|
||||
}
|
||||
return "unsupported";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue