mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-09 04:59:56 -06:00
Enable reversing of movement for joystick axes
This commit is contained in:
@@ -9,11 +9,11 @@ local bindLocalRoll = function(name, axis)
|
||||
-- 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
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
end
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
end
|
||||
@@ -23,11 +23,11 @@ local bindGlobalRoll = function(name, axis)
|
||||
-- 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
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
end
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity);
|
||||
Joystick.State.IsInRollMode = true
|
||||
]]
|
||||
end
|
||||
@@ -35,20 +35,20 @@ end
|
||||
local permaBindLocalRoll = function(name, axis)
|
||||
return [[
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "LocalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity);
|
||||
]]
|
||||
end
|
||||
|
||||
local permaBindGlobalRoll = function(name, axis)
|
||||
return [[
|
||||
-- Save current axis state
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity, Joystick.State.Axis.PropertyUri, Joystick.State.Axis.MinValue, Joystick.State.Axis.MaxValue, Joystick.State.Axis.IsRemote = openspace.navigation.joystickAxis("]] .. name .. "\", " .. axis .. [[);
|
||||
|
||||
-- Set new axis state
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Sensitivity);
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, "GlobalRoll X", Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity);
|
||||
]]
|
||||
end
|
||||
|
||||
@@ -56,9 +56,9 @@ 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.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.Flip, 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);
|
||||
openspace.navigation.bindJoystickAxis("]] .. name .. "\", " .. axis .. [[, Joystick.State.Axis.Type, Joystick.State.Axis.Inverted, Joystick.State.Axis.JoystickType, Joystick.State.Axis.Sticky, Joystick.State.Axis.Flip, Joystick.State.Axis.Sensitivity);
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
@@ -21,7 +21,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local PS4Controller = {
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
|
||||
@@ -22,7 +22,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local SpaceMouse = {
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
@@ -37,12 +38,12 @@ asset.onInitialize(function()
|
||||
local controller = SpaceMouse;
|
||||
local name = "3Dconnexion Universal Receiver";
|
||||
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false, "JoystickLike", true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false, "JoystickLike", true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false, "JoystickLike", true, false, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false, "JoystickLike", true, false, 35.0);
|
||||
|
||||
openspace.navigation.bindJoystickButton(
|
||||
name,
|
||||
|
||||
@@ -22,7 +22,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local SpaceMouse = {
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
@@ -37,12 +38,12 @@ asset.onInitialize(function()
|
||||
local controller = SpaceMouse;
|
||||
local name = "SpaceNavigator";
|
||||
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false, "JoystickLike", true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false, "JoystickLike", true, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false, "JoystickLike", true, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y", false, "JoystickLike", true, false, 35.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom", false, "JoystickLike", true, false, 40.0);
|
||||
openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X", false, "JoystickLike", true, false, 35.0);
|
||||
|
||||
openspace.navigation.bindJoystickButton(
|
||||
name,
|
||||
|
||||
@@ -22,7 +22,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local SpaceMouse = {
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
|
||||
@@ -22,7 +22,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local SpaceMouse = {
|
||||
Push = {0, 1, 2}, -- left/right, back/forth, up/down
|
||||
|
||||
@@ -21,7 +21,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local XBoxController = {
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
|
||||
@@ -21,7 +21,8 @@ local joystickHelper = asset.require("./joystick_helper")
|
||||
-- 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.
|
||||
-- Seventh parameter is the sensitivity for the axis
|
||||
-- Seventh parameter can be used to reverse the camera movement for the axis
|
||||
-- Eighth parameter is the sensitivity for the axis
|
||||
|
||||
local XBoxController = {
|
||||
LeftThumbStick = { 0 , 1 },
|
||||
|
||||
Reference in New Issue
Block a user