Skip to content
Closed
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 @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed InputSystem.onAnyButtonPress fails to trigger when the device receives a touch [UUM-137930](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-137930).
- Fixed an incorrect ArraysHelper.HaveDuplicateReferences implementation that didn't use its arguments right [ISXB-1792] (https://github.com/Unity-Technologies/InputSystem/pull/2376)
- Fixed `InputAction.IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` using a `ButtonControl`'s `pressPoint` when a binding also had an explicit `PressInteraction` with its own `pressPoint`, which could make those APIs disagree with the interaction's press and release behavior. Action-level press APIs now follow the interaction threshold when both are set explicitly.
- Replaced deprecated `DEVELOPMENT_BUILD` and `UNITY_64` preprocessor directives flagged by the `UAC0008` / `UAC0009` analyzers on Unity 6000.6 (Package Validation rule `PVP-301-1`). `#if DEVELOPMENT_BUILD || UNITY_EDITOR` becomes `#if UNITY_EDITOR || DEBUG` (`DEBUG` is the modern managed-code-variant equivalent that's defined in development player builds), `#if UNITY_64` becomes a runtime `IntPtr.Size == 8` check. Also added `[NonSerialized]` on `HID.HIDLayoutBuilder.deviceType` and `HID.HIDElementDescriptor.usageMin` / `usageMax` to silence `UAC1001`. No behavioural change.

### Changed
- Action-level `IsPressed`, `WasPressedThisFrame`, and `WasReleasedThisFrame` for bindings to `Vector2Control` / `StickControl` no longer consult a per-control `pressPoint` on the vector (that field was removed). Use a `Press` interaction to set a custom threshold, or rely on `defaultButtonPressPoint`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ public struct ControlBuilder
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder At(InputDevice device, int index)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (device == null)
throw new ArgumentNullException(nameof(device));
if (index < 0 || index >= device.m_ChildrenForEachControl.Length)
Expand All @@ -1630,7 +1630,7 @@ public ControlBuilder At(InputDevice device, int index)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithParent(InputControl parent)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (parent == null)
throw new ArgumentNullException(nameof(parent));
if (parent == control)
Expand All @@ -1643,7 +1643,7 @@ public ControlBuilder WithParent(InputControl parent)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithName(string name)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException(nameof(name));
#endif
Expand All @@ -1654,7 +1654,7 @@ public ControlBuilder WithName(string name)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithDisplayName(string displayName)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(displayName))
throw new ArgumentNullException(nameof(displayName));
#endif
Expand All @@ -1665,7 +1665,7 @@ public ControlBuilder WithDisplayName(string displayName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithShortDisplayName(string shortDisplayName)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(shortDisplayName))
throw new ArgumentNullException(nameof(shortDisplayName));
#endif
Expand All @@ -1676,7 +1676,7 @@ public ControlBuilder WithShortDisplayName(string shortDisplayName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithLayout(InternedString layout)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (layout.IsEmpty())
throw new ArgumentException("Layout name cannot be empty", nameof(layout));
#endif
Expand All @@ -1687,7 +1687,7 @@ public ControlBuilder WithLayout(InternedString layout)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithUsages(int startIndex, int count)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (startIndex < 0 || startIndex >= control.device.m_UsagesForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (count < 0 || startIndex + count > control.device.m_UsagesForEachControl.Length)
Expand All @@ -1701,7 +1701,7 @@ public ControlBuilder WithUsages(int startIndex, int count)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithAliases(int startIndex, int count)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (startIndex < 0 || startIndex >= control.device.m_AliasesForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (count < 0 || startIndex + count > control.device.m_AliasesForEachControl.Length)
Expand All @@ -1715,7 +1715,7 @@ public ControlBuilder WithAliases(int startIndex, int count)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ControlBuilder WithChildren(int startIndex, int count)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (startIndex < 0 || startIndex >= control.device.m_ChildrenForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (count < 0 || startIndex + count > control.device.m_ChildrenForEachControl.Length)
Expand Down Expand Up @@ -1754,7 +1754,7 @@ public ControlBuilder WithProcessor<TProcessor, TValue>(TProcessor processor)
where TValue : struct
where TProcessor : InputProcessor<TValue>
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (processor == null)
throw new ArgumentNullException(nameof(processor));
#endif
Expand Down Expand Up @@ -1808,7 +1808,7 @@ public struct DeviceBuilder
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithName(string name)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException(nameof(name));
#endif
Expand All @@ -1819,7 +1819,7 @@ public DeviceBuilder WithName(string name)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithDisplayName(string displayName)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(displayName))
throw new ArgumentNullException(nameof(displayName));
#endif
Expand All @@ -1830,7 +1830,7 @@ public DeviceBuilder WithDisplayName(string displayName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithShortDisplayName(string shortDisplayName)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (string.IsNullOrEmpty(shortDisplayName))
throw new ArgumentNullException(nameof(shortDisplayName));
#endif
Expand All @@ -1841,7 +1841,7 @@ public DeviceBuilder WithShortDisplayName(string shortDisplayName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithLayout(InternedString layout)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (layout.IsEmpty())
throw new ArgumentException("Layout name cannot be empty", nameof(layout));
#endif
Expand All @@ -1852,7 +1852,7 @@ public DeviceBuilder WithLayout(InternedString layout)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithChildren(int startIndex, int count)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (startIndex < 0 || startIndex >= device.device.m_ChildrenForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(startIndex));
if (count < 0 || startIndex + count > device.device.m_ChildrenForEachControl.Length)
Expand Down Expand Up @@ -1880,7 +1880,7 @@ public DeviceBuilder IsNoisy(bool value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithControlUsage(int controlIndex, InternedString usage, InputControl control)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (controlIndex < 0 || controlIndex >= device.m_UsagesForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(controlIndex));
if (usage.IsEmpty())
Expand All @@ -1896,7 +1896,7 @@ public DeviceBuilder WithControlUsage(int controlIndex, InternedString usage, In
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DeviceBuilder WithControlAlias(int controlIndex, InternedString alias)
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
if (controlIndex < 0 || controlIndex >= device.m_AliasesForEachControl.Length)
throw new ArgumentOutOfRangeException(nameof(controlIndex));
if (alias.IsEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace UnityEngine.InputSystem
/// </remarks>
/// <typeparam name="TControl">Type of <see cref="InputControl"/> to store in the list.</typeparam>
[DebuggerDisplay("Count = {Count}")]
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
[DebuggerTypeProxy(typeof(InputControlListDebugView<>))]
#endif
public unsafe struct InputControlList<TControl> : IList<TControl>, IReadOnlyList<TControl>, IDisposable
Expand Down Expand Up @@ -597,7 +597,7 @@ public void Dispose()
}
}

#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
internal struct InputControlListDebugView<TControl>
where TControl : InputControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ private static TData DeserializeData<TData>(byte[] data)
return JsonUtility.FromJson<TData>(json);
}

#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
// State we want to take across domain reloads. We can only take some of the
// state across. Subscriptions will be lost and have to be manually restored.
[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ internal void AdvanceToNextEvent(ref InputEvent* currentReadPos,
if (numRemainingEvents > 1)
{
// Don't perform safety check in non-debug builds.
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
newReadPos = InputEvent.GetNextInMemoryChecked(currentReadPos, ref this);
#else
newReadPos = InputEvent.GetNextInMemory(currentReadPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4481,7 +4481,7 @@ private bool FlipBuffersForDeviceIfNecessary(InputDevice device, InputUpdateType

// Stuff everything that we want to survive a domain reload into
// a m_SerializedState.
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
[Serializable]
internal struct DeviceState
{
Expand Down Expand Up @@ -4795,6 +4795,6 @@ private bool RestoreDeviceFromSavedState(ref DeviceState deviceState, InternedSt
return true;
}

#endif // UNITY_EDITOR || DEVELOPMENT_BUILD
#endif // UNITY_EDITOR || DEBUG
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3366,7 +3366,7 @@ public static bool runInBackground
internal static InputManager s_Manager;
internal static InputRemoting s_Remote;

#if DEVELOPMENT_BUILD || UNITY_EDITOR
#if UNITY_EDITOR || DEBUG
private static RemoteInputPlayerConnection s_RemoteConnection;

internal static RemoteInputPlayerConnection remoteConnection
Expand Down Expand Up @@ -3411,7 +3411,7 @@ private static bool ShouldEnableRemoting()
}

#endif //!UNITY_EDITOR
#endif // DEVELOPMENT_BUILD || UNITY_EDITOR
#endif // UNITY_EDITOR || DEBUG

// The rest here is internal stuff to manage singletons, survive domain reloads,
// and to support the reset ability for tests.
Expand Down Expand Up @@ -3506,7 +3506,7 @@ internal static void InitializeInPlayer(IInputRuntime runtime = null, bool loadS
#endif

// Automatically enable remoting in development players.
#if DEVELOPMENT_BUILD
#if !UNITY_EDITOR && DEBUG
if (ShouldEnableRemoting())
SetUpRemoting();
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace UnityEngine.InputSystem
{
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#if UNITY_EDITOR || DEBUG
/// <summary>
/// Snapshot of the state used by the input system.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private static void OnBeforeDomainReload()

#endif

[Conditional("DEVELOPMENT_BUILD")]
[Conditional("DEBUG")]
[Conditional("UNITY_EDITOR")]
internal static void CheckEnabled()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private class HIDLayoutBuilder
public string displayName;
public HIDDeviceDescriptor hidDescriptor;
public string parentLayout;
public Type deviceType;
[NonSerialized] public Type deviceType;

public InputControlLayout Build()
{
Expand Down Expand Up @@ -517,8 +517,8 @@ public struct HIDElementDescriptor
public HIDElementFlags flags;

// Fields only relevant to arrays.
public int? usageMin;
public int? usageMax;
[NonSerialized] public int? usageMin;
[NonSerialized] public int? usageMax;

public bool hasNullState => (flags & HIDElementFlags.NullState) == HIDElementFlags.NullState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private bool IsDeviceUsableWithPlayerActions(InputDevice device)

private void ValidateInputActionAsset()
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
#if UNITY_EDITOR || DEBUG
if (m_PlayerPrefab == null || m_PlayerPrefab.GetComponentInChildren<PlayerInput>() == null)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private static void MigrateDoubleBuffer(DoubleBuffers newBuffer, InputDevice[] d
// NOTE: This also means that device indices of
if (device.m_StateBlock.byteOffset == InputStateBlock.InvalidOffset)
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
#if UNITY_EDITOR || DEBUG
for (var n = i + 1; n < deviceCount; ++n)
Debug.Assert(devices[n].m_StateBlock.byteOffset == InputStateBlock.InvalidOffset,
"New devices must be appended to the array; found an old device coming in the array after a newly added device");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,17 @@

unchecked
{
// 64bit blocks.
#if UNITY_64
while (numBytes >= 8)
// 64bit blocks (only on 64-bit runtimes; JIT folds the branch).
if (IntPtr.Size == 8)
{
*(ulong*)&to[pos] = ((ulong)value << 56) | ((ulong)value << 48) | ((ulong)value << 40) | ((ulong)value << 32)
| ((ulong)value << 24) | ((ulong)value << 16) | ((ulong)value << 8) | value;
numBytes -= 8;
pos += 8;
while (numBytes >= 8)
{
*(ulong*)&to[pos] = ((ulong)value << 56) | ((ulong)value << 48) | ((ulong)value << 40) | ((ulong)value << 32)

Check warning on line 249 in Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/MemoryHelpers.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/MemoryHelpers.cs#L248-L249

Added lines #L248 - L249 were not covered by tests
| ((ulong)value << 24) | ((ulong)value << 16) | ((ulong)value << 8) | value;
numBytes -= 8;
pos += 8;
}

Check warning on line 253 in Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/MemoryHelpers.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Runtime/Utilities/MemoryHelpers.cs#L251-L253

Added lines #L251 - L253 were not covered by tests
Comment on lines +247 to +253
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Have you considered hoisting the 64-bit fill value calculation outside of the while loop? Since value is loop-invariant, calculating it once before the loop avoids redundant bit-shifting and bitwise operations on every iteration. This can significantly improve performance when filling larger buffers.

🤖 Helpful? 👍/👎 by guardian

}
#endif

// 32bit blocks.
while (numBytes >= 4)
Expand Down Expand Up @@ -287,16 +288,17 @@

unchecked
{
// Copy 64bit blocks.
#if UNITY_64
while (numBytes >= 8)
// Copy 64bit blocks (only on 64-bit runtimes; JIT folds the branch).
if (IntPtr.Size == 8)
{
*(ulong*)(to + pos) &= ~*(ulong*)(bits + pos); // Preserve unmasked bits.
*(ulong*)(to + pos) |= *(ulong*)(from + pos) & *(ulong*)(bits + pos); // Copy masked bits.
numBytes -= 8;
pos += 8;
while (numBytes >= 8)
{
*(ulong*)(to + pos) &= ~*(ulong*)(bits + pos); // Preserve unmasked bits.
*(ulong*)(to + pos) |= *(ulong*)(from + pos) & *(ulong*)(bits + pos); // Copy masked bits.
numBytes -= 8;
pos += 8;
}
}
#endif

// Copy 32bit blocks.
while (numBytes >= 4)
Expand Down
Loading