Skip to content

Commit 6efecc3

Browse files
Merge branch 'DOCS__Specifying_mouse_position_and_delta_behaviour' of https://github.com/Unity-Technologies/InputSystem into DOCS__Specifying_mouse_position_and_delta_behaviour
2 parents eb576b4 + a183c21 commit 6efecc3

File tree

13 files changed

+295
-303
lines changed

13 files changed

+295
-303
lines changed

Assets/Tests/InputSystem/CoreTests_Devices.cs

Lines changed: 34 additions & 7 deletions
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]

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +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-
## [Unreleased] - yyyy-mm-dd
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)
1220

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

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+
1731
## [1.11.1] - 2024-09-26
1832

1933
### Fixed
@@ -23,6 +37,7 @@ however, it has to be formatted properly to pass verification tests.
2337
- Fixed "MissingReferenceException" errors when closing an in-game dropdown field [ISXB-1081](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1081).
2438
- 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).
2539
- 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).
2641

2742
### Changed
2843
- Renamed editor Resources directories to PackageResources to fix package validation warnings.

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

Lines changed: 4 additions & 4 deletions
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/InputActionState.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ private void RestoreActionStatesAfterReResolvingBindings(UnmanagedMemory oldStat
560560
newActionState.releasedInUpdate = oldActionState.releasedInUpdate;
561561
newActionState.startTime = oldActionState.startTime;
562562
newActionState.bindingIndex = oldActionState.bindingIndex;
563+
newActionState.frame = oldActionState.frame;
563564

564565
if (oldActionState.phase != InputActionPhase.Disabled)
565566
{
@@ -884,6 +885,7 @@ public void ResetActionState(int actionIndex, InputActionPhase toPhase = InputAc
884885
actionState->lastCompletedInUpdate = default;
885886
actionState->pressedInUpdate = default;
886887
actionState->releasedInUpdate = default;
888+
actionState->frame = default;
887889
}
888890

889891
Debug.Assert(!actionState->isStarted, "Cannot reset an action to started phase");
@@ -1579,6 +1581,7 @@ private void ProcessButtonState(ref TriggerState trigger, int actionIndex, Bindi
15791581
{
15801582
actionState->pressedInUpdate = InputUpdate.s_UpdateStepCount;
15811583
actionState->isPressed = true;
1584+
actionState->frame = Time.frameCount;
15821585
}
15831586
else if (actionState->isPressed)
15841587
{
@@ -1587,6 +1590,7 @@ private void ProcessButtonState(ref TriggerState trigger, int actionIndex, Bindi
15871590
{
15881591
actionState->releasedInUpdate = InputUpdate.s_UpdateStepCount;
15891592
actionState->isPressed = false;
1593+
actionState->frame = Time.frameCount;
15901594
}
15911595
}
15921596
}
@@ -2445,6 +2449,7 @@ private void ChangePhaseOfActionInternal(int actionIndex, TriggerState* actionSt
24452449
newState.magnitude = 0f;
24462450

24472451
newState.phase = newPhase;
2452+
newState.frame = Time.frameCount;
24482453
if (newPhase == InputActionPhase.Performed)
24492454
{
24502455
newState.lastPerformedInUpdate = InputUpdate.s_UpdateStepCount;
@@ -3627,7 +3632,7 @@ public int partIndex
36273632
/// other is to represent the current actuation state of an action as a whole. The latter is stored in <see cref="actionStates"/>
36283633
/// while the former is passed around as temporary instances on the stack.
36293634
/// </remarks>
3630-
[StructLayout(LayoutKind.Explicit, Size = 52)]
3635+
[StructLayout(LayoutKind.Explicit, Size = 56)]
36313636
public struct TriggerState
36323637
{
36333638
public const int kMaxNumMaps = byte.MaxValue;
@@ -3651,6 +3656,7 @@ public struct TriggerState
36513656
[FieldOffset(40)] private uint m_PressedInUpdate;
36523657
[FieldOffset(44)] private uint m_ReleasedInUpdate;
36533658
[FieldOffset(48)] private uint m_LastCompletedInUpdate;
3659+
[FieldOffset(52)] private int m_Frame;
36543660

36553661
/// <summary>
36563662
/// Phase being triggered by the control value change.
@@ -3806,6 +3812,12 @@ public uint lastPerformedInUpdate
38063812
set => m_LastPerformedInUpdate = value;
38073813
}
38083814

3815+
internal int frame
3816+
{
3817+
get => m_Frame;
3818+
set => m_Frame = value;
3819+
}
3820+
38093821
/// <summary>
38103822
/// Update step count (<see cref="InputUpdate.s_UpdateStepCount"/>) in which action completed last.
38113823
/// Zero if the action did not become completed yet. Also reset to zero when the action is hard reset.

0 commit comments

Comments
 (0)