Skip to content

Commit c851869

Browse files
committed
Merge branch 'develop' into stable
2 parents 684a284 + db7b26f commit c851869

37 files changed

+655
-342
lines changed

Assets/Samples/InGameHints/InGameHintsActions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
4-
// version 1.11.1
4+
// version 1.11.2
55
// from Assets/Samples/InGameHints/InGameHintsActions.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if

Assets/Samples/SimpleDemo/SimpleControls.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
4-
// version 1.11.1
4+
// version 1.11.2
55
// from Assets/Samples/SimpleDemo/SimpleControls.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if

Assets/Tests/InputSystem/CoreTests_Analytics.cs

+49
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,55 @@ public void Analytics_ShouldReportPlayerInputManagerData()
663663
}
664664
}
665665

666+
[Test]
667+
[Category("Analytics")]
668+
public void Analytics_ShouldReportCodeAuthoringAnalytic()
669+
{
670+
CollectAnalytics(InputExitPlayModeAnalytic.kEventName);
671+
672+
// NOTE: We do not want to trigger entering/exiting play-mode for this small data-sanity check
673+
// so just stick to triggering it explicitly. A better test would have been an editor test
674+
// going in and out of play-mode for real but not clear if this is really possible.
675+
676+
// Pretend we are entering play-mode
677+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
678+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
679+
680+
// Assert no data received
681+
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(0));
682+
683+
// Pretend we are exiting play-mode
684+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
685+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
686+
687+
// Assert: Data received
688+
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(1));
689+
Assert.That(sentAnalyticsEvents[0].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
690+
Assert.That(sentAnalyticsEvents[0].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());
691+
692+
var data0 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[0].data;
693+
Assert.That(data0.uses_code_authoring, Is.False);
694+
695+
// Pretend we are entering play-mode
696+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
697+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
698+
699+
var action = new InputAction("Dance");
700+
action.AddBinding("<Keyboard>/Space");
701+
702+
// Pretend we are exiting play-mode
703+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
704+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
705+
706+
// Assert: Data received
707+
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(2));
708+
Assert.That(sentAnalyticsEvents[1].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
709+
Assert.That(sentAnalyticsEvents[1].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());
710+
711+
var data1 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[1].data;
712+
Assert.That(data1.uses_code_authoring, Is.True);
713+
}
714+
666715
#if UNITY_INPUT_SYSTEM_ENABLE_UI
667716
[Test]
668717
[Category("Analytics")]

Assets/Tests/InputSystem/CoreTests_Devices.cs

+34-7
Original file line numberDiff line numberDiff line change
@@ -4162,13 +4162,40 @@ public void Devices_RemovingAndReaddingDevice_DoesNotAllocateMemory()
41624162
recorder.CollectFromAllThreads();
41634163
#endif
41644164

4165-
// We expect a single allocation for each call to ReportNewInputDevice when there is one disconnected device
4166-
//
4167-
int numberOfRepeats = 2;
4168-
int numberOfDisconnectedDevices = 1;
4169-
int numberOfCallsToReportNewInputDevicePerRun = 2;
4170-
int expectedAllocations = numberOfRepeats * numberOfDisconnectedDevices * numberOfCallsToReportNewInputDevicePerRun;
4171-
Assert.AreEqual(expectedAllocations, recorder.sampleBlockCount);
4165+
// No allocations are expected.
4166+
Assert.AreEqual(0, recorder.sampleBlockCount);
4167+
}
4168+
4169+
// Regression test to cover having null descriptor fields for a device. Some non-desktop gamepad device types do this.
4170+
[Test]
4171+
[Category("Devices")]
4172+
public void Devices_RemovingAndReaddingDeviceWithNullDescriptorFields_DoesNotThrow()
4173+
{
4174+
// InputDeviceDescription.ToJson writes empty string fields and not null values, whereas reporting a device via an incomplete description string will fully omit the fields.
4175+
string description = @"{
4176+
""type"": ""Gamepad"",
4177+
""product"": ""TestProduct""
4178+
}";
4179+
4180+
var deviceId = runtime.ReportNewInputDevice(description);
4181+
InputSystem.Update();
4182+
4183+
// "Unplug" device.
4184+
var removeEvent1 = DeviceRemoveEvent.Create(deviceId);
4185+
InputSystem.QueueEvent(ref removeEvent1);
4186+
InputSystem.Update();
4187+
4188+
// "Plug" it back in.
4189+
deviceId = runtime.ReportNewInputDevice(description);
4190+
InputSystem.Update();
4191+
4192+
// Repeat that sequence.
4193+
var removeEvent2 = DeviceRemoveEvent.Create(deviceId);
4194+
InputSystem.QueueEvent(ref removeEvent2);
4195+
InputSystem.Update();
4196+
4197+
runtime.ReportNewInputDevice(description);
4198+
InputSystem.Update();
41724199
}
41734200

41744201
[Test]

Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
4-
// version 1.11.1
4+
// version 1.11.2
55
// from Assets/Tests/InputSystem/InputActionCodeGeneratorActions.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if

Packages/com.unity.inputsystem/CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
Due to package verification, the latest version below is the unpublished version and the date is meaningless.
99
however, it has to be formatted properly to pass verification tests.
1010

11+
## [1.11.2] - 2024-10-16
12+
13+
### Fixed
14+
- 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)
15+
- Fixed `NullReferenceException` from disconnecting and reconnecting a GXDKGamepad.
16+
- 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)
17+
- Fixed "AnalyticsResult" errors on consoles [ISXB-1107]
18+
- Fixed wrong `Display Index` value for touchscreen events.[ISXB-1101](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1101)
19+
- 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)
20+
21+
### Added
22+
- Added the display of the device flag `CanRunInBackground` in device debug view.
23+
- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions` when exiting play-mode.
24+
25+
### Fixed
26+
- Removed a redundant warning when using fallback code to parse a HID descriptor. (UUM-71260)
27+
28+
### Changed
29+
- Removed the InputManager to InputSystem project-wide asset migration code for performance improvement (ISX-2086)
30+
1131
## [1.11.1] - 2024-09-26
1232

1333
### Fixed
@@ -17,6 +37,7 @@ however, it has to be formatted properly to pass verification tests.
1737
- Fixed "MissingReferenceException" errors when closing an in-game dropdown field [ISXB-1081](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1081).
1838
- 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).
1939
- Fixed conditional compilation for non-editor analytics on platforms not enabling analytics.
40+
- Fixed simulated touch input not working with PlayerInput component [ISXB-483](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-483).
2041

2142
### Changed
2243
- Renamed editor Resources directories to PackageResources to fix package validation warnings.

Packages/com.unity.inputsystem/InputSystem/Actions/InputAction.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ public unsafe bool WasPressedThisFrame()
12361236
{
12371237
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12381238
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1239-
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default;
1239+
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
12401240
}
12411241

12421242
return false;
@@ -1285,7 +1285,7 @@ public unsafe bool WasReleasedThisFrame()
12851285
{
12861286
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12871287
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1288-
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default;
1288+
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
12891289
}
12901290

12911291
return false;
@@ -1344,7 +1344,7 @@ public unsafe bool WasPerformedThisFrame()
13441344
{
13451345
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
13461346
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1347-
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default;
1347+
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
13481348
}
13491349

13501350
return false;
@@ -1417,7 +1417,7 @@ public unsafe bool WasCompletedThisFrame()
14171417
{
14181418
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
14191419
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1420-
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default;
1420+
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
14211421
}
14221422

14231423
return false;

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs

+77
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,23 @@ public static BindingSyntax AddBinding(this InputAction action, string path, str
306306
});
307307
}
308308

309+
/// <summary>
310+
/// Conditionally compiled helper for logging API usage of code-authored actions.
311+
/// </summary>
312+
/// <param name="api">The associated API function.</param>
313+
/// <remarks>
314+
/// Be extremely carefully to review for indirect calls and overloads to not register analytics twice.
315+
/// Be extremely careful in enabling/disabling tracking before internal calls since those may otherwise
316+
/// be incorrectly registered.
317+
/// </remarks>
318+
#if UNITY_EDITOR
319+
private static void RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api api)
320+
{
321+
UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Register(api);
322+
}
323+
324+
#endif
325+
309326
/// <summary>
310327
/// Add a binding that references the given <paramref name="control"/> and triggers
311328
/// the given <paramref cref="action"/>.
@@ -349,6 +366,10 @@ public static BindingSyntax AddBinding(this InputAction action, InputControl con
349366
/// </remarks>
350367
public static BindingSyntax AddBinding(this InputAction action, InputBinding binding = default)
351368
{
369+
#if UNITY_EDITOR
370+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
371+
#endif
372+
352373
if (action == null)
353374
throw new ArgumentNullException(nameof(action));
354375

@@ -478,6 +499,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, string pat
478499
/// <seealso cref="InputActionMap.bindings"/>
479500
public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBinding binding)
480501
{
502+
#if UNITY_EDITOR
503+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
504+
#endif
505+
481506
if (actionMap == null)
482507
throw new ArgumentNullException(nameof(actionMap));
483508
if (binding.path == null)
@@ -501,6 +526,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBindi
501526
public static CompositeSyntax AddCompositeBinding(this InputAction action, string composite,
502527
string interactions = null, string processors = null)
503528
{
529+
#if UNITY_EDITOR
530+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddCompositeBinding);
531+
#endif
532+
504533
if (action == null)
505534
throw new ArgumentNullException(nameof(action));
506535
if (string.IsNullOrEmpty(composite))
@@ -580,6 +609,10 @@ private static int AddBindingInternal(InputActionMap map, InputBinding binding,
580609
/// of <paramref name="action"/>).</exception>
581610
public static BindingSyntax ChangeBinding(this InputAction action, int index)
582611
{
612+
#if UNITY_EDITOR
613+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
614+
#endif
615+
583616
if (action == null)
584617
throw new ArgumentNullException(nameof(action));
585618

@@ -638,6 +671,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, string name)
638671
/// of <paramref name="actionMap"/>).</exception>
639672
public static BindingSyntax ChangeBinding(this InputActionMap actionMap, int index)
640673
{
674+
#if UNITY_EDITOR
675+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
676+
#endif
677+
641678
if (actionMap == null)
642679
throw new ArgumentNullException(nameof(actionMap));
643680
if (index < 0 || index >= actionMap.m_Bindings.LengthSafe())
@@ -836,6 +873,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, InputBinding
836873
/// <seealso cref="InputBindingComposite"/>
837874
public static BindingSyntax ChangeCompositeBinding(this InputAction action, string compositeName)
838875
{
876+
#if UNITY_EDITOR
877+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeCompositeBinding);
878+
#endif
879+
839880
if (action == null)
840881
throw new ArgumentNullException(nameof(action));
841882
if (string.IsNullOrEmpty(compositeName))
@@ -877,6 +918,10 @@ public static BindingSyntax ChangeCompositeBinding(this InputAction action, stri
877918
/// </remarks>
878919
public static void Rename(this InputAction action, string newName)
879920
{
921+
#if UNITY_EDITOR
922+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.Rename);
923+
#endif
924+
880925
if (action == null)
881926
throw new ArgumentNullException(nameof(action));
882927
if (string.IsNullOrEmpty(newName))
@@ -919,6 +964,10 @@ public static void Rename(this InputAction action, string newName)
919964
/// </remarks>
920965
public static void AddControlScheme(this InputActionAsset asset, InputControlScheme controlScheme)
921966
{
967+
#if UNITY_EDITOR
968+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddControlScheme);
969+
#endif
970+
922971
if (asset == null)
923972
throw new ArgumentNullException(nameof(asset));
924973
if (string.IsNullOrEmpty(controlScheme.name))
@@ -987,6 +1036,10 @@ public static ControlSchemeSyntax AddControlScheme(this InputActionAsset asset,
9871036
/// </remarks>
9881037
public static void RemoveControlScheme(this InputActionAsset asset, string name)
9891038
{
1039+
#if UNITY_EDITOR
1040+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.RemoveControlScheme);
1041+
#endif
1042+
9901043
if (asset == null)
9911044
throw new ArgumentNullException(nameof(asset));
9921045
if (string.IsNullOrEmpty(name))
@@ -1007,33 +1060,57 @@ public static void RemoveControlScheme(this InputActionAsset asset, string name)
10071060
/// <returns><paramref name="scheme"/></returns>
10081061
public static InputControlScheme WithBindingGroup(this InputControlScheme scheme, string bindingGroup)
10091062
{
1063+
#if UNITY_EDITOR
1064+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithBindingGroup);
1065+
#endif
1066+
10101067
return new ControlSchemeSyntax(scheme).WithBindingGroup(bindingGroup).Done();
10111068
}
10121069

10131070
public static InputControlScheme WithDevice(this InputControlScheme scheme, string controlPath, bool required)
10141071
{
1072+
#if UNITY_EDITOR
1073+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithDevice);
1074+
#endif
1075+
10151076
if (required)
10161077
return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done();
10171078
return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done();
10181079
}
10191080

10201081
public static InputControlScheme WithRequiredDevice(this InputControlScheme scheme, string controlPath)
10211082
{
1083+
#if UNITY_EDITOR
1084+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithRequiredDevice);
1085+
#endif
1086+
10221087
return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done();
10231088
}
10241089

10251090
public static InputControlScheme WithOptionalDevice(this InputControlScheme scheme, string controlPath)
10261091
{
1092+
#if UNITY_EDITOR
1093+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithOptionalDevice);
1094+
#endif
1095+
10271096
return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done();
10281097
}
10291098

10301099
public static InputControlScheme OrWithRequiredDevice(this InputControlScheme scheme, string controlPath)
10311100
{
1101+
#if UNITY_EDITOR
1102+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithRequiredDevice);
1103+
#endif
1104+
10321105
return new ControlSchemeSyntax(scheme).OrWithRequiredDevice(controlPath).Done();
10331106
}
10341107

10351108
public static InputControlScheme OrWithOptionalDevice(this InputControlScheme scheme, string controlPath)
10361109
{
1110+
#if UNITY_EDITOR
1111+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithOptionalDevice);
1112+
#endif
1113+
10371114
return new ControlSchemeSyntax(scheme).OrWithOptionalDevice(controlPath).Done();
10381115
}
10391116

0 commit comments

Comments
 (0)