Skip to content

Commit 0a622df

Browse files
author
Rene Damm
authored
CHANGE: Refactor/clean up some APIs and add a batch of scripting API docs (#762).
1 parent 1e926a8 commit 0a622df

File tree

119 files changed

+1745
-699
lines changed

Some content is hidden

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

119 files changed

+1745
-699
lines changed

Assets/Demo/OnScreenController/Prefabs.meta

-8
This file was deleted.

Assets/Demo/SimpleDemo/SimpleController_UsingActionEventQueue.cs

-131
This file was deleted.

Assets/Demo/SimpleDemo/SimpleController_UsingActionEventQueue.cs.meta

-11
This file was deleted.

Assets/Demo/SimpleDevice.cs

+8-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine.InputSystem.Utilities;
55
using UnityEngine;
66
using UnityEngine.InputSystem.Layouts;
7+
using UnityEngine.InputSystem.LowLevel;
78

89
public struct MyDeviceState : IInputStateTypeInfo
910
{
@@ -13,14 +14,10 @@ public struct MyDeviceState : IInputStateTypeInfo
1314
[InputControl(layout = "Axis")]
1415
public float axis1;
1516

16-
public FourCC format
17-
{
18-
get { return new FourCC('M', 'Y', 'D', 'V'); }
19-
}
17+
public FourCC format => new FourCC('M', 'Y', 'D', 'V');
2018
}
2119

2220
[InputControlLayout(stateType = typeof(MyDeviceState))]
23-
//[InputPlugin]
2421
public class MyDevice : InputDevice, IInputUpdateCallbackReceiver
2522
{
2623
public ButtonControl button1 { get; private set; }
@@ -33,16 +30,13 @@ protected override void FinishSetup()
3330
base.FinishSetup();
3431
}
3532

36-
public void OnUpdate(InputUpdateType updateType)
33+
public void OnUpdate()
3734
{
38-
if (updateType == InputUpdateType.Dynamic)
39-
{
40-
var isButton1Pressed = Time.frameCount % 100 == 0;
41-
if (isButton1Pressed)
42-
InputSystem.QueueStateEvent(this, new MyDeviceState {buttons = 1});
43-
else
44-
InputSystem.QueueStateEvent(this, new MyDeviceState());
45-
}
35+
var isButton1Pressed = Time.frameCount % 100 == 0;
36+
if (isButton1Pressed)
37+
InputSystem.QueueStateEvent(this, new MyDeviceState {buttons = 1});
38+
else
39+
InputSystem.QueueStateEvent(this, new MyDeviceState());
4640
}
4741

4842
public static void Initialize()

Assets/Demo/SteamController/SteamDemoController.cs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine.InputSystem;
55
using UnityEngine.InputSystem.Controls;
66
using UnityEngine.InputSystem.Layouts;
7+
using UnityEngine.InputSystem.LowLevel;
78
using UnityEngine.InputSystem.Utilities;
89
using UnityEngine.InputSystem.Steam;
910
#if UNITY_EDITOR

Assets/QA/Input_Test/IMETest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using UnityEngine;
22
using UnityEngine.InputSystem;
3+
using UnityEngine.InputSystem.LowLevel;
34
using UnityEngine.UI;
45

56
////FIXME: will not work properly when there are multiple keyboards
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"displayName": "On-Screen Controls Sample",
3+
"description": "Demonstrates a simple setup for an on-screen joystick."
4+
}

Assets/Samples/VisualizerSamples/.sample.json

-4
This file was deleted.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"displayName": "Visualizers",
3+
"description": "Several example visualizations of input controls/devices and input actions."
4+
}

Assets/TanksDemo/Assets/Scripts/Tank/TankMovement.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEngine.InputSystem.PlayerInput;
2+
using UnityEngine.InputSystem;
33
using UnityEngine.SceneManagement;
44

55
public class TankMovement : MonoBehaviour

Assets/TanksDemo/Assets/Scripts/Tank/TankShooting.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
using UnityEngine.InputSystem.PlayerInput;
2+
using UnityEngine.InputSystem;
33
using UnityEngine.UI;
44

55

Assets/Tests/InputSystem/APIVerificationTests.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Mono.Cecil;
88
using UnityEditor.PackageManager.DocumentationTools.UI;
99
using UnityEngine.InputSystem;
10+
using UnityEngine.InputSystem.LowLevel;
1011
using HtmlAgilityPack;
1112

1213
class APIVerificationTests
@@ -37,9 +38,9 @@ private bool IsTypeWhichCanHavePublicFields(TypeReference type)
3738

3839
if (
3940
// These have fields popuplated by reflection in the Input System
40-
type.FullName == typeof(UnityEngine.InputSystem.InputProcessor).FullName ||
41-
type.FullName == typeof(UnityEngine.InputSystem.InputControl).FullName ||
42-
type.FullName == typeof(UnityEngine.InputSystem.InputBindingComposite).FullName
41+
type.FullName == typeof(InputProcessor).FullName ||
42+
type.FullName == typeof(InputControl).FullName ||
43+
type.FullName == typeof(InputBindingComposite).FullName
4344
)
4445
return true;
4546

@@ -52,15 +53,15 @@ private bool IsTypeWhichCanHavePublicFields(TypeReference type)
5253

5354
if (
5455
// Interactions have fields populated by reflection in the Input System
55-
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(UnityEngine.InputSystem.IInputInteraction).FullName) ||
56+
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(IInputInteraction).FullName) ||
5657

5758
// Input state structures use fields for the memory layout and construct Input Controls from the fields.
58-
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(UnityEngine.InputSystem.IInputStateTypeInfo).FullName) ||
59+
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(IInputStateTypeInfo).FullName) ||
5960

6061
// These use fields for the explicit memory layout, and have a member for the base type. If we exposed that via a property,
6162
// base type values could not be written individually.
62-
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(UnityEngine.InputSystem.LowLevel.IInputDeviceCommandInfo).FullName) ||
63-
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(UnityEngine.InputSystem.LowLevel.IInputEventTypeInfo).FullName) ||
63+
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(IInputDeviceCommandInfo).FullName) ||
64+
resolved.Interfaces.Any(i => i.InterfaceType.FullName == typeof(IInputEventTypeInfo).FullName) ||
6465

6566
// serializable types may depend on the field names to match serialized data (eg. Json)
6667
resolved.Attributes.HasFlag(TypeAttributes.Serializable)
@@ -77,7 +78,7 @@ private bool IsTypeWhichCanHavePublicFields(TypeReference type)
7778

7879
private IEnumerable<TypeDefinition> GetInputSystemPublicTypes()
7980
{
80-
var codeBase = typeof(UnityEngine.InputSystem.InputSystem).Assembly.CodeBase;
81+
var codeBase = typeof(InputSystem).Assembly.CodeBase;
8182
var uri = new UriBuilder(codeBase);
8283
var path = Uri.UnescapeDataString(uri.Path);
8384
var asmDef = AssemblyDefinition.ReadAssembly(path);
@@ -232,12 +233,14 @@ bool IgnoreTypeForDocs(TypeDefinition type)
232233
#if UNITY_EDITOR_WIN
233234
type.FullName == typeof(UnityEngine.InputSystem.XInput.XInputControllerWindows).FullName ||
234235
#endif
236+
#if UNITY_ENABLE_STEAM_CONTROLLER_SUPPORT
235237
type.FullName == typeof(UnityEngine.InputSystem.Steam.ISteamControllerAPI).FullName ||
236238
type.FullName == typeof(UnityEngine.InputSystem.Steam.SteamController).FullName ||
237239
type.FullName == typeof(UnityEngine.InputSystem.Steam.SteamDigitalActionData).FullName ||
238240
type.FullName == typeof(UnityEngine.InputSystem.Steam.SteamAnalogActionData).FullName ||
239241
type.FullName == typeof(UnityEngine.InputSystem.Steam.SteamHandle<>).FullName ||
240242
type.FullName == typeof(UnityEngine.InputSystem.Steam.Editor.SteamIGAConverter).FullName ||
243+
#endif
241244
type.FullName == typeof(UnityEngine.InputSystem.PS4.PS4TouchControl).FullName ||
242245
type.FullName == typeof(UnityEngine.InputSystem.PS4.DualShockGamepadPS4).FullName ||
243246
type.FullName == typeof(UnityEngine.InputSystem.PS4.MoveControllerPS4).FullName ||

Assets/Tests/InputSystem/CoreTests_Actions.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ public void Process(ref InputInteractionContext context)
13921392
{
13931393
var actuated = context.ControlIsActuated();
13941394
if (!actuated && m_WaitingForRelease)
1395-
context.PerformedAndGoBackToWaiting();
1395+
context.Performed();
13961396
else if (actuated)
13971397
m_WaitingForRelease = true;
13981398
}
@@ -2592,7 +2592,7 @@ public void Actions_CanAddInteractionsToActions()
25922592

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

2595-
InputSystem.RegisterControlProcessor<ConstantVector2TestProcessor>();
2595+
InputSystem.RegisterProcessor<ConstantVector2TestProcessor>();
25962596
var action = new InputAction(interactions: "Tap(duration=0.123)");
25972597
action.AddBinding("<Gamepad>/buttonSouth");
25982598
action.Enable();
@@ -2619,7 +2619,7 @@ public void Actions_CanAddProcessorsToActions()
26192619
{
26202620
var gamepad = InputSystem.AddDevice<Gamepad>();
26212621

2622-
InputSystem.RegisterControlProcessor<ConstantVector2TestProcessor>();
2622+
InputSystem.RegisterProcessor<ConstantVector2TestProcessor>();
26232623
var action = new InputAction(processors: "ConstantVector2Test");
26242624
action.AddBinding("<Gamepad>/leftStick");
26252625
action.Enable();
@@ -2645,7 +2645,7 @@ public void Actions_IncompatibleProcessorIsIgnored()
26452645
{
26462646
var gamepad = InputSystem.AddDevice<Gamepad>();
26472647

2648-
InputSystem.RegisterControlProcessor<ConstantVector2TestProcessor>();
2648+
InputSystem.RegisterProcessor<ConstantVector2TestProcessor>();
26492649
var action = new InputAction(processors: "ConstantVector2Test");
26502650
action.AddBinding("<Gamepad>/leftStick/x");
26512651
action.Enable();
@@ -2681,7 +2681,7 @@ public void Actions_CanAddProcessorsToBindings()
26812681
{
26822682
var gamepad = InputSystem.AddDevice<Gamepad>();
26832683

2684-
InputSystem.RegisterControlProcessor<ConstantVector2TestProcessor>();
2684+
InputSystem.RegisterProcessor<ConstantVector2TestProcessor>();
26852685
var action = new InputAction();
26862686
action.AddBinding("<Gamepad>/leftStick").WithProcessor<ConstantVector2TestProcessor>();
26872687
action.Enable();
@@ -4669,7 +4669,7 @@ private class LogInteraction : IInputInteraction
46694669
public void Process(ref InputInteractionContext context)
46704670
{
46714671
Debug.LogAssertion("LogInteraction.Process");
4672-
context.PerformedAndGoBackToWaiting();
4672+
context.Performed();
46734673
}
46744674

46754675
public void Reset()

0 commit comments

Comments
 (0)