Skip to content

Commit 0953592

Browse files
RELEASE: Merge dvelop.
2 parents 5615a30 + a338407 commit 0953592

File tree

120 files changed

+1781
-511
lines changed

Some content is hidden

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

120 files changed

+1781
-511
lines changed

Assets/Samples/SimpleDemo/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class SimpleController : MonoBehaviour
113113
}
114114
```
115115

116-
but then we would have to look up all the actions manually in the action map. A simple approach is to put all our actions in a separate asset and generate a C# wrapper class that automatically performs the lookup for us.
116+
but then we would have to look up all the actions manually in the action map. A simpler approach is to put all our actions in a separate asset and generate a C# wrapper class that automatically performs the lookup for us.
117117

118118
To create such an `.inputactions` asset, right-click in the Project Browser and click `Create >> Input Actions`. To edit the actions, double-click the `.inputactions` asset and a separate window will come up. The asset we use in this example is [SimpleControls.inputactions](SimpleControls.inputactions).
119119

@@ -153,6 +153,8 @@ public class SimpleController_UsingActionAsset
153153
// Same here, we can just look the actions up by name.
154154
var look = m_Controls.gameplay.look.ReadValue<Vector2>();
155155
var move = m_Controls.gameplay.move.ReadValue<Vector2>();
156+
157+
//...
156158
}
157159
}
158160
```

Assets/Samples/SimpleDemo/SimpleControls.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// GENERATED AUTOMATICALLY FROM 'Assets/Demo/SimpleDemo/SimpleControls.inputactions'
1+
// GENERATED AUTOMATICALLY FROM 'Assets/Samples/SimpleDemo/SimpleControls.inputactions'
22

33
using System.Collections;
44
using System.Collections.Generic;

Assets/Samples/SimpleDemo/SimpleControls.inputactions.meta

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "InputSystem.Samples.Visualizers",
3+
"references": [
4+
"GUID:75469ad4d38634e559750d17036d5f7c"
5+
],
6+
"optionalUnityReferences": [],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": true,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": []
15+
}

Assets/Samples/Visualizers/Unity.InputSystem.Visualizers.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Tests/DemoGameTestFixture.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using UnityEngine.InputSystem;
66
using UnityEngine.InputSystem.Controls;
77
using UnityEngine.InputSystem.DualShock;
8-
using UnityEngine.InputSystem.Steam;
98
using UnityEngine.InputSystem.XInput;
109
using UnityEngine.InputSystem.XR;
1110
using UnityEngine.SceneManagement;

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 119 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ public void Actions_CanDetermineIfMapIsUsableWithGivenDevice()
183183
[Category("Actions")]
184184
public void Actions_WhenDisabled_CancelAllStartedInteractions()
185185
{
186-
InputSystem.settings.timesliceEvents = false;
187-
188186
var gamepad = InputSystem.AddDevice<Gamepad>();
189187

190188
var action1 = new InputAction("action1", InputActionType.Button, binding: "<Gamepad>/buttonSouth", interactions: "Hold");
@@ -828,8 +826,6 @@ public void Actions_CanCreateActionsWithoutAnActionMap()
828826
[Category("Actions")]
829827
public void Actions_CanCreateActionAssetWithMultipleActionMaps()
830828
{
831-
InputSystem.settings.timesliceEvents = false;
832-
833829
var gamepad = InputSystem.AddDevice<Gamepad>();
834830

835831
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
@@ -1172,8 +1168,6 @@ public void Actions_CanByPassControlActuationChecks_UsingPasshtroughAction()
11721168
[Category("Actions")]
11731169
public void Actions_WithMultipleBoundControls_DriveInteractionsFromControlWithGreatestActuation()
11741170
{
1175-
InputSystem.settings.timesliceEvents = false;
1176-
11771171
var gamepad = InputSystem.AddDevice<Gamepad>();
11781172

11791173
// We go through several permutations of the same behavior all in one test. Makes the
@@ -1502,8 +1496,6 @@ public void Actions_WithMultipleBoundControls_CanHandleInteractionsThatTriggerOn
15021496
[Ignore("TODO")]
15031497
public void TODO_Actions_WithMultipleActuationsFromSameState_()
15041498
{
1505-
InputSystem.settings.timesliceEvents = false;
1506-
15071499
var mouse = InputSystem.AddDevice<Mouse>();
15081500
var action = new InputAction(binding: "<Mouse>/*button");
15091501
action.Enable();
@@ -1669,8 +1661,6 @@ public void Actions_WhenTriggered_TriggerGlobalNotification()
16691661
[Category("Actions")]
16701662
public void Actions_CanRecordActions()
16711663
{
1672-
InputSystem.settings.timesliceEvents = false;
1673-
16741664
var action = new InputAction();
16751665
action.AddBinding("<Gamepad>/leftStick");
16761666
action.AddBinding("<Gamepad>/rightStick");
@@ -2588,8 +2578,6 @@ public void Actions_ChangingBindingMaskWhileEnabled_CancelsOngoingActions()
25882578
[Category("Actions")]
25892579
public void Actions_CanAddInteractionsToActions()
25902580
{
2591-
InputSystem.settings.timesliceEvents = false;
2592-
25932581
var gamepad = InputSystem.AddDevice<Gamepad>();
25942582

25952583
InputSystem.RegisterProcessor<ConstantVector2TestProcessor>();
@@ -2980,7 +2968,6 @@ public void Actions_WithoutInteraction_TriggerInResponseToMagnitude()
29802968
[Category("Actions")]
29812969
public void Actions_CanPerformHoldOnTrigger()
29822970
{
2983-
InputSystem.settings.timesliceEvents = false;
29842971
InputSystem.settings.defaultButtonPressPoint = 0.1f;
29852972

29862973
var gamepad = InputSystem.AddDevice<Gamepad>();
@@ -3025,8 +3012,6 @@ public void Actions_CanPerformHoldOnTrigger()
30253012
[Category("Actions")]
30263013
public void Actions_CanDistinguishTapAndSlowTapOnSameAction()
30273014
{
3028-
InputSystem.settings.timesliceEvents = false;
3029-
30303015
// Bindings can have more than one interaction. Depending on the interaction happening on the bound
30313016
// controls one of the interactions may initiate a phase shift and which interaction initiated the
30323017
// shift is visible on the callback.
@@ -3399,8 +3384,6 @@ public void TODO_Actions_ButtonTriggersActionOnlyAfterCrossingPressThreshold()
33993384
[Category("Actions")]
34003385
public void Actions_CanQueryStartAndPerformTime()
34013386
{
3402-
InputSystem.settings.timesliceEvents = false;
3403-
34043387
var gamepad = InputSystem.AddDevice("Gamepad");
34053388

34063389
var action = new InputAction(binding: "/gamepad/leftTrigger", interactions: "slowTap");
@@ -5056,6 +5039,125 @@ public void Actions_CanGetSourceControlWhenReadingValueFromCompositePart()
50565039
LogAssert.NoUnexpectedReceived();
50575040
}
50585041

5042+
[Test]
5043+
[Category("Actions")]
5044+
public void Actions_CanCreateButtonWithOneModifierComposite()
5045+
{
5046+
InputSystem.settings.defaultButtonPressPoint = 0.1f;
5047+
5048+
// Using gamepad so we can use the triggers and make sure
5049+
// that the composite preserves the full button value instead
5050+
// of just going 0 and 1.
5051+
var gamepad = InputSystem.AddDevice<Gamepad>();
5052+
5053+
var action = new InputAction(type: InputActionType.Button);
5054+
action.AddCompositeBinding("ButtonWithOneModifier")
5055+
.With("Modifier", "<Gamepad>/leftTrigger")
5056+
.With("Modifier", "<Gamepad>/dpad/up")
5057+
.With("Button", "<Gamepad>/rightTrigger");
5058+
5059+
action.Enable();
5060+
5061+
using (var trace = new InputActionTrace(action))
5062+
{
5063+
Set(gamepad.leftTrigger, 0.5f);
5064+
Assert.That(trace, Is.Empty);
5065+
5066+
Set(gamepad.rightTrigger, 0.75f);
5067+
Assert.That(trace,
5068+
Started(action, value: 0.75f, control: gamepad.rightTrigger)
5069+
.AndThen(Performed(action, value: 0.75f, control: gamepad.rightTrigger)));
5070+
5071+
trace.Clear();
5072+
5073+
Set(gamepad.leftTrigger, 0);
5074+
Assert.That(trace,
5075+
Canceled(action, value: 0f, control: gamepad.leftTrigger));
5076+
5077+
trace.Clear();
5078+
5079+
Press(gamepad.dpad.up);
5080+
Assert.That(trace,
5081+
Started(action, value: 0.75f, control: gamepad.dpad.up)
5082+
.AndThen(Performed(action, value: 0.75f, control: gamepad.dpad.up)));
5083+
5084+
trace.Clear();
5085+
5086+
Set(gamepad.rightTrigger, 0);
5087+
Assert.That(trace,
5088+
Canceled(action, value: 0f, control: gamepad.rightTrigger));
5089+
5090+
trace.Clear();
5091+
5092+
Release(gamepad.dpad.up);
5093+
Set(gamepad.rightTrigger, 0.456f);
5094+
5095+
Assert.That(trace, Is.Empty);
5096+
}
5097+
}
5098+
5099+
[Test]
5100+
[Category("Actions")]
5101+
public void Actions_CanCreateButtonWithTwoModifiersComposite()
5102+
{
5103+
InputSystem.settings.defaultButtonPressPoint = 0.1f;
5104+
5105+
// Using gamepad so we can use the triggers and make sure
5106+
// that the composite preserves the full button value instead
5107+
// of just going 0 and 1.
5108+
var gamepad = InputSystem.AddDevice<Gamepad>();
5109+
5110+
var action = new InputAction(type: InputActionType.Button);
5111+
action.AddCompositeBinding("ButtonWithTwoModifiers")
5112+
.With("Modifier1", "<Gamepad>/leftTrigger")
5113+
.With("Modifier1", "<Gamepad>/dpad/up")
5114+
.With("Modifier2", "<Gamepad>/rightTrigger")
5115+
.With("Modifier2", "<Gamepad>/dpad/down")
5116+
.With("Button", "<Gamepad>/leftStick/up");
5117+
5118+
action.Enable();
5119+
5120+
using (var trace = new InputActionTrace(action))
5121+
{
5122+
Set(gamepad.leftTrigger, 0.345f);
5123+
Assert.That(trace, Is.Empty);
5124+
5125+
Set(gamepad.rightTrigger, 0.456f);
5126+
Assert.That(trace, Is.Empty);
5127+
5128+
Set(gamepad.leftStick, new Vector2(0, 0.75f));
5129+
Assert.That(trace,
5130+
Started(action,
5131+
value: 0.75f,
5132+
control: gamepad.leftStick.up)
5133+
.AndThen(Performed(action,
5134+
value: 0.75f,
5135+
control: gamepad.leftStick.up)));
5136+
5137+
trace.Clear();
5138+
5139+
Press(gamepad.dpad.up);
5140+
Set(gamepad.leftTrigger, 0);
5141+
5142+
// Bit counter-intuitive but the composite yields a value every time
5143+
// one of the constituents change.
5144+
Assert.That(trace,
5145+
Performed(action,
5146+
value: 0.75f,
5147+
control: gamepad.dpad.up)
5148+
.AndThen(Performed(action,
5149+
value: 0.75f,
5150+
control: gamepad.leftTrigger)));
5151+
5152+
trace.Clear();
5153+
5154+
Set(gamepad.rightTrigger, 0);
5155+
5156+
Assert.That(trace,
5157+
Canceled(action, value: 0f, control: gamepad.rightTrigger));
5158+
}
5159+
}
5160+
50595161
[Test]
50605162
[Category("Actions")]
50615163
public void Actions_CanSerializeAndDeserializeActionMapsWithCompositeBindings()
@@ -5827,8 +5929,6 @@ public void Actions_CanIterateOverActionsInMap()
58275929
[Category("Actions")]
58285930
public void Actions_CanUseTouchWithActions()
58295931
{
5830-
InputSystem.settings.timesliceEvents = false;
5831-
58325932
var touchscreen = InputSystem.AddDevice<Touchscreen>();
58335933

58345934
var primaryTouchAction = new InputAction("PrimaryTouch" , binding: "<Touchscreen>/primaryTouch/position");
@@ -5899,8 +5999,6 @@ public void Actions_CanUseTouchWithActions()
58995999
[Category("Actions")]
59006000
public void Actions_CanDrivePointerInputFromTouchPenAndMouse()
59016001
{
5902-
InputSystem.settings.timesliceEvents = false;
5903-
59046002
// Give us known parameters for tap detection.
59056003
InputSystem.settings.defaultTapTime = 0.5f;
59066004
InputSystem.settings.tapRadius = 5;

Assets/Tests/InputSystem/CoreTests_Actions_Interactions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ public void Actions_CanPerformPressInteraction()
143143
[Category("Actions")]
144144
public void Actions_CanPerformHoldInteraction()
145145
{
146-
InputSystem.settings.timesliceEvents = false;
147-
148146
const int timeOffset = 123;
149147
runtime.currentTimeOffsetToRealtimeSinceStartup = timeOffset;
150148
runtime.currentTime = 10 + timeOffset;
@@ -256,8 +254,6 @@ public void Actions_CanPerformHoldInteraction()
256254
[Category("Actions")]
257255
public void Actions_CanPerformTapInteraction()
258256
{
259-
InputSystem.settings.timesliceEvents = false;
260-
261257
var gamepad = InputSystem.AddDevice<Gamepad>();
262258

263259
var performedReceivedCalls = 0;
@@ -315,8 +311,6 @@ public void Actions_CanPerformTapInteraction()
315311
[Category("Actions")]
316312
public void Actions_CanPerformDoubleTapInteraction()
317313
{
318-
InputSystem.settings.timesliceEvents = false;
319-
320314
var gamepad = InputSystem.AddDevice<Gamepad>();
321315

322316
runtime.advanceTimeEachDynamicUpdate = 0;

Assets/Tests/InputSystem/CoreTests_Controls.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,15 @@ public void Controls_CanQueueValueChange()
574574
[Category("Controls")]
575575
public void Controls_CanQueueValueChange_InFuture()
576576
{
577+
InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsInFixedUpdate;
577578
var gamepad = InputSystem.AddDevice<Gamepad>();
578579

579580
gamepad.leftTrigger.QueueValueChange(0.123f, 0.5);
580581

581582
InputSystem.Update();
582583
Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0).Within(0.00001));
583584

584-
runtime.currentTime = 1;
585+
runtime.currentTimeForFixedUpdate = 1;
585586
InputSystem.Update();
586587
Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.123).Within(0.00001));
587588
}

0 commit comments

Comments
 (0)