Update joysitck assets

* NOTE: Xbox and PS4 names have not yet been added
This commit is contained in:
Malin E
2021-11-05 13:03:10 +01:00
parent 3526e14e66
commit 5ed69aea6b
5 changed files with 99 additions and 73 deletions
@@ -4,7 +4,7 @@ Joystick.State = {}
Joystick.State.IsInRollMode = false
Joystick.State.Axis = {}
local bindLocalRoll = function(axis)
local bindLocalRoll = function(name, axis)
return [[
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
if not Joystick.State.IsInRollMode then
@@ -13,12 +13,12 @@ local bindLocalRoll = function(axis)
end
-- Set new axis state
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
openspace.navigation.bindJoystickAxis(]] .. name .. ", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
Joystick.State.IsInRollMode = true
]]
end
local bindGlobalRoll = function(axis)
local bindGlobalRoll = function(name, axis)
return [[
-- We only want to store the current state in the first mode that is enabled, otherwise we will overwrite the backup
if not Joystick.State.IsInRollMode then
@@ -27,35 +27,35 @@ local bindGlobalRoll = function(axis)
end
-- Set new axis state
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
openspace.navigation.bindJoystickAxis(]] .. name .. ", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
Joystick.State.IsInRollMode = true
]]
end
local permaBindLocalRoll = function(axis)
local permaBindLocalRoll = function(name, axis)
return [[
-- Save current axis state
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity = openspace.navigation.joystickAxis(]] .. axis .. [[)
-- Set new axis state
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
openspace.navigation.bindJoystickAxis(]] .. name .. ", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
]]
end
local permaBindGlobalRoll = function(axis)
local permaBindGlobalRoll = function(name, axis)
return [[
-- Save current axis state
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity = openspace.navigation.joystickAxis(]] .. axis .. [[)
-- Set new axis state
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
openspace.navigation.bindJoystickAxis(]] .. name .. ", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
]]
end
local unbindRoll = function(axis)
local unbindRoll = function(name, axis)
return [[
-- Reset previous state
openspace.navigation.bindJoystickAxis(]] .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
openspace.navigation.bindJoystickAxis(]] .. name .. ", " .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.Normalized, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
]]
end
+29 -19
View File
@@ -1,7 +1,7 @@
local propertyHelper = asset.require('../property_helper')
local joystickHelper = asset.require('./joystick_helper')
-- Allowed values for the second parameter of bindJoystickAxis:
-- Allowed values for the third parameter of bindJoystickAxis:
-- "None"
-- "Orbit X"
-- "Orbit Y"
@@ -14,13 +14,13 @@ local joystickHelper = asset.require('./joystick_helper')
-- "GlobalRoll Y"
-- "Pan X"
-- "Pan Y"
-- Third parameter determines whether the axis should be inverted
-- Fourth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Fifth parameters determins if the axis should be "Sticky" or not.
-- Fourth parameter determines whether the axis should be inverted
-- Fifth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Sixth parameters determins if the axis should be "Sticky" or not.
-- The axis values can either go back to 0 when the joystick is released or it can
-- stay at the value it was before the joystick was released.
-- The latter is called a sticky axis, when the values don't go back to 0.
-- Sixth parameter is the sensitivity for the axis
-- Seventh parameter is the sensitivity for the axis
local PS4Controller = {
LeftThumbStick = { 0 , 1 },
@@ -49,59 +49,68 @@ local PS4Controller = {
asset.onInitialize(function()
local controller = PS4Controller;
local name = "";
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[2], 0.15)
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[2], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.LeftThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.LeftThumbStick[2], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.RightThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.RightThumbStick[2], 0.15)
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[1], "Orbit X");
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[2], "Orbit Y", true);
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[2], "Pan Y", true);
openspace.navigation.bindJoystickAxis(controller.L2, "Zoom Out", false, true);
openspace.navigation.bindJoystickAxis(controller.R2, "Zoom In", false, true);
openspace.navigation.bindJoystickAxis(name, controller.LeftThumbStick[1], "Orbit X");
openspace.navigation.bindJoystickAxis(name, controller.LeftThumbStick[2], "Orbit Y", true);
openspace.navigation.bindJoystickAxis(name, controller.RightThumbStick[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(name, controller.RightThumbStick[2], "Pan Y", true);
openspace.navigation.bindJoystickAxis(name, controller.L2, "Zoom Out", false, true);
openspace.navigation.bindJoystickAxis(name, controller.R2, "Zoom In", false, true);
openspace.navigation.bindJoystickButton(
name,
controller.L1,
joystickHelper.bindLocalRoll(controller.RightThumbStick[1]),
joystickHelper.bindLocalRoll(name, controller.RightThumbStick[1]),
"Switch to local roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.L1,
joystickHelper.unbindRoll(controller.RightThumbStick[1]),
joystickHelper.unbindRoll(name, controller.RightThumbStick[1]),
"Switch back to normal mode",
"Release"
)
openspace.navigation.bindJoystickButton(
name,
controller.R1,
joystickHelper.bindGlobalRoll(controller.RightThumbStick[1]),
joystickHelper.bindGlobalRoll(name, controller.RightThumbStick[1]),
"Switch to global roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.R1,
joystickHelper.unbindRoll(controller.RightThumbStick[1]),
joystickHelper.unbindRoll(name, controller.RightThumbStick[1]),
"Switch back to normal mode",
"Release"
)
openspace.navigation.bindJoystickButton(
name,
controller.Cross,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
"Toggle zoom friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.Circle,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
"Toggle rotational friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.DPad.Left,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
"Toggle roll friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.Square,
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');" ..
@@ -109,6 +118,7 @@ asset.onInitialize(function()
"Switch target to Earth"
)
openspace.navigation.bindJoystickButton(
name,
controller.Triangle,
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Mars');" ..
@@ -1,7 +1,7 @@
local propertyHelper = asset.require('../property_helper')
local joystickHelper = asset.require('./joystick_helper')
-- Allowed values for the second parameter of bindJoystickAxis:
-- Allowed values for the third parameter of bindJoystickAxis:
-- "None"
-- "Orbit X"
-- "Orbit Y"
@@ -14,14 +14,14 @@ local joystickHelper = asset.require('./joystick_helper')
-- "GlobalRoll Y"
-- "Pan X"
-- "Pan Y"
-- Third parameter determines whether the axis should be inverted
-- Fourth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Fifth parameters determins if the axis should be "Sticky" or not.
-- Fourth parameter determines whether the axis should be inverted
-- Fifth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Sixth parameters determins if the axis should be "Sticky" or not.
-- The axis values can either go back to 0 when the joystick is released or it can
-- stay at the value it was before the joystick was released.
-- The latter is called a sticky axis, when the values don't go back to 0.
-- This version of the SpaceMouse is NOT Sticky.
-- Sixth parameter is the sensitivity for the axis
-- Seventh parameter is the sensitivity for the axis
local SpaceMouse = {
Push = {0, 1, 2}, -- left/right, back/forth, up/down
@@ -33,23 +33,26 @@ local SpaceMouse = {
asset.onInitialize(function()
local controller = SpaceMouse;
local name = "SpaceNavigator";
openspace.navigation.bindJoystickAxis(controller.Push[1], "Orbit X", false);
openspace.navigation.bindJoystickAxis(controller.Push[2], "Orbit Y", false);
openspace.navigation.bindJoystickAxis(controller.Twist[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(controller.Tilt[2], "Pan Y", false);
openspace.navigation.bindJoystickAxis(controller.Push[3], "Zoom", false);
openspace.navigation.bindJoystickAxis(controller.Tilt[1], "LocalRoll X", false);
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false);
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false);
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false);
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false);
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false);
openspace.navigation.bindJoystickButton(
name,
controller.LeftButton,
joystickHelper.permaBindLocalRoll(controller.Tilt[1]),
joystickHelper.permaBindLocalRoll(name, controller.Tilt[1]),
"Switch to local roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.RightButton,
joystickHelper.permaBindGlobalRoll(controller.Tilt[1]),
joystickHelper.permaBindGlobalRoll(name, controller.Tilt[1]),
"Switch to global roll mode"
)
end)
+16 -13
View File
@@ -1,7 +1,7 @@
local propertyHelper = asset.require('../property_helper')
local joystickHelper = asset.require('./joystick_helper')
-- Allowed values for the second parameter of bindJoystickAxis:
-- Allowed values for the third parameter of bindJoystickAxis:
-- "None"
-- "Orbit X"
-- "Orbit Y"
@@ -14,14 +14,14 @@ local joystickHelper = asset.require('./joystick_helper')
-- "GlobalRoll Y"
-- "Pan X"
-- "Pan Y"
-- Third parameter determines whether the axis should be inverted
-- Fourth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Fifth parameters determins if the axis should be "Sticky" or not.
-- Fourth parameter determines whether the axis should be inverted
-- Fifth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Sixth parameters determins if the axis should be "Sticky" or not.
-- The axis values can either go back to 0 when the joystick is released or it can
-- stay at the value it was before the joystick was released.
-- The latter is called a sticky axis, when the values don't go back to 0.
-- This version of the SpaceMouse IS Sticky.
-- Sixth parameter is the sensitivity for the axis
-- Seventh parameter is the sensitivity for the axis
local SpaceMouse = {
Push = {0, 1, 2}, -- left/right, back/forth, up/down
@@ -33,23 +33,26 @@ local SpaceMouse = {
asset.onInitialize(function()
local controller = SpaceMouse;
local name = "SpaceNavigator";
openspace.navigation.bindJoystickAxis(controller.Push[1], "Orbit X", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(controller.Push[2], "Orbit Y", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(controller.Twist[1], "Pan X", true, false, true, 40.0);
openspace.navigation.bindJoystickAxis(controller.Tilt[2], "Pan Y", false, false, true, 35.0);
openspace.navigation.bindJoystickAxis(controller.Push[3], "Zoom", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(controller.Tilt[1], "LocalRoll X", false, false, true, 35.0);
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true, false, true, 40.0);
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false, false, true, 35.0);
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false, false, true, 40.0);
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false, false, true, 35.0);
openspace.navigation.bindJoystickButton(
name,
controller.LeftButton,
joystickHelper.permaBindLocalRoll(controller.Tilt[1]),
joystickHelper.permaBindLocalRoll(name, controller.Tilt[1]),
"Switch to local roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.RightButton,
joystickHelper.permaBindGlobalRoll(controller.Tilt[1]),
joystickHelper.permaBindGlobalRoll(name, controller.Tilt[1]),
"Switch to global roll mode"
)
end)
+28 -18
View File
@@ -1,7 +1,7 @@
local propertyHelper = asset.require('../property_helper')
local joystickHelper = asset.require('./joystick_helper')
-- Allowed values for the second parameter of bindJoystickAxis:
-- Allowed values for the third parameter of bindJoystickAxis:
-- "None"
-- "Orbit X"
-- "Orbit Y"
@@ -14,13 +14,13 @@ local joystickHelper = asset.require('./joystick_helper')
-- "GlobalRoll Y"
-- "Pan X"
-- "Pan Y"
-- Third parameter determines whether the axis should be inverted
-- Fourth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Fifth parameters determins if the axis should be "Sticky" or not.
-- Fourth parameter determines whether the axis should be inverted
-- Fifth parameter determines whether the axis should be normalized from [-1,1] to [0,1]
-- Sixth parameters determins if the axis should be "Sticky" or not.
-- The axis values can either go back to 0 when the joystick is released or it can
-- stay at the value it was before the joystick was released.
-- The latter is called a sticky axis, when the values don't go back to 0.
-- Sixth parameter is the sensitivity for the axis
-- Seventh parameter is the sensitivity for the axis
local XBoxController = {
LeftThumbStick = { 0 , 1 },
@@ -47,59 +47,68 @@ local XBoxController = {
asset.onInitialize(function()
local controller = XBoxController;
local name = "";
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(controller.LeftThumbStick[2], 0.15)
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.LeftThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.LeftThumbStick[2], 0.15)
openspace.navigation.setAxisDeadZone(name, controller.RightThumbStick[1], 0.15)
openspace.navigation.setAxisDeadZone(controller.RightThumbStick[2], 0.15)
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[1], "Orbit X");
openspace.navigation.bindJoystickAxis(controller.LeftThumbStick[2], "Orbit Y", true);
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(controller.RightThumbStick[2], "Pan Y", true);
openspace.navigation.bindJoystickAxis(controller.LeftTrigger, "Zoom Out", false, true);
openspace.navigation.bindJoystickAxis(controller.RightTrigger, "Zoom In", false, true);
openspace.navigation.bindJoystickAxis(name, controller.LeftThumbStick[1], "Orbit X");
openspace.navigation.bindJoystickAxis(name, controller.LeftThumbStick[2], "Orbit Y", true);
openspace.navigation.bindJoystickAxis(name, controller.RightThumbStick[1], "Pan X", true);
openspace.navigation.bindJoystickAxis(name, controller.RightThumbStick[2], "Pan Y", true);
openspace.navigation.bindJoystickAxis(name, controller.LeftTrigger, "Zoom Out", false, true);
openspace.navigation.bindJoystickAxis(name, controller.RightTrigger, "Zoom In", false, true);
openspace.navigation.bindJoystickButton(
name,
controller.LB,
joystickHelper.bindLocalRoll(controller.RightThumbStick[1]),
joystickHelper.bindLocalRoll(name, controller.RightThumbStick[1]),
"Switch to local roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.LB,
joystickHelper.unbindRoll(controller.RightThumbStick[1]),
joystickHelper.unbindRoll(name, controller.RightThumbStick[1]),
"Switch back to normal mode",
"Release"
)
openspace.navigation.bindJoystickButton(
name,
controller.RB,
joystickHelper.bindGlobalRoll(controller.RightThumbStick[1]),
joystickHelper.bindGlobalRoll(name, controller.RightThumbStick[1]),
"Switch to global roll mode"
)
openspace.navigation.bindJoystickButton(
name,
controller.RB,
joystickHelper.unbindRoll(controller.RightThumbStick[1]),
joystickHelper.unbindRoll(name, controller.RightThumbStick[1]),
"Switch back to normal mode",
"Release"
)
openspace.navigation.bindJoystickButton(
name,
controller.A,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'),
"Toggle zoom friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.B,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'),
"Toggle rotational friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.DPad.Left,
propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'),
"Toggle roll friction"
)
openspace.navigation.bindJoystickButton(
name,
controller.X,
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Earth');" ..
@@ -107,6 +116,7 @@ asset.onInitialize(function()
"Switch target to Earth"
)
openspace.navigation.bindJoystickButton(
name,
controller.Y,
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Aim', '');" ..
"openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.Anchor', 'Mars');" ..