diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index a771fcba2f..a0c863fce2 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -14,6 +14,7 @@ however, it has to be formatted properly to pass verification tests. - Replaced "Look" rebinding button for "Keyboard" control scheme with a mouse sensitivity slider in `RebindingUISample` to illustrate how to support customizing scaling of mouse deltas and how to reapply the persisted setting between runs. - Changed: Input System no longer depends the obsolete com.unity.modules.vr package. - Removed code that had to do with Unity versions older than Unity 2021.3 LTS. +- Removed code that had to do with Unity versions older than Unity 2022.3 LTS. ### Added - Added an example of how to swap two similar controls to the `RebindingUISample`. This is accessible via a button with two arrows at the right hand-side of the screen. Pressing the button allows swapping the current bindings of the "Move" and "Look" gamepad bindings via the new `RebindActionUI.SwapBinding(RebindActionUI other)` method. diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/DeviceSimulator/InputSystemPlugin.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/DeviceSimulator/InputSystemPlugin.cs index 39de5482ad..a15ee4799c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/DeviceSimulator/InputSystemPlugin.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/DeviceSimulator/InputSystemPlugin.cs @@ -12,7 +12,6 @@ internal class InputSystemPlugin : DeviceSimulatorPlugin internal Touchscreen SimulatorTouchscreen; private bool m_InputSystemEnabled; - private bool m_Quitting; private List m_DisabledDevices; public override string title => "Input System"; @@ -22,9 +21,6 @@ public override void OnCreate() m_InputSystemEnabled = EditorPlayerSettingHelpers.newSystemBackendsEnabled; if (m_InputSystemEnabled) { - // Monitor whether the editor is quitting to avoid risking unsafe EnableDevice while quitting - UnityEditor.EditorApplication.quitting += OnQuitting; - m_DisabledDevices = new List(); // deviceSimulator is never null when the plugin is instantiated by a simulator window, but it can be null during unit tests @@ -99,27 +95,15 @@ public override void OnDestroy() deviceSimulator.touchScreenInput -= OnTouchEvent; InputSystem.onDeviceChange -= OnDeviceChange; - UnityEditor.EditorApplication.quitting -= OnQuitting; - if (SimulatorTouchscreen != null) InputSystem.RemoveDevice(SimulatorTouchscreen); foreach (var device in m_DisabledDevices) { - // Note that m_Quitting is used here to mitigate the problem reported in issue tracker: - // https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-10774. - // Enabling a device will call into IOCTL of backend which will (may) be destroyed prior - // to this callback on Unity version <= 2022.2. This is not a fix for the actual problem - // of shutdown order but a package fix to mitigate this problem. - if (device.added && !m_Quitting) + if (device.added) InputSystem.EnableDevice(device); } } } - - private void OnQuitting() - { - m_Quitting = true; - } } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs index 78e01768e1..12f4c961c9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/InputSystemPluginControl.cs @@ -37,12 +37,8 @@ private static void CheckForExtension() BuildTarget.tvOS, BuildTarget.LinuxHeadlessSimulation, BuildTarget.EmbeddedLinux, - #if UNITY_2022_1_OR_NEWER BuildTarget.QNX, - #endif - #if UNITY_2022_3_OR_NEWER BuildTarget.VisionOS, - #endif (BuildTarget)49, BuildTarget.NoTarget }; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs index 736d65b34a..f36f79f49a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs @@ -94,9 +94,7 @@ public override string ToString() stringBuilder.AppendLine("azimuthAngle: " + azimuthAngle); stringBuilder.AppendLine("altitudeAngle: " + altitudeAngle); stringBuilder.AppendLine("twist: " + twist); - #if UNITY_2022_3_OR_NEWER stringBuilder.AppendLine("displayIndex: " + displayIndex); - #endif return stringBuilder.ToString(); } @@ -138,27 +136,21 @@ internal void ReadDeviceState() azimuthAngle = (pen.tilt.value.x + 1) * Mathf.PI / 2; altitudeAngle = (pen.tilt.value.y + 1) * Mathf.PI / 2; twist = pen.twist.value * Mathf.PI * 2; - #if UNITY_2022_3_OR_NEWER displayIndex = pen.displayIndex.ReadValue(); - #endif } else if (control.parent is TouchControl touchControl) { uiToolkitPointerId = GetTouchPointerId(touchControl); pressure = touchControl.pressure.magnitude; radius = touchControl.radius.value; - #if UNITY_2022_3_OR_NEWER displayIndex = touchControl.displayIndex.ReadValue(); - #endif } else if (control.parent is Touchscreen touchscreen) { uiToolkitPointerId = GetTouchPointerId(touchscreen.primaryTouch); pressure = touchscreen.pressure.magnitude; radius = touchscreen.radius.value; - #if UNITY_2022_3_OR_NEWER displayIndex = touchscreen.displayIndex.ReadValue(); - #endif } else { diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs index b2e06a010a..096bbe33e3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs @@ -579,9 +579,8 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje if (!sendPointerHoverToParent && current == pointerParent) break; -#if UNITY_2021_3_OR_NEWER eventData.fullyExited = current != commonRoot && eventData.pointerEnter != currentPointerTarget; -#endif + ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerExitHandler); eventData.hovered.Remove(current.gameObject); @@ -605,12 +604,10 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje Transform current = currentPointerTarget.transform; while (current != null && !PointerShouldIgnoreTransform(current)) { -#if UNITY_2021_3_OR_NEWER eventData.reentered = current == commonRoot && current != oldPointerEnter; // if we are sending the event to parent, they are already in hover mode at that point. No need to bubble up the event. if (sendPointerHoverToParent && eventData.reentered) break; -#endif ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerEnterHandler); if (wasMoved) @@ -1926,9 +1923,7 @@ private int GetPointerStateIndexFor(InputControl control, bool createIfNotExists eventData.pointerType = pointerType; eventData.pointerId = pointerId; eventData.touchId = touchId; -#if UNITY_2022_3_OR_NEWER eventData.displayIndex = displayIndex; -#endif // Make sure these don't linger around when we switch to a different kind of pointer. eventData.trackedDeviceOrientation = default; @@ -2031,9 +2026,7 @@ private int AllocatePointer(int pointerId, int displayIndex, int touchId, UIPoin eventData = new ExtendedPointerEventData(eventSystem); eventData.pointerId = pointerId; -#if UNITY_2022_3_OR_NEWER eventData.displayIndex = displayIndex; -#endif eventData.touchId = touchId; eventData.pointerType = pointerType; eventData.control = control; @@ -2164,9 +2157,7 @@ private void OnPointCallback(InputAction.CallbackContext context) ref var state = ref GetPointerStateForIndex(index); state.screenPosition = context.ReadValue(); -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } // NOTE: In the click events, we specifically react to the Canceled phase to make sure we do NOT perform @@ -2195,9 +2186,7 @@ private void OnLeftClickCallback(InputAction.CallbackContext context) state.changedThisFrame = true; if (IgnoreNextClick(ref context, wasPressed)) state.leftButton.ignoreNextClick = true; -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private void OnRightClickCallback(InputAction.CallbackContext context) @@ -2212,9 +2201,7 @@ private void OnRightClickCallback(InputAction.CallbackContext context) state.changedThisFrame = true; if (IgnoreNextClick(ref context, wasPressed)) state.rightButton.ignoreNextClick = true; -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private void OnMiddleClickCallback(InputAction.CallbackContext context) @@ -2229,9 +2216,7 @@ private void OnMiddleClickCallback(InputAction.CallbackContext context) state.changedThisFrame = true; if (IgnoreNextClick(ref context, wasPressed)) state.middleButton.ignoreNextClick = true; -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private bool CheckForRemovedDevice(ref InputAction.CallbackContext context) @@ -2261,9 +2246,7 @@ private void OnScrollCallback(InputAction.CallbackContext context) // ISXB-704: convert input value to BaseInputModule convention. state.scrollDelta = (scrollDelta / InputSystem.scrollWheelDeltaPerTick) * scrollDeltaPerTick; -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private void OnMoveCallback(InputAction.CallbackContext context) @@ -2286,9 +2269,7 @@ private void OnTrackedDeviceOrientationCallback(InputAction.CallbackContext cont ref var state = ref GetPointerStateForIndex(index); state.worldOrientation = context.ReadValue(); -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context) @@ -2299,9 +2280,7 @@ private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context ref var state = ref GetPointerStateForIndex(index); state.worldPosition = context.ReadValue(); -#if UNITY_2022_3_OR_NEWER state.eventData.displayIndex = GetDisplayIndexFor(context.control); -#endif } private void OnControlsChanged(object obj) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs index ed5e870044..5161b35857 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XInput/XboxGamepadMacOS.cs @@ -127,12 +127,6 @@ public enum Button RightThumbstickPress = 15, } - // IL2CPP on 2021 doesn't respect the FieldOffsets - as such, we need some padding fields -#if UNITY_2021 && ENABLE_IL2CPP - [FieldOffset(0)] - private uint padding; -#endif - [InputControl(name = "buttonSouth", bit = (uint)Button.A, displayName = "A")] [InputControl(name = "buttonEast", bit = (uint)Button.B, displayName = "B")] [InputControl(name = "buttonWest", bit = (uint)Button.X, displayName = "X")] @@ -154,20 +148,9 @@ public enum Button [InputControl(name = "leftTrigger", format = "BYTE")] [FieldOffset(6)] public byte leftTrigger; -#if UNITY_2021 && ENABLE_IL2CPP - [FieldOffset(7)] - private byte triggerPadding; -#endif - [InputControl(name = "rightTrigger", format = "BYTE")] [FieldOffset(8)] public byte rightTrigger; -#if UNITY_2021 && ENABLE_IL2CPP - [FieldOffset(9)] - private byte triggerPadding2; -#endif - - [InputControl(name = "leftStick", layout = "Stick", format = "VC2S")] [InputControl(name = "leftStick/x", offset = 0, format = "SHRT", parameters = "")] [InputControl(name = "leftStick/left", offset = 0, format = "SHRT", parameters = "")] diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs index affde24152..54d24cad9f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs @@ -587,26 +587,26 @@ protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRota var positionValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Position) != 0; var rotationValid = m_IgnoreTrackingState || (m_CurrentTrackingState & TrackingStates.Rotation) != 0; -#if HAS_SET_LOCAL_POSITION_AND_ROTATION - if (m_TrackingType == TrackingType.RotationAndPosition && rotationValid && positionValid) + switch (m_TrackingType) { - transform.SetLocalPositionAndRotation(newPosition, newRotation); - return; - } -#endif - - if (rotationValid && - (m_TrackingType == TrackingType.RotationAndPosition || - m_TrackingType == TrackingType.RotationOnly)) - { - transform.localRotation = newRotation; - } - - if (positionValid && - (m_TrackingType == TrackingType.RotationAndPosition || - m_TrackingType == TrackingType.PositionOnly)) - { - transform.localPosition = newPosition; + case TrackingType.RotationAndPosition: + if (rotationValid && positionValid) + transform.SetLocalPositionAndRotation(newPosition, newRotation); + else if (rotationValid) + transform.localRotation = newRotation; + else if (positionValid) + transform.localPosition = newPosition; + break; + + case TrackingType.PositionOnly: + if (positionValid) + transform.localPosition = newPosition; + break; + + case TrackingType.RotationOnly: + if (rotationValid) + transform.localRotation = newRotation; + break; } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef b/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef index bd5b6f0af4..253ad9c2f9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef +++ b/Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef @@ -52,21 +52,6 @@ "expression": "1.0.0", "define": "UNITY_INPUT_SYSTEM_ENABLE_UI" }, - { - "name": "Unity", - "expression": "[2021.3.11,2022.1)", - "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" - }, - { - "name": "Unity", - "expression": "[2022.1.19,2022.2)", - "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" - }, - { - "name": "Unity", - "expression": "2022.2", - "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" - }, { "name": "Unity", "expression": "2022.3",