Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
### Changed
- 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.

### 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1931,12 +1931,7 @@ public void Finish()
}

device.m_ButtonControlsCheckingPressState = new List<ButtonControl>(i);
#if UNITY_2020_1_OR_NEWER
device.m_UpdatedButtons = new HashSet<int>(i);
#else
// 2019 is too old to support setting HashSet capacity
device.m_UpdatedButtons = new HashSet<int>();
#endif

device.isSetupFinished = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ public InputDevice Finish()
}

device.m_ButtonControlsCheckingPressState = new List<ButtonControl>(i);
#if UNITY_2020_1_OR_NEWER
device.m_UpdatedButtons = new HashSet<int>(i);
#else
// 2019 is too old to support setting HashSet capacity
device.m_UpdatedButtons = new HashSet<int>();
#endif

// Kill off our state.
Reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,8 @@ private static void Process(string[] assets, ICollection<string> target)
}
}

// Note: Callback prior to Unity 2021.2 did not provide a boolean indicating domain relaod.
#if UNITY_2021_2_OR_NEWER
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
#else
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromAssetPaths)
#endif
{
Process(importedAssets, s_Imported);
Process(deletedAssets, s_Deleted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
using System.IO;
using System.Linq;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif
using UnityEngine.InputSystem.Utilities;

////FIXME: The importer accesses icons through the asset db (which EditorGUIUtility.LoadIcon falls back on) which will
Expand Down Expand Up @@ -381,14 +377,8 @@ private static bool ContainsInputActionAssetPath(string[] assetPaths)
// the name will no longer be a mismatch and the cycle will be aborted.
private class InputActionJsonNameModifierAssetProcessor : AssetPostprocessor
{
// Note: Callback prior to Unity 2021.2 did not provide a boolean indicating domain relaod.
#if UNITY_2021_2_OR_NEWER
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
#else
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromAssetPaths)
#endif
{
var needToInvalidate = false;
foreach (var assetPath in importedAssets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using System.IO;
using UnityEngine.InputSystem.Utilities;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif

////TODO: support for multi-editing

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR && UNITY_2021_1_OR_NEWER
#if UNITY_EDITOR

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_EDITOR && UNITY_2020_2_OR_NEWER
#if UNITY_EDITOR
using System;
using System.Collections.ObjectModel;
using UnityEditor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if ((UNITY_EDITOR && UNITY_2021_1_OR_NEWER) || PACKAGE_DOCS_GENERATION)
#if (UNITY_EDITOR || PACKAGE_DOCS_GENERATION)
using System;
using System.Collections.Generic;
using UnityEditor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ internal static bool SaveAsset(string assetPath, string text)
// Maps path into a physical path.
public static string GetPhysicalPath(string path)
{
// Note that we can only get physical path for 2021.2 or newer
#if UNITY_2021_2_OR_NEWER
return FileUtil.GetPhysicalPath(path);
#else
return path;
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class ProjectSettingsPostprocessor : AssetPostprocessor
{
private static bool migratedInputActionAssets = false;

#if UNITY_2021_2_OR_NEWER
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
#else
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
#endif
{
if (!migratedInputActionAssets && importedAssets.Contains(kAssetPathInputManager))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@ public static bool newSystemBackendsEnabled
{
get
{
#if UNITY_2020_2_OR_NEWER
var property = GetPropertyOrNull(kActiveInputHandler);
return property == null || ActiveInputHandlerToTuple(property.intValue).newSystemEnabled;
#else
var property = GetPropertyOrNull(kEnableNewSystemProperty);
return property == null || property.boolValue;
#endif
}
set
{
#if UNITY_2020_2_OR_NEWER
var property = GetPropertyOrNull(kActiveInputHandler);
if (property != null)
{
Expand All @@ -43,18 +37,6 @@ public static bool newSystemBackendsEnabled
{
Debug.LogError($"Cannot find '{kActiveInputHandler}' in player settings");
}
#else
var property = GetPropertyOrNull(kEnableNewSystemProperty);
if (property != null)
{
property.boolValue = value;
property.serializedObject.ApplyModifiedProperties();
}
else
{
Debug.LogError($"Cannot find '{kEnableNewSystemProperty}' in player settings");
}
#endif
}
}

Expand All @@ -66,17 +48,11 @@ public static bool oldSystemBackendsEnabled
{
get
{
#if UNITY_2020_2_OR_NEWER
var property = GetPropertyOrNull(kActiveInputHandler);
return property == null || ActiveInputHandlerToTuple(property.intValue).oldSystemEnabled;
#else
var property = GetPropertyOrNull(kDisableOldSystemProperty);
return property == null || !property.boolValue;
#endif
}
set
{
#if UNITY_2020_2_OR_NEWER
var property = GetPropertyOrNull(kActiveInputHandler);
if (property != null)
{
Expand All @@ -89,23 +65,9 @@ public static bool oldSystemBackendsEnabled
{
Debug.LogError($"Cannot find '{kActiveInputHandler}' in player settings");
}
#else
var property = GetPropertyOrNull(kDisableOldSystemProperty);
if (property != null)
{
property.boolValue = !value;
property.serializedObject.ApplyModifiedProperties();
}
else
{
Debug.LogError($"Cannot find '{kDisableOldSystemProperty}' in player settings");
}
#endif
}
}


#if UNITY_2020_2_OR_NEWER
private const string kActiveInputHandler = "activeInputHandler";

private enum InputHandler
Expand Down Expand Up @@ -152,11 +114,6 @@ private static int TupleToActiveInputHandler((bool newSystemEnabled, bool oldSys
}
}

#else
private const string kEnableNewSystemProperty = "enableNativePlatformBackendsForNewInputSystem";
private const string kDisableOldSystemProperty = "disableOldInputManagerSupport";
#endif

private static SerializedProperty GetPropertyOrNull(string name)
{
#if UNITY_6000_0_OR_NEWER
Expand Down
6 changes: 0 additions & 6 deletions Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
using Unity.Profiling;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.Scripting;
#if UNITY_2021_2_OR_NEWER
using UnityEngine.Pool;
#endif

// HID support is currently broken in 32-bit Windows standalone players. Consider 32bit Windows players unsupported for now.
#if UNITY_STANDALONE_WIN && !UNITY_64
Expand Down Expand Up @@ -980,7 +978,6 @@ public string ToJson()

public static HIDDeviceDescriptor FromJson(string json)
{
#if UNITY_2021_2_OR_NEWER
try
{
// HID descriptors, when formatted correctly, are always json strings with no whitespace and a
Expand Down Expand Up @@ -1138,9 +1135,6 @@ public static HIDDeviceDescriptor FromJson(string json)
k_HIDParseDescriptorFallback.End();
return descriptor;
}
#else
return JsonUtility.FromJson<HIDDeviceDescriptor>(json);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ public override string ToString()
stringBuilder.AppendLine("pressPosition: " + pressPosition);
stringBuilder.AppendLine("trackedDevicePosition: " + trackedDevicePosition);
stringBuilder.AppendLine("trackedDeviceOrientation: " + trackedDeviceOrientation);
#if UNITY_2021_1_OR_NEWER
stringBuilder.AppendLine("pressure" + pressure);
stringBuilder.AppendLine("radius: " + radius);
stringBuilder.AppendLine("azimuthAngle: " + azimuthAngle);
stringBuilder.AppendLine("altitudeAngle: " + altitudeAngle);
stringBuilder.AppendLine("twist: " + twist);
#endif
#if UNITY_2022_3_OR_NEWER
stringBuilder.AppendLine("displayIndex: " + displayIndex);
#endif
Expand Down Expand Up @@ -136,34 +134,28 @@ internal void ReadDeviceState()
if (control.parent is Pen pen)
{
uiToolkitPointerId = GetPenPointerId(pen);
#if UNITY_2021_1_OR_NEWER
pressure = pen.pressure.magnitude;
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;
#endif
#if UNITY_2022_3_OR_NEWER
displayIndex = pen.displayIndex.ReadValue();
#endif
}
else if (control.parent is TouchControl touchControl)
{
uiToolkitPointerId = GetTouchPointerId(touchControl);
#if UNITY_2021_1_OR_NEWER
pressure = touchControl.pressure.magnitude;
radius = touchControl.radius.value;
#endif
#if UNITY_2022_3_OR_NEWER
displayIndex = touchControl.displayIndex.ReadValue();
#endif
}
else if (control.parent is Touchscreen touchscreen)
{
uiToolkitPointerId = GetTouchPointerId(touchscreen.primaryTouch);
#if UNITY_2021_1_OR_NEWER
pressure = touchscreen.pressure.magnitude;
radius = touchscreen.radius.value;
#endif
#if UNITY_2022_3_OR_NEWER
displayIndex = touchscreen.displayIndex.ReadValue();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ private void ProcessPointerMovement(ref PointerModel pointer, ExtendedPointerEve

private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObject currentPointerTarget)
{
#if UNITY_2021_1_OR_NEWER
// If the pointer moved, send move events to all UI elements the pointer is
// currently over.
var wasMoved = eventData.IsPointerMoving();
Expand All @@ -540,7 +539,6 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje
for (var i = 0; i < eventData.hovered.Count; ++i)
ExecuteEvents.Execute(eventData.hovered[i], eventData, ExecuteEvents.pointerMoveHandler);
}
#endif

// If we have no target or pointerEnter has been deleted,
// we just send exit events to anything we are tracking
Expand Down Expand Up @@ -615,10 +613,8 @@ private void ProcessPointerMovement(ExtendedPointerEventData eventData, GameObje
#endif

ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerEnterHandler);
#if UNITY_2021_1_OR_NEWER
if (wasMoved)
ExecuteEvents.Execute(current.gameObject, eventData, ExecuteEvents.pointerMoveHandler);
#endif
eventData.hovered.Add(current.gameObject);

// stop when encountering an object with the pointerEnterHandler
Expand Down Expand Up @@ -689,9 +685,7 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
// Set pointerPress. This nukes lastPress. Meaning that after OnPointerDown, lastPress will
// become null.
eventData.pointerPress = newPressed;
#if UNITY_2020_1_OR_NEWER // pointerClick doesn't exist before this.
eventData.pointerClick = pointerClickHandler;
#endif
eventData.rawPointerPress = currentOverGo;

// Save the drag handler for drag events during this mouse down.
Expand All @@ -712,11 +706,7 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
// 2) StandaloneInputModule increases click counts even if something is eventually not deemed a
// click and OnPointerClick is thus never invoked.
var pointerClickHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(currentOverGo);
#if UNITY_2020_1_OR_NEWER
var isClick = eventData.pointerClick != null && eventData.pointerClick == pointerClickHandler && eventData.eligibleForClick;
#else
var isClick = eventData.pointerPress != null && eventData.pointerPress == pointerClickHandler && eventData.eligibleForClick;
#endif
if (isClick)
{
// Count clicks.
Expand All @@ -740,11 +730,7 @@ private void ProcessPointerButton(ref PointerModel.ButtonState button, PointerEv
// Invoke OnPointerClick or OnDrop.
if (isClick)
{
#if UNITY_2020_1_OR_NEWER
ExecuteEvents.Execute(eventData.pointerClick, eventData, ExecuteEvents.pointerClickHandler);
#else
ExecuteEvents.Execute(eventData.pointerPress, eventData, ExecuteEvents.pointerClickHandler);
#endif
}
else if (eventData.dragging && eventData.pointerDrag != null)
ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
Expand Down Expand Up @@ -2453,7 +2439,6 @@ public override void Process()
}
}

#if UNITY_2021_1_OR_NEWER
public override int ConvertUIToolkitPointerId(PointerEventData sourcePointerData)
{
// Case 1369081: when using SingleUnifiedPointer, the same (default) pointerId should be sent to UIToolkit
Expand All @@ -2466,8 +2451,6 @@ public override int ConvertUIToolkitPointerId(PointerEventData sourcePointerData
: base.ConvertUIToolkitPointerId(sourcePointerData);
}

#endif

#if UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA
const float kSmallestScrollDeltaPerTick = 0.00001f;
public override Vector2 ConvertPointerEventScrollDeltaToTicks(Vector2 scrollDelta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,11 @@ public void OnFrameFinished()

public void CopyTouchOrPenStateFrom(PointerEventData eventData)
{
#if UNITY_2021_1_OR_NEWER
pressure = eventData.pressure;
azimuthAngle = eventData.azimuthAngle;
altitudeAngle = eventData.altitudeAngle;
twist = eventData.twist;
radius = eventData.radius;
#endif
}

// State related to pressing and releasing individual bodies. Retains those parts of
Expand Down
Loading