Skip to content

Commit c22d1b1

Browse files
committed
Merge Upstream/Develop
2 parents 78d26c4 + a338407 commit c22d1b1

File tree

87 files changed

+433
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+433
-248
lines changed

Assets/Tests/InputSystem/CoreTests_Devices.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -921,20 +921,25 @@ public void Devices_ChangingStateOfDevice_TriggersNotification()
921921
var gamepad = InputSystem.AddDevice<Gamepad>();
922922

923923
var receivedCalls = 0;
924-
InputDevice receivedDevice = null;
924+
InputDevice receivedDevice = default;
925+
InputEventPtr receivedEventPtr = default;
925926

926927
InputState.onChange +=
927-
d =>
928+
(d, e) =>
928929
{
929930
++receivedCalls;
930931
receivedDevice = d;
932+
receivedEventPtr = e;
931933
};
932934

933935
InputSystem.QueueStateEvent(gamepad, new GamepadState { leftStick = new Vector2(0.5f, 0.5f) });
934936
InputSystem.Update();
935937

936938
Assert.That(receivedCalls, Is.EqualTo(1));
937939
Assert.That(receivedDevice, Is.SameAs(gamepad));
940+
Assert.That(receivedEventPtr.valid, Is.True);
941+
Assert.That(receivedEventPtr.deviceId, Is.EqualTo(gamepad.id));
942+
Assert.That(receivedEventPtr.IsA<StateEvent>(), Is.True);
938943
}
939944

940945
private class TestDeviceThatResetsStateInCallback : InputDevice, IInputStateCallbackReceiver
@@ -967,19 +972,22 @@ public void Devices_ChangingStateOfDevice_InStateCallback_TriggersNotification()
967972
var device = InputSystem.AddDevice<TestDeviceThatResetsStateInCallback>();
968973

969974
var receivedCalls = 0;
970-
InputDevice receivedDevice = null;
975+
InputDevice receivedDevice = default;
976+
InputEventPtr receivedEventPtr = default;
971977

972978
InputState.onChange +=
973-
d =>
979+
(d, e) =>
974980
{
975981
++receivedCalls;
976982
receivedDevice = d;
983+
receivedEventPtr = e;
977984
};
978985

979986
InputSystem.Update();
980987

981988
Assert.That(receivedCalls, Is.EqualTo(1));
982989
Assert.That(receivedDevice, Is.SameAs(device));
990+
Assert.That(receivedEventPtr.valid, Is.False);
983991
}
984992

985993
[Test]

Assets/Tests/InputSystem/CoreTests_Layouts.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,24 @@ public void Layouts_RegisteringLayoutType_UsesBaseTypeAsBaseLayout()
10591059
Assert.That(layout.baseLayouts, Is.EquivalentTo(new[] {new InternedString("Pointer")}));
10601060
}
10611061

1062+
class DeviceWithControlProperties : InputDevice
1063+
{
1064+
public ButtonControl propertyWithoutAttribute { get; set; }
1065+
[InputControl]
1066+
public ButtonControl propertyWithAttribute { get; set; }
1067+
}
1068+
1069+
[Test]
1070+
[Category("Layouts")]
1071+
public void Layouts_RegisteringLayoutType_OnlyAddsPropertiesWithExplicitAttribute()
1072+
{
1073+
var device = InputSystem.AddDevice<DeviceWithControlProperties>();
1074+
1075+
Assert.That(device.TryGetChildControl("propertyWithoutAttribute"), Is.Null);
1076+
Assert.That(device.TryGetChildControl("propertyWithAttribute"), Is.Not.Null);
1077+
Assert.That(device.TryGetChildControl("propertyWithAttribute"), Is.TypeOf<ButtonControl>());
1078+
}
1079+
10621080
// We consider layouts built by layout builders as being auto-generated. We want them to
10631081
// be overridable by layouts built specifically for a device so we boost the score of
10641082
// of type and JSON layouts such that they will override auto-generated layouts even if
@@ -1378,6 +1396,7 @@ public void Layouts_CanSpecifyMinAndMaxValuesForControlInJson()
13781396

13791397
class BaseClassWithControl : InputDevice
13801398
{
1399+
[InputControl]
13811400
public AxisControl controlFromBase { get; set; }
13821401
}
13831402

Assets/Tests/InputSystem/CoreTests_Remoting.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ public void Send(Guid messageId, byte[] data)
255255
otherEnd.Receive(messageId, data);
256256
}
257257

258+
public bool TrySend(Guid messageId, byte[] data)
259+
{
260+
Send(messageId, data);
261+
return true;
262+
}
263+
258264
private Dictionary<Guid, MessageEvent> m_MessageListeners = new Dictionary<Guid, MessageEvent>();
259265
private ConnectEvent m_ConnectionListeners = new ConnectEvent();
260266
private ConnectEvent m_DisconnectionListeners = new ConnectEvent();

Assets/Tests/InputSystem/Plugins/UserTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,23 @@ public void Users_CanFindUserPairedToSpecificDevice()
760760
Assert.That(InputUser.FindUserPairedToDevice(gamepad3), Is.Null);
761761
}
762762

763+
[Test]
764+
[Category("Users")]
765+
public void Users_CanDetectUseOfUnpairedDevice_FromControlThatDoesNotSupportMagnitude()
766+
{
767+
++InputUser.listenForUnpairedDeviceActivity;
768+
769+
var receivedControls = new List<InputControl>();
770+
InputUser.onUnpairedDeviceUsed +=
771+
control => { receivedControls.Add(control); };
772+
773+
var mouse = InputSystem.AddDevice<Mouse>();
774+
775+
Set(mouse.delta, new Vector2(0, 0.234f));
776+
777+
Assert.That(receivedControls, Is.EquivalentTo(new[] { mouse.delta.y }));
778+
}
779+
763780
[Test]
764781
[Category("Users")]
765782
public void Users_CanDetectUseOfUnpairedDevice()

Assets/Tests/InputSystem/Plugins/XRTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ public void Layouts_ButtonsArePackedByTheByte_WhileLargerStructuresAreFourByteAl
364364
[InputControlLayout(updateBeforeRender = true)]
365365
private class TestHMD : InputDevice
366366
{
367+
[InputControl]
367368
public QuaternionControl quaternion { get; private set; }
369+
[InputControl]
368370
public Vector3Control vector3 { get; private set; }
369371
protected override void FinishSetup()
370372
{

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ however, it has to be formatted properly to pass verification tests.
1111

1212
### Fixed
1313

14+
- `XInputController` and `XboxOneGamepad` no longer have two extraneous, non-functional "menu" and "view" buttons.
15+
- Fixed `InputUser.onUnpairedDeviceUser` ignoring input on controls that do not support `EvaluateMagnitude`.
16+
* This led to situations, for example, where `PlayerInput` would not initialize a control scheme switch from a `<Mouse>/delta` binding as the delta X and Y axes do not have min&max limits and thus return -1 from `EvaluateMagnitude`.
17+
- Fixed available processor list not updated right away when changing the action type in the Input Action editor window.
18+
1419
#### Actions
1520

1621
- `NullReferenceException` when the input debugger is open with actions being enabled.
@@ -20,6 +25,7 @@ however, it has to be formatted properly to pass verification tests.
2025

2126
- Removed `timesliceEvents` setting - and made this tied to the update mode instead. We now always time slice when using fixed updates, and not when using dynamic updates.
2227
- When adding a composite, only ones compatible with the value type of the current action are shown. This will, for example, no longer display a `2D Vector` composite as an option on a floating-point button action.
28+
- The `InputState.onChange` callback now receives a second argument which is the event (if any) that triggered the state change on the device.
2329

2430
### Added
2531

Packages/com.unity.inputsystem/Documentation~/ActionAssets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ One of the most convenient ways to work with `.inputactions` assets in script is
8383
To enable this, tick the `Generate C# Class` in the importer properties in the inspector of the `.inputactions` asset when selected in Unity and hit "Apply".
8484

8585
////TODO: Update screenshot
86-
![MyPlayerControls Importer Settings](Images/MyPlayerControlsImporterSettings.png)
86+
![MyPlayerControls Importer Settings](Images/FireActionInputAssetInspector.png)
8787

8888
This will generate a C# script that makes working with the asset a lot simpler. TODO
8989

Packages/com.unity.inputsystem/Documentation~/Actions.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* [Creating Actions in Code](#creating-actions-in-code)
1313
* [Using Actions](#using-actions)
1414
* [Responding to Actions](#responding-to-actions)
15-
* [Continuous Actions](#continuous-actions)
1615
* [Pass-Through Actions](#pass-through-actions)
1716
* [Debugging Actions](#debugging-actions)
1817
* [Extending Actions](#extending-actions)
@@ -105,7 +104,7 @@ The editors work similar to the [action asset editor](ActionAssets.md).
105104
* To add or remote actions or bindings, click the plus or minus icon in the header.
106105
* To edit binding entries, double-click them.<br>
107106
![InputBinding Inspector](Images/InputBindingInspector.png)
108-
* To edit action entries, double-click them.<br>
107+
* To edit action entries, double-click them in an InputActionMap, or click the 'gear' icon on individual action properties.<br>
109108
![InputAction Inspector](Images/InputActionInspector.png)
110109
* Entries can also be right-clicked to bring up a context menu and can be dragged around (hold alt to duplicate).
111110

@@ -339,20 +338,6 @@ trace.Dispose();
339338

340339
Once recorded, a trace can be safely read from multiple threads as long as it is not concurrently being written to and as long as the action setup (i.e. the configuration data accessed by the trace) is not concurrently being changed on the main thread.
341340

342-
### Continuous Actions
343-
344-
By default, actions will trigger only in response to input events. This means that, for example, an action bound to the left stick of a gamepad will only trigger when the left stick is actually moved. This behavior can be undesirable when an input is meant to register for as long as a control is actuated -- regardless of whether it changes value in a particular frame or not.
345-
346-
This is what "continuous" mode is for. It can be enabled in the UI by selecting the action in the [action editor](ActionAssets.md) and ticking the "Continuous" checkbox.
347-
348-
////TODO: Update screenshot
349-
350-
![Continuous Action](Images/ContinuousAction.png)
351-
352-
When continuous mode is enabled, an action that goes into `Performed` phase will stay in the phase until it is `Cancelled`. Also, while in the `Performed` phase, an action in continuous mode will be `Performed` in a frame even if there is no input. The value returned by `ReadValue` will be the value of the control that was last used with the action.
353-
354-
>NOTE: Not all interactions support continuous mode. See [here](Interactions.md#predefined-interactions) for details.
355-
356341
### Pass-Through Actions
357342

358343
////TODO

Packages/com.unity.inputsystem/Documentation~/Components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ You can listen to the following notifications:
100100
|--------|-----------|
101101
|[`Send Messages`](../api/UnityEngine.InputSystem.PlayerNotifications.html)|Uses [`GameObject.SendMessage`](https://docs.unity3d.com/ScriptReference/GameObject.SendMessage.html) on the `GameObject` that the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component belongs to. The messages that will be sent by the component are shown in the UI.|
102102
|[`Broadcast Messages`](../api/UnityEngine.InputSystem.PlayerNotifications.html)|Like `Send Message` but instead of [`GameObject.SendMessage`](https://docs.unity3d.com/ScriptReference/GameObject.SendMessage.html) uses [`GameObject.BroadcastMessage`](https://docs.unity3d.com/ScriptReference/GameObject.BroadcastMessage.html). This will broadcast the message down the `GameObject` hierarchy.|
103-
|[`Invoke Unity Events`](../api/UnityEngine.InputSystem.PlayerNotifications.html)|Uses a separate [`UnityEvent`](https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html) for each individual type of message. When this is selected, the events that are available on the given [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) are accessible from the "Events" foldout. The argument received by events triggered for actions is the same as the one received by [`started`, `performed`, and `cancelled` callbacks](Actions.md#started-performed-and-cancelled-callbacks).<br><br>![PlayerInput UnityEvents](Images/PlayerInputUnityEvents.png)|
103+
|[`Invoke Unity Events`](../api/UnityEngine.InputSystem.PlayerNotifications.html)|Uses a separate [`UnityEvent`](https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html) for each individual type of message. When this is selected, the events that are available on the given [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) are accessible from the "Events" foldout. The argument received by events triggered for actions is the same as the one received by [`started`, `performed`, and `cancelled` callbacks](Actions.md#started-performed-and-cancelled-callbacks).<br><br>![PlayerInput UnityEvents](Images/MyPlayerActionEvents.png)|
104104
|[`Invoke CSharp Events`](../api/UnityEngine.InputSystem.PlayerNotifications.html)|Similar to `Invoke Unity Events` except that the events are plain C# events available on the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) API. These cannot be initialized from the inspector but have to be manually registered callbacks for in script.<br><br>The following events are available:<br><br><ul><li>[`onActionTriggered`](../api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_onActionTriggered) (collective event for all actions on the player)</li><li>[`onDeviceLost`](../api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_onDeviceLost)</li><li>[`onDeviceRegained`](../api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_onDeviceRegained)</li></ul>|
105105

106106
In addition to per-action notifications, the following general notifications are employed by [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html).
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
////WIP
2-
31
# Contributing
42

53
[Full source code](https://github.com/Unity-Technologies/InputSystem) for the input system is available on GitHub. This is also where most of our development happens.
64

75
>NOTE: This includes the full source code for the managed/C# part of the system. At this point, the native, platform-specific C++ backends are still closed-source and require a source code license.
86
9-
## Creating PRs
10-
117
## Reporting Bugs
128

13-
## Feature Requests
9+
Input System bugs should be reported through using [same mechanism as for any other Unity bugs](https://unity3d.com/unity/qa/bug-reporting). Make sure to submit a repro project, and to mention that the bug is specific to the Input System package in the description, so it can get forwarded to the correct respondents at Unity.
1410

1511
## Discussion
1612

17-
To ask questions or discuss the new input system, we have a [dedicated section on Unity's forum](https://forum.unity.com/forums/new-input-system.103/).
13+
To ask questions or discuss the input system, we have a [dedicated section on Unity's forum](https://forum.unity.com/forums/new-input-system.103/). This is also the best place to post feature requests.

0 commit comments

Comments
 (0)