diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 7479fcbc14..486d4f7d4f 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -37,6 +37,7 @@ however, it has to be formatted properly to pass verification tests. ### Changed - Changed enum value `Key.IMESelected` to obsolete which was not a real key. Please use the ButtonControl `imeSelected`. +- Changed conditional guards inside Plugins/XR so that we don't unnecessarily wrap entire classes. This stops downstream packages from having to also wrap Input System objects with similar conditionals. ### Added - Added support of F13-F24 keys. [UUM-44328](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-44328) diff --git a/Packages/com.unity.inputsystem/Documentation~/filter.yml b/Packages/com.unity.inputsystem/Documentation~/filter.yml index 844f071c39..04ac179404 100644 --- a/Packages/com.unity.inputsystem/Documentation~/filter.yml +++ b/Packages/com.unity.inputsystem/Documentation~/filter.yml @@ -37,3 +37,15 @@ apiRules: - exclude: uidRegex: ^UnityEngine\.InputSystem\.InputSystem\.runInBackground$ type: Member + - exclude: + uidRegex: ^Unity\.XR\.Oculus\.Input\..*$ + type: Namespace + - exclude: + uidRegex: ^Unity\.XR\.GoogleVr\..*$ + type: Namespace + - exclude: + uidRegex: ^Unity\.XR\.OpenVR\..*$ + type: Namespace + - exclude: + uidRegex: ^Unity\.XR\.WindowsMR\.Input\..*$ + type: Namespace diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs index a4dab309ff..ca156f0a8c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs @@ -1,6 +1,5 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. +#if !DISABLE_BUILTIN_INPUT_SYSTEM_GOOGLEVR // Docs generation is skipped because these are intended to be replaced with the com.unity.xr.googlevr package. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !DISABLE_BUILTIN_INPUT_SYSTEM_GOOGLEVR && !UNITY_FORCE_INPUTSYSTEM_XR_OFF && !PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.XR; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs index 8267c728d5..9c8e0e65b5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs @@ -1,6 +1,5 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. +#if !DISABLE_BUILTIN_INPUT_SYSTEM_OCULUS // Docs generation is skipped because these are intended to be replaced with the com.unity.xr.oculus package. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !DISABLE_BUILTIN_INPUT_SYSTEM_OCULUS && !UNITY_FORCE_INPUTSYSTEM_XR_OFF && !PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs index c109b57989..a099be99fc 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs @@ -1,6 +1,5 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. +#if !DISABLE_BUILTIN_INPUT_SYSTEM_OPENVR // Docs generation is skipped because these are intended to be replaced with the com.unity.xr.openvr package. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !DISABLE_BUILTIN_INPUT_SYSTEM_OPENVR && !UNITY_FORCE_INPUTSYSTEM_XR_OFF && !PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs index d018cd5f0a..d8b3513e9f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs @@ -1,6 +1,5 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. +#if !DISABLE_BUILTIN_INPUT_SYSTEM_WINDOWSMR // Docs generation is skipped because these are intended to be replaced with the com.unity.xr.windowsmr package. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !DISABLE_BUILTIN_INPUT_SYSTEM_WINDOWSMR && !UNITY_FORCE_INPUTSYSTEM_XR_OFF && !PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.XR; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs index cfbbb51f0a..035cf38d36 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !UNITY_FORCE_INPUTSYSTEM_XR_OFF || PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.XR.Haptics; using UnityEngine.InputSystem.Layouts; @@ -100,7 +98,7 @@ public class XRController : TrackedDevice protected override void FinishSetup() { base.FinishSetup(); - +#if UNITY_INPUT_SYSTEM_ENABLE_XR var capabilities = description.capabilities; var deviceDescriptor = XRDeviceDescriptor.FromJson(capabilities); @@ -111,6 +109,7 @@ protected override void FinishSetup() else if ((deviceDescriptor.characteristics & InputDeviceCharacteristics.Right) != 0) InputSystem.SetDeviceUsage(this, CommonUsages.RightHand); } +#endif } } @@ -126,4 +125,3 @@ public void SendImpulse(float amplitude, float duration) } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/BufferedRumble.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/BufferedRumble.cs index 20bd60c591..cffe32f027 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/BufferedRumble.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/BufferedRumble.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION namespace UnityEngine.InputSystem.XR.Haptics { public struct BufferedRumble @@ -26,4 +24,3 @@ public void EnqueueRumble(byte[] samples) } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetCurrentHapticStateCommand.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetCurrentHapticStateCommand.cs index c246037db7..beb7531cb1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetCurrentHapticStateCommand.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetCurrentHapticStateCommand.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION using System.Runtime.InteropServices; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; @@ -47,4 +45,3 @@ public static GetCurrentHapticStateCommand Create() } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetHapticCapabilitiesCommand.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetHapticCapabilitiesCommand.cs index 670ccd158f..f1b49f4e0b 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetHapticCapabilitiesCommand.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/GetHapticCapabilitiesCommand.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION using System.Runtime.InteropServices; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; @@ -156,4 +154,3 @@ public static GetHapticCapabilitiesCommand Create() } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendBufferedHapticsCommand.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendBufferedHapticsCommand.cs index 577d38bbaf..cbea007992 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendBufferedHapticsCommand.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendBufferedHapticsCommand.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION using System.Runtime.InteropServices; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; @@ -53,4 +51,3 @@ public static SendBufferedHapticCommand Create(byte[] rumbleBuffer) } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendHapticImpulseCommand.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendHapticImpulseCommand.cs index e9985d9eca..8a979d2fef 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendHapticImpulseCommand.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Haptics/SendHapticImpulseCommand.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION using System.Runtime.InteropServices; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; @@ -50,4 +48,3 @@ public static SendHapticImpulseCommand Create(int motorChannel, float motorAmpli } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs index 3c3ef1aa31..b5715ba6e8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRLayoutBuilder.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !UNITY_FORCE_INPUTSYSTEM_XR_OFF using System; using System.Collections.Generic; using UnityEngine.InputSystem.LowLevel; @@ -90,7 +88,7 @@ internal static string OnFindLayoutForDevice(ref InputDeviceDescription descript { return null; } - +#if UNITY_INPUT_SYSTEM_ENABLE_XR if (string.IsNullOrEmpty(matchedLayout)) { const InputDeviceCharacteristics controllerCharacteristics = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Controller; @@ -99,7 +97,7 @@ internal static string OnFindLayoutForDevice(ref InputDeviceDescription descript else if ((deviceDescriptor.characteristics & controllerCharacteristics) == controllerCharacteristics) matchedLayout = "XRController"; } - +#endif string layoutName; if (string.IsNullOrEmpty(description.manufacturer)) { @@ -341,4 +339,3 @@ private InputControlLayout Build() } } } -#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs index bcf3818581..c58a0b7756 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs @@ -1,5 +1,3 @@ -// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. -#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) || PACKAGE_DOCS_GENERATION using System; using System.Collections.Generic; using UnityEngine.InputSystem.Layouts; @@ -104,7 +102,12 @@ public class XRDeviceDescriptor /// /// The capabilities of the device, used to help filter and identify devices that server a certain purpose (e.g. controller, or headset, or hardware tracker). /// +#if UNITY_INPUT_SYSTEM_ENABLE_XR public InputDeviceCharacteristics characteristics; +#else + [SerializeField] + private uint characteristics; +#endif /// /// The underlying deviceId, this can be used with to create a device. /// @@ -388,7 +391,7 @@ static class XRSupport /// public static void Initialize() { -#if !UNITY_FORCE_INPUTSYSTEM_XR_OFF +#if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !UNITY_FORCE_INPUTSYSTEM_XR_OFF InputSystem.RegisterLayout("Pose"); InputSystem.RegisterLayout("Bone"); InputSystem.RegisterLayout("Eyes"); @@ -506,4 +509,3 @@ public static void Initialize() } } } -#endif