From 8e2fd76e7edcbf408f418ca956e3572bea8da046 Mon Sep 17 00:00:00 2001 From: Malin E Date: Thu, 14 Apr 2022 09:38:48 +0200 Subject: [PATCH] Add different versions of spacemouse joystick asset --- .../space-mouse-compact-wireless.asset | 60 +++++++++++++++++++ ...-mouse.asset => space-mouse-compact.asset} | 1 + .../space-mouse-enterprise-wireless.asset | 60 +++++++++++++++++++ ...cky.asset => space-mouse-enterprise.asset} | 3 +- 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 data/assets/util/joysticks/space-mouse-compact-wireless.asset rename data/assets/util/joysticks/{space-mouse.asset => space-mouse-compact.asset} (99%) create mode 100644 data/assets/util/joysticks/space-mouse-enterprise-wireless.asset rename data/assets/util/joysticks/{space-mouse-not-sticky.asset => space-mouse-enterprise.asset} (98%) diff --git a/data/assets/util/joysticks/space-mouse-compact-wireless.asset b/data/assets/util/joysticks/space-mouse-compact-wireless.asset new file mode 100644 index 0000000000..2874aa23f2 --- /dev/null +++ b/data/assets/util/joysticks/space-mouse-compact-wireless.asset @@ -0,0 +1,60 @@ +local propertyHelper = asset.require("../property_helper") +local joystickHelper = asset.require("./joystick_helper") + +-- Allowed values for the third parameter of bindJoystickAxis: +-- "None" +-- "Orbit X" +-- "Orbit Y" +-- "Zoom" -- both in and out +-- "Zoom In" +-- "Zoom Out" +-- "LocalRoll X" +-- "LocalRoll Y" +-- "GlobalRoll X" +-- "GlobalRoll Y" +-- "Pan X" +-- "Pan Y" +-- Fourth parameter determines whether the axis should be inverted +-- Fifth parameter determines whether the axis behaves like a joystick or a Trigger. +-- Allowed values are "JoystickLike" and "TriggerLike", the first one is the default +-- 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. +-- Seventh parameter is the sensitivity for the axis + +local SpaceMouse = { + Push = {0, 1, 2}, -- left/right, back/forth, up/down + Twist = {5}, -- left/right + Tilt = {4, 3}, -- left/right, back/forth + + LeftButton = 0, + RightButton = 1 +} + +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.bindJoystickButton( + name, + controller.LeftButton, + joystickHelper.permaBindLocalRoll(name, controller.Tilt[1]), + "Switch to local roll mode" + ) + + openspace.navigation.bindJoystickButton( + name, + controller.RightButton, + joystickHelper.permaBindGlobalRoll(name, controller.Tilt[1]), + "Switch to global roll mode" + ) +end) diff --git a/data/assets/util/joysticks/space-mouse.asset b/data/assets/util/joysticks/space-mouse-compact.asset similarity index 99% rename from data/assets/util/joysticks/space-mouse.asset rename to data/assets/util/joysticks/space-mouse-compact.asset index 3d36804891..d9a2d13fed 100644 --- a/data/assets/util/joysticks/space-mouse.asset +++ b/data/assets/util/joysticks/space-mouse-compact.asset @@ -28,6 +28,7 @@ local SpaceMouse = { Push = {0, 1, 2}, -- left/right, back/forth, up/down Twist = {5}, -- left/right Tilt = {4, 3}, -- left/right, back/forth + LeftButton = 0, RightButton = 1 } diff --git a/data/assets/util/joysticks/space-mouse-enterprise-wireless.asset b/data/assets/util/joysticks/space-mouse-enterprise-wireless.asset new file mode 100644 index 0000000000..76087df224 --- /dev/null +++ b/data/assets/util/joysticks/space-mouse-enterprise-wireless.asset @@ -0,0 +1,60 @@ +local propertyHelper = asset.require("../property_helper") +local joystickHelper = asset.require("./joystick_helper") + +-- Allowed values for the third parameter of bindJoystickAxis: +-- "None" +-- "Orbit X" +-- "Orbit Y" +-- "Zoom" -- both in and out +-- "Zoom In" +-- "Zoom Out" +-- "LocalRoll X" +-- "LocalRoll Y" +-- "GlobalRoll X" +-- "GlobalRoll Y" +-- "Pan X" +-- "Pan Y" +-- Fourth parameter determines whether the axis should be inverted +-- Fifth parameter determines whether the axis behaves like a joystick or a Trigger. +-- Allowed values are "JoystickLike" and "TriggerLike", the first one is the default +-- 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. +-- Seventh parameter is the sensitivity for the axis + +local SpaceMouse = { + Push = {0, 1, 2}, -- left/right, back/forth, up/down + Twist = {5}, -- left/right + Tilt = {4, 3}, -- left/right, back/forth + + LeftButton = 0, + RightButton = 1 +} + +asset.onInitialize(function() + local controller = SpaceMouse; + local name = "3Dconnexion Universal Receiver"; + + openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X"); + openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y"); + openspace.navigation.bindJoystickAxis(name, controller.Twist[1], "Pan X", true); + openspace.navigation.bindJoystickAxis(name, controller.Tilt[2], "Pan Y"); + openspace.navigation.bindJoystickAxis(name, controller.Push[3], "Zoom"); + openspace.navigation.bindJoystickAxis(name, controller.Tilt[1], "LocalRoll X"); + + openspace.navigation.bindJoystickButton( + name, + controller.LeftButton, + joystickHelper.permaBindLocalRoll(name, controller.Tilt[1]), + "Switch to local roll mode" + ) + + openspace.navigation.bindJoystickButton( + name, + controller.RightButton, + joystickHelper.permaBindGlobalRoll(name, controller.Tilt[1]), + "Switch to global roll mode" + ) +end) diff --git a/data/assets/util/joysticks/space-mouse-not-sticky.asset b/data/assets/util/joysticks/space-mouse-enterprise.asset similarity index 98% rename from data/assets/util/joysticks/space-mouse-not-sticky.asset rename to data/assets/util/joysticks/space-mouse-enterprise.asset index cea4fb0681..98d8697908 100644 --- a/data/assets/util/joysticks/space-mouse-not-sticky.asset +++ b/data/assets/util/joysticks/space-mouse-enterprise.asset @@ -28,13 +28,14 @@ local SpaceMouse = { Push = {0, 1, 2}, -- left/right, back/forth, up/down Twist = {5}, -- left/right Tilt = {4, 3}, -- left/right, back/forth + LeftButton = 0, RightButton = 1 } asset.onInitialize(function() local controller = SpaceMouse; - local name = "SpaceNavigator"; + local name = "SpaceMouse Enterprise"; openspace.navigation.bindJoystickAxis(name, controller.Push[1], "Orbit X"); openspace.navigation.bindJoystickAxis(name, controller.Push[2], "Orbit Y");