Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanunity committed Jul 24, 2024
2 parents 73feff4 + 8714f70 commit 4d0196d
Show file tree
Hide file tree
Showing 42 changed files with 1,803 additions and 62 deletions.
1,588 changes: 1,588 additions & 0 deletions .yamato/PVPexemptions.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yamato/upm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ publish{% cycle "", "_dryrun" %}:
- upm-ci package pack --package-path ./Packages/com.unity.inputsystem/
- upm-ci package test --package-path ./Packages/com.unity.inputsystem/ -u 2019.4
- upm-ci package publish --package-path ./Packages/com.unity.inputsystem/ {% cycle "", "--dry-run" %}
- upm-pvp xray --packages "upm-ci~/packages/*.tgz" --results upm-ci~/xray
- upm-pvp require "supported rme" --no-report --allow-missing --results upm-ci~/xray --exemptions upm-ci~/xray/new-exemptions.json
- upm-pvp require "supported rme ./.yamato/PVPexemptions.json" --allow-missing --results upm-ci~/xray
artifacts:
artifacts:
paths:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Samples/CustomComposite/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Custom Binding Composite",
"description": "Shows how to implement a custom composite binding."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/CustomDevice/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Custom Device",
"description": "Shows how to implement a custom input device."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/CustomDeviceUsages/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Custom Device Usages",
"description": "Shows how to tag devices with custom usage strings that can be used, for example, to distinguish multiple instances of the same type of device (e.g. 'Gamepad') based on how the device is used (e.g. 'Player1' vs 'Player2' or 'LeftHand' vs 'RightHand')."
}
}
3 changes: 0 additions & 3 deletions Assets/Samples/CustomDeviceUsages/.sample.json.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Samples/GamepadMouseCursor/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Gamepad Mouse Cursor",
"description": "An example that shows how to use the gamepad for driving a mouse cursor for use with UIs."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/InGameHints/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "In-Game Hints",
"description": "Demonstrates how to create in-game hints in the UI which reflect current bindings and active control schemes."
}
}
5 changes: 2 additions & 3 deletions 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.9.0
// version 1.10.0
// from Assets/Samples/InGameHints/InGameHintsActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand All @@ -14,7 +14,6 @@
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine;

namespace UnityEngine.InputSystem.Samples.InGameHints
{
Expand Down Expand Up @@ -275,7 +274,7 @@ public @InGameHintsActions()

~@InGameHintsActions()
{
Debug.Assert(!m_Gameplay.enabled, "This will cause a leak and performance issues, InGameHintsActions.Gameplay.Disable() has not been called.");
UnityEngine.Debug.Assert(!m_Gameplay.enabled, "This will cause a leak and performance issues, InGameHintsActions.Gameplay.Disable() has not been called.");
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion Assets/Samples/InputDeviceTester/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "InputDeviceTester",
"description": "A scene containing UI to visualize the controls on various supported input devices."
}
}
3 changes: 0 additions & 3 deletions Assets/Samples/InputDeviceTester/.sample.json.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Samples/InputRecorder/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Input Recorder",
"description": "Shows how to capture and replay input events. Also useful by itself to debug input event sequences."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/OnScreenControls/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "On-Screen Controls",
"description": "Demonstrates a simple setup for an on-screen joystick."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/RebindingUI/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Rebinding UI",
"description": "An example UI component that demonstrates how to create UI for rebinding actions."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/SimpleDemo/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Simple Demo",
"description": "A walkthrough of a simple character controller that demonstrates several techniques for working with the input system. See the README.md file in the sample for details."
}
}
3 changes: 0 additions & 3 deletions Assets/Samples/SimpleDemo/.sample.json.meta

This file was deleted.

5 changes: 2 additions & 3 deletions 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.9.0
// version 1.10.0
// from Assets/Samples/SimpleDemo/SimpleControls.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand All @@ -14,7 +14,6 @@
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine;

public partial class @SimpleControls: IInputActionCollection2, IDisposable
{
Expand Down Expand Up @@ -170,7 +169,7 @@ public @SimpleControls()

~@SimpleControls()
{
Debug.Assert(!m_gameplay.enabled, "This will cause a leak and performance issues, SimpleControls.gameplay.Disable() has not been called.");
UnityEngine.Debug.Assert(!m_gameplay.enabled, "This will cause a leak and performance issues, SimpleControls.gameplay.Disable() has not been called.");
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion Assets/Samples/SimpleMultiplayer/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Simple Multiplayer",
"description": "Demonstrates how to set up a simple local multiplayer scenario."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/TouchSamples/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Touch Samples",
"description": "A series of sample scenes for using touch input with the Input System package. This sample is not actually part of the package, but needs to be downloaded."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/UIvsGameInput/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "UI vs. Game Input",
"description": "An example that shows how to deal with ambiguities that may arrise when overlaying interactive UI elements on top of a game scene."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/UnityRemote/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Unity Remote",
"description": "An example with a simple scene for trying out the Unity Remote app."
}
}
2 changes: 1 addition & 1 deletion Assets/Samples/Visualizers/.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"displayName": "Visualizers",
"description": "Several example visualizations of input controls/devices and input actions."
}
}
30 changes: 30 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5250,6 +5250,36 @@ public void Actions_CanAddBindingsToActions_ToExistingComposite()
composite.InsertPartBinding("Negative", "<Keyboard>/leftArrow");
composite.InsertPartBinding("Positive", "<Keyboard>/rightArrow");

ValidateCompositeBindingsOnAction(action);
}

[Test]
[Category("Actions")]
[Description("ISXB-494 Changing composite of action inside a map triggered exception that wasn't caught by previous test.")]
public void Actions_CanChangeBindingPart_ToExistingCompositeInActionMap()
{
var keyboard = InputSystem.AddDevice<Keyboard>();

var actionMap = new InputActionMap("Map");
var action = actionMap.AddAction("Action", InputActionType.Value, expectedControlLayout: "Axis");

action.AddCompositeBinding("Axis")
.With("Negative", "<Keyboard>/a")
.With("Positive", "<Keyboard>/d");

Assert.That(action.bindings, Has.Count.EqualTo(3));
Assert.That(action.controls, Is.EquivalentTo(new[] { keyboard.aKey, keyboard.dKey }));

var composite = action.ChangeCompositeBinding("Axis");

composite.InsertPartBinding("Negative", "<Keyboard>/leftArrow");
composite.InsertPartBinding("Positive", "<Keyboard>/rightArrow");

ValidateCompositeBindingsOnAction(action);
}

private void ValidateCompositeBindingsOnAction(InputAction action)
{
Assert.That(action.bindings, Has.Count.EqualTo(5));
Assert.That(action.bindings,
Has.Exactly(1).With.Property("isComposite").EqualTo(true).And.With.Property("isPartOfComposite").EqualTo(false).And.With
Expand Down
42 changes: 42 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Actions_Interactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,48 @@ public void Actions_WhenTransitioningFromOneInteractionToNext_GetCallbacks()
}
}

// https://jira.unity3d.com/browse/ISXB-310
[Test]
[Category("Actions")]
public void Actions_WhenTransitioningFromOneInteractionToNextAlreadyPerformed_GetCallbacksAndResetOtherInteractions()
{
ResetTime();

var gamepad = InputSystem.AddDevice<Gamepad>();

var action = new InputAction("test", InputActionType.Button, binding: "<Gamepad>/buttonSouth",
interactions: "multiTap(tapCount=3),multiTap,Tap");
action.Enable();

using (var trace = new InputActionTrace(action))
{
// Trigger the second interaction with a double tap which also internally performs a tap on the third one.
PressAndRelease(gamepad.buttonSouth);
PressAndRelease(gamepad.buttonSouth, 0.2);
currentTime = 2;
InputSystem.Update();
Assert.That(trace,
Started<MultiTapInteraction>(action, gamepad.buttonSouth, time: 0)
.AndThen(Canceled<MultiTapInteraction>(action, gamepad.buttonSouth, duration: 2))
.AndThen(Started<MultiTapInteraction>(action, gamepad.buttonSouth))
.AndThen(Performed<MultiTapInteraction>(action, gamepad.buttonSouth, duration: 0.2)));

trace.Clear();

// Trigger the third interaction with a tap and ensure that doesn't come from the previous one.
PressAndRelease(gamepad.buttonSouth, time: 4);
currentTime = 6;
InputSystem.Update();
Assert.That(trace,
Started<MultiTapInteraction>(action, gamepad.buttonSouth, time: 4)
.AndThen(Canceled<MultiTapInteraction>(action, gamepad.buttonSouth, duration: 2))
.AndThen(Started<MultiTapInteraction>(action, gamepad.buttonSouth, time: 4))
.AndThen(Canceled<MultiTapInteraction>(action, gamepad.buttonSouth, duration: 2))
.AndThen(Started<TapInteraction>(action, gamepad.buttonSouth, time: 4))
.AndThen(Performed<TapInteraction>(action, gamepad.buttonSouth, time: 4)));
}
}

[Test]
[Category("Actions")]
public void Actions_CanPerformPressInteraction()
Expand Down
5 changes: 2 additions & 3 deletions Assets/Tests/InputSystem/InputActionCodeGeneratorActions.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.9.0
// version 1.10.0
// from Assets/Tests/InputSystem/InputActionCodeGeneratorActions.inputactions
//
// Changes to this file may cause incorrect behavior and will be lost if
Expand All @@ -14,7 +14,6 @@
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine;

public partial class @InputActionCodeGeneratorActions: IInputActionCollection2, IDisposable
{
Expand Down Expand Up @@ -83,7 +82,7 @@ public @InputActionCodeGeneratorActions()

~@InputActionCodeGeneratorActions()
{
Debug.Assert(!m_gameplay.enabled, "This will cause a leak and performance issues, InputActionCodeGeneratorActions.gameplay.Disable() has not been called.");
UnityEngine.Debug.Assert(!m_gameplay.enabled, "This will cause a leak and performance issues, InputActionCodeGeneratorActions.gameplay.Disable() has not been called.");
}

public void Dispose()
Expand Down
30 changes: 27 additions & 3 deletions Assets/Tests/InputSystem/Plugins/UITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p
Assert.That(scene.rightChildReceiver.events[0].pointerData.pointerId, Is.EqualTo(pointerId));
Assert.That(scene.rightChildReceiver.events[0].pointerData.position, Is.EqualTo(thirdScreenPosition).Using(Vector2EqualityComparer.Instance));
Assert.That(scene.rightChildReceiver.events[0].pointerData.delta, Is.EqualTo(Vector2.zero));
Assert.That(scene.rightChildReceiver.events[0].pointerData.scrollDelta, Is.EqualTo(Vector2.one).Using(Vector2EqualityComparer.Instance));
Assert.That(scene.rightChildReceiver.events[0].pointerData.scrollDelta, Is.EqualTo(Vector2.one * scene.uiModule.scrollDeltaPerTick).Using(Vector2EqualityComparer.Instance));
Assert.That(scene.rightChildReceiver.events[0].pointerData.pointerEnter, Is.SameAs(scene.rightGameObject));
Assert.That(scene.rightChildReceiver.events[0].pointerData.pointerDrag, Is.Null);
Assert.That(scene.rightChildReceiver.events[0].pointerData.pointerPress, Is.Null);
Expand Down Expand Up @@ -1201,16 +1201,40 @@ public IEnumerator UI_ReceivesNormalizedScrollWheelDelta(float scrollWheelDeltaP
Set(mouse.scroll, new Vector2(0, scrollWheelDeltaPerTick));
yield return null;

// UI should receive scroll delta in the [-1, 1] range.
// UI should receive scroll delta in the range defined by InputSystemUIInputModule.
Assert.That(scene.leftChildReceiver.events,
EventSequence(
OneEvent("type", EventType.Scroll),
AllEvents("position", scene.From640x480ToScreen(100, 100)),
AllEvents("scrollDelta", Vector2.up)
AllEvents("scrollDelta", Vector2.up * scene.uiModule.scrollDeltaPerTick)
)
);
}

#endif

#if UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA
[TestCase(1)]
[TestCase(2)]
[Category("UI")]
public void UI_ConvertPointerEventScrollDeltaToTicks_AppliesScrollWheelMultiplier(float multiplier)
{
var scene = CreateTestUI();
scene.uiModule.scrollDeltaPerTick = multiplier;
var ticks = scene.uiModule.ConvertPointerEventScrollDeltaToTicks(Vector2.one);
Assert.That(ticks, Is.EqualTo(Vector2.one / multiplier).Within(0.001f));
}

[TestCase(0)]
[TestCase(1)]
[Category("UI")]
public void UI_ConvertPointerEventScrollDeltaToTicks_ReturnsZeroIfScrollDeltaPerTickIsZero(float delta)
{
var scene = CreateTestUI();
scene.uiModule.scrollDeltaPerTick = 0;
Assert.That(scene.uiModule.ConvertPointerEventScrollDeltaToTicks(Vector2.one * delta), Is.EqualTo(Vector2.zero));
}

#endif

[UnityTest]
Expand Down
5 changes: 5 additions & 0 deletions Assets/Tests/InputSystem/Unity.InputSystem.Tests.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
"name": "Unity",
"expression": "6000.0.9",
"define": "UNITY_INPUT_SYSTEM_PLATFORM_SCROLL_DELTA"
},
{
"name": "Unity",
"expression": "6000.0.11",
"define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA"
}
],
"noEngineReferences": false
Expand Down
Loading

0 comments on commit 4d0196d

Please sign in to comment.