Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauliusd01 committed Oct 16, 2024
2 parents 684a284 + db7b26f commit c851869
Show file tree
Hide file tree
Showing 37 changed files with 655 additions and 342 deletions.
2 changes: 1 addition & 1 deletion Assets/Samples/InGameHints/InGameHintsActions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.11.1
// version 1.11.2
// from Assets/Samples/InGameHints/InGameHintsActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
2 changes: 1 addition & 1 deletion Assets/Samples/SimpleDemo/SimpleControls.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.11.1
// version 1.11.2
// from Assets/Samples/SimpleDemo/SimpleControls.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
49 changes: 49 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Analytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,55 @@ public void Analytics_ShouldReportPlayerInputManagerData()
}
}

[Test]
[Category("Analytics")]
public void Analytics_ShouldReportCodeAuthoringAnalytic()
{
CollectAnalytics(InputExitPlayModeAnalytic.kEventName);

// NOTE: We do not want to trigger entering/exiting play-mode for this small data-sanity check
// so just stick to triggering it explicitly. A better test would have been an editor test
// going in and out of play-mode for real but not clear if this is really possible.

// Pretend we are entering play-mode
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);

// Assert no data received
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(0));

// Pretend we are exiting play-mode
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);

// Assert: Data received
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(1));
Assert.That(sentAnalyticsEvents[0].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
Assert.That(sentAnalyticsEvents[0].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());

var data0 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[0].data;
Assert.That(data0.uses_code_authoring, Is.False);

// Pretend we are entering play-mode
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);

var action = new InputAction("Dance");
action.AddBinding("<Keyboard>/Space");

// Pretend we are exiting play-mode
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);

// Assert: Data received
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(2));
Assert.That(sentAnalyticsEvents[1].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
Assert.That(sentAnalyticsEvents[1].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());

var data1 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[1].data;
Assert.That(data1.uses_code_authoring, Is.True);
}

#if UNITY_INPUT_SYSTEM_ENABLE_UI
[Test]
[Category("Analytics")]
Expand Down
41 changes: 34 additions & 7 deletions Assets/Tests/InputSystem/CoreTests_Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4162,13 +4162,40 @@ public void Devices_RemovingAndReaddingDevice_DoesNotAllocateMemory()
recorder.CollectFromAllThreads();
#endif

// We expect a single allocation for each call to ReportNewInputDevice when there is one disconnected device
//
int numberOfRepeats = 2;
int numberOfDisconnectedDevices = 1;
int numberOfCallsToReportNewInputDevicePerRun = 2;
int expectedAllocations = numberOfRepeats * numberOfDisconnectedDevices * numberOfCallsToReportNewInputDevicePerRun;
Assert.AreEqual(expectedAllocations, recorder.sampleBlockCount);
// No allocations are expected.
Assert.AreEqual(0, recorder.sampleBlockCount);
}

// Regression test to cover having null descriptor fields for a device. Some non-desktop gamepad device types do this.
[Test]
[Category("Devices")]
public void Devices_RemovingAndReaddingDeviceWithNullDescriptorFields_DoesNotThrow()
{
// InputDeviceDescription.ToJson writes empty string fields and not null values, whereas reporting a device via an incomplete description string will fully omit the fields.
string description = @"{
""type"": ""Gamepad"",
""product"": ""TestProduct""
}";

var deviceId = runtime.ReportNewInputDevice(description);
InputSystem.Update();

// "Unplug" device.
var removeEvent1 = DeviceRemoveEvent.Create(deviceId);
InputSystem.QueueEvent(ref removeEvent1);
InputSystem.Update();

// "Plug" it back in.
deviceId = runtime.ReportNewInputDevice(description);
InputSystem.Update();

// Repeat that sequence.
var removeEvent2 = DeviceRemoveEvent.Create(deviceId);
InputSystem.QueueEvent(ref removeEvent2);
InputSystem.Update();

runtime.ReportNewInputDevice(description);
InputSystem.Update();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.11.1
// version 1.11.2
// from Assets/Tests/InputSystem/InputActionCodeGeneratorActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand Down
21 changes: 21 additions & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Due to package verification, the latest version below is the unpublished version and the date is meaningless.
however, it has to be formatted properly to pass verification tests.

## [1.11.2] - 2024-10-16

### Fixed
- Fixed touch pointers being released twice causing an index out of bounds error. [ISXB-687](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-687)
- Fixed `NullReferenceException` from disconnecting and reconnecting a GXDKGamepad.
- Fixed wrong mapping of Xbox Series S|X and Xbox One wireless controllers "View" button on macOS.[ISXB-385](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-385)
- Fixed "AnalyticsResult" errors on consoles [ISXB-1107]
- Fixed wrong `Display Index` value for touchscreen events.[ISXB-1101](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1101)
- Fixed event handling when using Fixed Update processing where WasPressedThisFrame could appear to true for consecutive frames [ISXB-1006](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1006)

### Added
- Added the display of the device flag `CanRunInBackground` in device debug view.
- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions` when exiting play-mode.

### Fixed
- Removed a redundant warning when using fallback code to parse a HID descriptor. (UUM-71260)

### Changed
- Removed the InputManager to InputSystem project-wide asset migration code for performance improvement (ISX-2086)

## [1.11.1] - 2024-09-26

### Fixed
Expand All @@ -17,6 +37,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed "MissingReferenceException" errors when closing an in-game dropdown field [ISXB-1081](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1081).
- Fixed potential crash on Mac when using stale references to deleted InputDevice objects [ISXB-606](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-606).
- Fixed conditional compilation for non-editor analytics on platforms not enabling analytics.
- Fixed simulated touch input not working with PlayerInput component [ISXB-483](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-483).

### Changed
- Renamed editor Resources directories to PackageResources to fix package validation warnings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ public unsafe bool WasPressedThisFrame()
{
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default;
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
}

return false;
Expand Down Expand Up @@ -1285,7 +1285,7 @@ public unsafe bool WasReleasedThisFrame()
{
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default;
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
}

return false;
Expand Down Expand Up @@ -1344,7 +1344,7 @@ public unsafe bool WasPerformedThisFrame()
{
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default;
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
}

return false;
Expand Down Expand Up @@ -1417,7 +1417,7 @@ public unsafe bool WasCompletedThisFrame()
{
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default;
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,23 @@ public static BindingSyntax AddBinding(this InputAction action, string path, str
});
}

/// <summary>
/// Conditionally compiled helper for logging API usage of code-authored actions.
/// </summary>
/// <param name="api">The associated API function.</param>
/// <remarks>
/// Be extremely carefully to review for indirect calls and overloads to not register analytics twice.
/// Be extremely careful in enabling/disabling tracking before internal calls since those may otherwise
/// be incorrectly registered.
/// </remarks>
#if UNITY_EDITOR
private static void RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api api)
{
UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Register(api);
}

#endif

/// <summary>
/// Add a binding that references the given <paramref name="control"/> and triggers
/// the given <paramref cref="action"/>.
Expand Down Expand Up @@ -349,6 +366,10 @@ public static BindingSyntax AddBinding(this InputAction action, InputControl con
/// </remarks>
public static BindingSyntax AddBinding(this InputAction action, InputBinding binding = default)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
#endif

if (action == null)
throw new ArgumentNullException(nameof(action));

Expand Down Expand Up @@ -478,6 +499,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, string pat
/// <seealso cref="InputActionMap.bindings"/>
public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBinding binding)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
#endif

if (actionMap == null)
throw new ArgumentNullException(nameof(actionMap));
if (binding.path == null)
Expand All @@ -501,6 +526,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBindi
public static CompositeSyntax AddCompositeBinding(this InputAction action, string composite,
string interactions = null, string processors = null)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddCompositeBinding);
#endif

if (action == null)
throw new ArgumentNullException(nameof(action));
if (string.IsNullOrEmpty(composite))
Expand Down Expand Up @@ -580,6 +609,10 @@ private static int AddBindingInternal(InputActionMap map, InputBinding binding,
/// of <paramref name="action"/>).</exception>
public static BindingSyntax ChangeBinding(this InputAction action, int index)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
#endif

if (action == null)
throw new ArgumentNullException(nameof(action));

Expand Down Expand Up @@ -638,6 +671,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, string name)
/// of <paramref name="actionMap"/>).</exception>
public static BindingSyntax ChangeBinding(this InputActionMap actionMap, int index)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
#endif

if (actionMap == null)
throw new ArgumentNullException(nameof(actionMap));
if (index < 0 || index >= actionMap.m_Bindings.LengthSafe())
Expand Down Expand Up @@ -836,6 +873,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, InputBinding
/// <seealso cref="InputBindingComposite"/>
public static BindingSyntax ChangeCompositeBinding(this InputAction action, string compositeName)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeCompositeBinding);
#endif

if (action == null)
throw new ArgumentNullException(nameof(action));
if (string.IsNullOrEmpty(compositeName))
Expand Down Expand Up @@ -877,6 +918,10 @@ public static BindingSyntax ChangeCompositeBinding(this InputAction action, stri
/// </remarks>
public static void Rename(this InputAction action, string newName)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.Rename);
#endif

if (action == null)
throw new ArgumentNullException(nameof(action));
if (string.IsNullOrEmpty(newName))
Expand Down Expand Up @@ -919,6 +964,10 @@ public static void Rename(this InputAction action, string newName)
/// </remarks>
public static void AddControlScheme(this InputActionAsset asset, InputControlScheme controlScheme)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddControlScheme);
#endif

if (asset == null)
throw new ArgumentNullException(nameof(asset));
if (string.IsNullOrEmpty(controlScheme.name))
Expand Down Expand Up @@ -987,6 +1036,10 @@ public static ControlSchemeSyntax AddControlScheme(this InputActionAsset asset,
/// </remarks>
public static void RemoveControlScheme(this InputActionAsset asset, string name)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.RemoveControlScheme);
#endif

if (asset == null)
throw new ArgumentNullException(nameof(asset));
if (string.IsNullOrEmpty(name))
Expand All @@ -1007,33 +1060,57 @@ public static void RemoveControlScheme(this InputActionAsset asset, string name)
/// <returns><paramref name="scheme"/></returns>
public static InputControlScheme WithBindingGroup(this InputControlScheme scheme, string bindingGroup)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithBindingGroup);
#endif

return new ControlSchemeSyntax(scheme).WithBindingGroup(bindingGroup).Done();
}

public static InputControlScheme WithDevice(this InputControlScheme scheme, string controlPath, bool required)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithDevice);
#endif

if (required)
return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done();
return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done();
}

public static InputControlScheme WithRequiredDevice(this InputControlScheme scheme, string controlPath)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithRequiredDevice);
#endif

return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done();
}

public static InputControlScheme WithOptionalDevice(this InputControlScheme scheme, string controlPath)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithOptionalDevice);
#endif

return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done();
}

public static InputControlScheme OrWithRequiredDevice(this InputControlScheme scheme, string controlPath)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithRequiredDevice);
#endif

return new ControlSchemeSyntax(scheme).OrWithRequiredDevice(controlPath).Done();
}

public static InputControlScheme OrWithOptionalDevice(this InputControlScheme scheme, string controlPath)
{
#if UNITY_EDITOR
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithOptionalDevice);
#endif

return new ControlSchemeSyntax(scheme).OrWithOptionalDevice(controlPath).Done();
}

Expand Down
Loading

0 comments on commit c851869

Please sign in to comment.