Remove support for sticky axis and sensitivity to Property type

This commit is contained in:
Malin E
2021-11-17 16:57:05 +01:00
parent 5ae9bfcd14
commit 78b1f2c6e1
6 changed files with 14 additions and 30 deletions
@@ -56,7 +56,7 @@ local unbindRoll = function(name, axis)
return [[
-- Reset previous state
if(Joystick.State.Axis.Type == "Property") then
openspace.navigation.bindJoystickAxisProperty("]] .. name .. "\", " .. axis .. [[, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.Inverted, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.IsRemote);
openspace.navigation.bindJoystickAxisProperty("]] .. name .. "\", " .. axis .. [[, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.Inverted, Joystick.State.Axis.IsRemote);
else
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
end
@@ -96,8 +96,7 @@ public:
void setAxisMappingProperty(const std::string& joystickName, int axis,
const std::string& propertyUri, float min = 0.f, float max = 1.f,
AxisInvert shouldInvert = AxisInvert::No,
bool isSticky = false, double sensitivity = 0.0, bool isRemote = true
AxisInvert shouldInvert = AxisInvert::No, bool isRemote = true
);
AxisInformation axisMapping(const std::string& joystickName, int axis) const;
@@ -111,8 +111,7 @@ public:
int axis, const std::string& propertyUri,
float min = 0.f, float max = 1.f,
JoystickCameraStates::AxisInvert shouldInvert =
JoystickCameraStates::AxisInvert::No,
bool isSticky = false, double sensitivity = 0.0, bool isRemote = true
JoystickCameraStates::AxisInvert::No, bool isRemote = true
);
JoystickCameraStates::AxisInformation joystickAxisMapping(
+6 -8
View File
@@ -97,12 +97,13 @@ void JoystickCameraStates::updateStateFromInput(
if (t.type == AxisType::Property) {
value = value * (t.maxValue - t.minValue) + t.minValue;
}
if (std::abs(t.sensitivity) > std::numeric_limits<double>::epsilon()) {
value = static_cast<float>(value * t.sensitivity * _sensitivity);
}
else {
value = static_cast<float>(value * _sensitivity);
if (std::abs(t.sensitivity) > std::numeric_limits<double>::epsilon()) {
value = static_cast<float>(value * t.sensitivity * _sensitivity);
}
else {
value = static_cast<float>(value * _sensitivity);
}
}
switch (t.type) {
@@ -245,7 +246,6 @@ void JoystickCameraStates::setAxisMappingProperty(const std::string& joystickNam
const std::string& propertyUri,
float min, float max,
AxisInvert shouldInvert,
bool isSticky, double sensitivity,
bool isRemote)
{
ghoul_assert(axis < JoystickInputState::MaxAxes, "axis must be < MaxAxes");
@@ -257,8 +257,6 @@ void JoystickCameraStates::setAxisMappingProperty(const std::string& joystickNam
joystickCameraState->axisMapping[axis].type = AxisType::Property;
joystickCameraState->axisMapping[axis].invert = shouldInvert;
joystickCameraState->axisMapping[axis].isSticky = isSticky;
joystickCameraState->axisMapping[axis].sensitivity = sensitivity;
joystickCameraState->axisMapping[axis].propertyUri = propertyUri;
joystickCameraState->axisMapping[axis].minValue = min;
joystickCameraState->axisMapping[axis].maxValue = max;
+3 -9
View File
@@ -521,7 +521,6 @@ void NavigationHandler::setJoystickAxisMappingProperty(const std::string& joysti
const std::string& propertyUri,
float min, float max,
JoystickCameraStates::AxisInvert shouldInvert,
bool isSticky, double sensitivity,
bool isRemote)
{
_orbitalNavigator.joystickStates().setAxisMappingProperty(
@@ -531,8 +530,6 @@ void NavigationHandler::setJoystickAxisMappingProperty(const std::string& joysti
min,
max,
shouldInvert,
isSticky,
sensitivity,
isRemote
);
}
@@ -672,12 +669,9 @@ scripting::LuaLibrary NavigationHandler::luaLibrary() {
"identified by the third argument. 'min' and 'max' is the minimum and "
"the maximum allowed value for the given property and the axis value is "
"rescaled from [-1, 1] to [min, max], default is [0, 1]. If 'isInverted' "
"is 'true', the axis value is inverted. If 'isSticky' is 'true', the "
"value is calculated relative to the previous value. If 'sensitivity' is "
"given then that value will affect the sensitivity of the axis together "
"with the global sensitivity. The last argument determines whether the "
"property change is going to be executed locally or remotely, where the "
"latter is the default."
"is 'true', the axis value is inverted. The last argument determines "
"whether the property change is going to be executed locally or "
"remotely, where the latter is the default."
},
{
"joystickAxis",
+2 -8
View File
@@ -177,18 +177,14 @@ int bindJoystickAxis(lua_State* L) {
int bindJoystickAxisProperty(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, { 3, 9 }, "lua::bindJoystickAxisProperty");
auto [joystickName, axis, propertyUri, min, max, shouldInvert, isSticky, sensitivity,
isRemote] =
auto [joystickName, axis, propertyUri, min, max, shouldInvert, isRemote] =
ghoul::lua::values<
std::string, int, std::string, std::optional<float>, std::optional<float>,
std::optional<bool>, std::optional<bool>, std::optional<double>,
std::optional<bool>
std::optional<bool>, std::optional<bool>
>(L);
min = min.value_or(0.f);
max = max.value_or(1.f);
shouldInvert = shouldInvert.value_or(false);
isSticky = isSticky.value_or(false);
sensitivity = sensitivity.value_or(0.0);
isRemote = isRemote.value_or(true);
global::navigationHandler->setJoystickAxisMappingProperty(
@@ -198,8 +194,6 @@ int bindJoystickAxisProperty(lua_State* L) {
*min,
*max,
interaction::JoystickCameraStates::AxisInvert(*shouldInvert),
*isSticky,
*sensitivity,
*isRemote
);
return 0;