diff --git a/Assets/QA/Tests/XRDeviceActions/_SharedScripts/Handedness.cs b/Assets/QA/Tests/XRDeviceActions/_SharedScripts/Handedness.cs index ff30762c36..6944cfa2f2 100644 --- a/Assets/QA/Tests/XRDeviceActions/_SharedScripts/Handedness.cs +++ b/Assets/QA/Tests/XRDeviceActions/_SharedScripts/Handedness.cs @@ -12,8 +12,8 @@ public void Update() { var handedness = ""; - var leftHand = InputSystem.GetDevice(CommonUsages.LeftHand); - var rightHand = InputSystem.GetDevice(CommonUsages.RightHand); + var leftHand = InputSystem.GetDevice(Usages.LeftHand); + var rightHand = InputSystem.GetDevice(Usages.RightHand); if (leftHand != null) handedness += "Left "; diff --git a/Assets/QA/Tests/XRHaptics/XRHaptics.cs b/Assets/QA/Tests/XRHaptics/XRHaptics.cs index c67cb5c231..b6f69894c5 100644 --- a/Assets/QA/Tests/XRHaptics/XRHaptics.cs +++ b/Assets/QA/Tests/XRHaptics/XRHaptics.cs @@ -28,9 +28,9 @@ private enum RumbleState public void Update() { - var leftHandController = InputSystem.GetDevice(CommonUsages.LeftHand); + var leftHandController = InputSystem.GetDevice(Usages.LeftHand); leftHapticDetected.color = leftHandController != null ? Color.red : Color.white; - var rightHandController = InputSystem.GetDevice(CommonUsages.RightHand); + var rightHandController = InputSystem.GetDevice(Usages.RightHand); rightHapticDetected.color = rightHandController != null ? Color.red : Color.white; UpdateTimer(); @@ -50,7 +50,7 @@ private void UpdateTimer() switch (state) { case RumbleState.Left: - controller = InputSystem.GetDevice(CommonUsages.LeftHand); + controller = InputSystem.GetDevice(Usages.LeftHand); controller.SendImpulse(1f, m_RumblePeriod); leftTryingToRumble.color = Color.red; leftTryingToRumbleHalf.color = Color.white; @@ -59,7 +59,7 @@ private void UpdateTimer() state = RumbleState.LeftHalf; break; case RumbleState.LeftHalf: - controller = InputSystem.GetDevice(CommonUsages.LeftHand); + controller = InputSystem.GetDevice(Usages.LeftHand); controller.SendImpulse(0.5f, m_RumblePeriod); leftTryingToRumble.color = Color.white; @@ -69,7 +69,7 @@ private void UpdateTimer() state = RumbleState.Right; break; case RumbleState.Right: - controller = InputSystem.GetDevice(CommonUsages.RightHand); + controller = InputSystem.GetDevice(Usages.RightHand); controller.SendImpulse(1f, m_RumblePeriod); leftTryingToRumble.color = Color.white; leftTryingToRumbleHalf.color = Color.white; @@ -78,7 +78,7 @@ private void UpdateTimer() state = RumbleState.RightHalf; break; case RumbleState.RightHalf: - controller = InputSystem.GetDevice(CommonUsages.RightHand); + controller = InputSystem.GetDevice(Usages.RightHand); controller.SendImpulse(0.5f, m_RumblePeriod); leftTryingToRumble.color = Color.white; leftTryingToRumbleHalf.color = Color.white; diff --git a/Assets/Samples/CustomDeviceUsages/CustomDeviceUsages.cs b/Assets/Samples/CustomDeviceUsages/CustomDeviceUsages.cs index 8e9f5d723d..8e0a9c8ae3 100644 --- a/Assets/Samples/CustomDeviceUsages/CustomDeviceUsages.cs +++ b/Assets/Samples/CustomDeviceUsages/CustomDeviceUsages.cs @@ -52,14 +52,14 @@ private static void Initialize() // The layout override is just a fragment of layout information // in JSON format. // - // The key property here is "commonUsages" which tells the system + // The key property here is "usages" which tells the system // that "Player1" and "Player2" are possible usages applied to devices // using the given layout ("Gamepad" in our case). InputSystem.RegisterLayoutOverride(@" { ""name"" : ""GamepadPlayerUsageTags"", ""extend"" : ""Gamepad"", - ""commonUsages"" : [ + ""usages"" : [ ""Player1"", ""Player2"" ] } diff --git a/Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs b/Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs index 2df0feaefa..f72287965f 100644 --- a/Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs +++ b/Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs @@ -776,7 +776,7 @@ public void Actions_InteractiveRebinding_IfDeviceHasUsages_UsagesAreAppliedToOve var action = new InputAction(binding: "/buttonSouth"); var rightHand = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(rightHand, CommonUsages.RightHand); + InputSystem.SetDeviceUsage(rightHand, Usages.RightHand); using (var rebind = new InputActionRebindingExtensions.RebindingOperation().WithAction(action).Start()) { @@ -1122,8 +1122,8 @@ public void Actions_InteractiveRebinding_IfDeviceHasMultipleUsages_UsagesAreAppl var rightHandVertical = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(rightHandVertical, CommonUsages.RightHand); - InputSystem.AddDeviceUsage(rightHandVertical, CommonUsages.Vertical); + InputSystem.SetDeviceUsage(rightHandVertical, Usages.RightHand); + InputSystem.AddDeviceUsage(rightHandVertical, Usages.Vertical); using (var rebind = new InputActionRebindingExtensions.RebindingOperation().WithAction(action).Start()) { diff --git a/Assets/Tests/InputSystem/CoreTests_Devices.cs b/Assets/Tests/InputSystem/CoreTests_Devices.cs index 580352dad2..95547a8d3c 100644 --- a/Assets/Tests/InputSystem/CoreTests_Devices.cs +++ b/Assets/Tests/InputSystem/CoreTests_Devices.cs @@ -210,7 +210,7 @@ public void Devices_ChangingUsageOfDevice_SendsDeviceChangeNotification() receivedDeviceChange = c; }; - InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(device, Usages.LeftHand); Assert.That(receivedDevice, Is.SameAs(device)); Assert.That(receivedDeviceChange, Is.EqualTo(InputDeviceChange.UsageChanged)); @@ -223,7 +223,7 @@ public void Devices_CanFindDeviceByUsage() InputSystem.AddDevice(); var device = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(device, Usages.LeftHand); using (var controls = InputSystem.FindControls("/{LeftHand}")) { @@ -292,8 +292,8 @@ public void Devices_CanFindDeviceByMultipleUsages() InputSystem.AddDevice(); var device = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand); - InputSystem.AddDeviceUsage(device, CommonUsages.Vertical); + InputSystem.SetDeviceUsage(device, Usages.LeftHand); + InputSystem.AddDeviceUsage(device, Usages.Vertical); // Device should be found even if the one of the usages is specified using (var controls = InputSystem.FindControls("/{LeftHand}")) @@ -328,10 +328,10 @@ public void Devices_CanFindDeviceByMultipleUsages() public void Devices_CanFindDeviceByUsageAndLayout() { var gamepad = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(gamepad, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(gamepad, Usages.LeftHand); var keyboard = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(keyboard, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(keyboard, Usages.LeftHand); using (var controls = InputSystem.FindControls("/{LeftHand}")) { @@ -925,11 +925,11 @@ public void Devices_CanLookUpDeviceByTypeAndUsage() var rightHand = InputSystem.AddDevice(); InputSystem.AddDevice(); // Noise. - InputSystem.SetDeviceUsage(leftHand, CommonUsages.LeftHand); - InputSystem.SetDeviceUsage(rightHand, CommonUsages.RightHand); + InputSystem.SetDeviceUsage(leftHand, Usages.LeftHand); + InputSystem.SetDeviceUsage(rightHand, Usages.RightHand); - Assert.That(InputSystem.GetDevice(CommonUsages.LeftHand), Is.SameAs(leftHand)); - Assert.That(InputSystem.GetDevice(CommonUsages.RightHand), Is.SameAs(rightHand)); + Assert.That(InputSystem.GetDevice(Usages.LeftHand), Is.SameAs(leftHand)); + Assert.That(InputSystem.GetDevice(Usages.RightHand), Is.SameAs(rightHand)); } [Test] diff --git a/Assets/Tests/InputSystem/CoreTests_Editor.cs b/Assets/Tests/InputSystem/CoreTests_Editor.cs index 273d9b1bda..aed651ec36 100644 --- a/Assets/Tests/InputSystem/CoreTests_Editor.cs +++ b/Assets/Tests/InputSystem/CoreTests_Editor.cs @@ -217,14 +217,14 @@ public void Editor_DomainReload_CanRestoreDevicesBuiltWithDynamicallyGeneratedLa public void Editor_DomainReload_PreservesUsagesOnDevices() { var device = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(device, Usages.LeftHand); SimulateDomainReload(); var newDevice = InputSystem.devices[0]; Assert.That(newDevice.usages, Has.Count.EqualTo(1)); - Assert.That(newDevice.usages, Has.Exactly(1).EqualTo(CommonUsages.LeftHand)); + Assert.That(newDevice.usages, Has.Exactly(1).EqualTo(Usages.LeftHand)); } // We have code that will automatically query the enabled state of devices on creation diff --git a/Assets/Tests/InputSystem/CoreTests_Layouts.cs b/Assets/Tests/InputSystem/CoreTests_Layouts.cs index 38af2abaaa..5d56c6cff4 100644 --- a/Assets/Tests/InputSystem/CoreTests_Layouts.cs +++ b/Assets/Tests/InputSystem/CoreTests_Layouts.cs @@ -185,7 +185,7 @@ public void Layouts_CanSetUsagesThroughControlAttribute() { var gamepad = InputSystem.AddDevice(); - Assert.That(gamepad.leftStick.usages, Has.Exactly(1).EqualTo(CommonUsages.Primary2DMotion)); + Assert.That(gamepad.leftStick.usages, Has.Exactly(1).EqualTo(Usages.Primary2DMotion)); } [Test] @@ -447,7 +447,7 @@ public void Layouts_BooleanParameterDefaultsToTrueIfValueOmitted() Assert.That(device.leftStick.x.normalize, Is.True); } - [InputControlLayout(commonUsages = new[] {"LeftHand", "RightHand"})] + [InputControlLayout(usages = new[] {"LeftHand", "RightHand"})] private class DeviceWithCommonUsages : InputDevice { } @@ -460,7 +460,7 @@ public void Layouts_CanSpecifyCommonUsagesForDevices() { ""name"" : ""DerivedDevice"", ""extend"" : ""BaseDevice"", - ""commonUsages"" : [ ""LeftToe"" ] + ""usages"" : [ ""LeftToe"" ] } "; @@ -469,10 +469,10 @@ public void Layouts_CanSpecifyCommonUsagesForDevices() var layout = InputSystem.LoadLayout("DerivedDevice"); - Assert.That(layout.commonUsages, Has.Count.EqualTo(3)); - Assert.That(layout.commonUsages[0], Is.EqualTo(CommonUsages.LeftHand)); - Assert.That(layout.commonUsages[1], Is.EqualTo(CommonUsages.RightHand)); - Assert.That(layout.commonUsages[2], Is.EqualTo(new InternedString("LeftToe"))); + Assert.That(layout.usages, Has.Count.EqualTo(3)); + Assert.That(layout.usages[0], Is.EqualTo(Usages.LeftHand)); + Assert.That(layout.usages[1], Is.EqualTo(Usages.RightHand)); + Assert.That(layout.usages[2], Is.EqualTo(new InternedString("LeftToe"))); } [Test] @@ -1084,12 +1084,12 @@ public void Layouts_ApplyingOverride_DoesNotAlterExistingInheritanceHierarchy() [Category("Layouts")] public void Layouts_CanOverrideCommonUsagesOnExistingLayout() { - // Change all Gamepads to have the common usages "A", "B", and "C". + // Change all Gamepads to have the usages "A", "B", and "C". const string json = @" { ""name"" : ""Overrides"", ""extend"" : ""Gamepad"", - ""commonUsages"" : [ ""A"", ""B"", ""C"" ] + ""usages"" : [ ""A"", ""B"", ""C"" ] } "; @@ -1098,10 +1098,10 @@ public void Layouts_CanOverrideCommonUsagesOnExistingLayout() var layout = InputSystem.LoadLayout("Gamepad"); Assert.That(layout.appliedOverrides, Is.EquivalentTo(new[] {new InternedString("Overrides")})); - Assert.That(layout.commonUsages.Count, Is.EqualTo(3)); - Assert.That(layout.commonUsages, Has.Exactly(1).EqualTo(new InternedString("A"))); - Assert.That(layout.commonUsages, Has.Exactly(1).EqualTo(new InternedString("B"))); - Assert.That(layout.commonUsages, Has.Exactly(1).EqualTo(new InternedString("C"))); + Assert.That(layout.usages.Count, Is.EqualTo(3)); + Assert.That(layout.usages, Has.Exactly(1).EqualTo(new InternedString("A"))); + Assert.That(layout.usages, Has.Exactly(1).EqualTo(new InternedString("B"))); + Assert.That(layout.usages, Has.Exactly(1).EqualTo(new InternedString("C"))); // Applying the override should not have created a cycle. Assert.That(layout.baseLayouts, Does.Not.Contains(new InternedString("Gamepad"))); @@ -2743,37 +2743,37 @@ public void Layouts_CanConfigureDeviceUsages() Assert.That(gamepad.usages, Is.Empty); // Set "Vertical" as usage - InputSystem.SetDeviceUsage(gamepad, CommonUsages.Vertical); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Vertical)); + InputSystem.SetDeviceUsage(gamepad, Usages.Vertical); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Vertical)); // Change usage with "Horizontal" - InputSystem.SetDeviceUsage(gamepad, CommonUsages.Horizontal); - Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(CommonUsages.Vertical)); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Horizontal)); + InputSystem.SetDeviceUsage(gamepad, Usages.Horizontal); + Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(Usages.Vertical)); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Horizontal)); // Add "Vertical" to usages - InputSystem.AddDeviceUsage(gamepad, CommonUsages.Vertical); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Vertical)); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Horizontal)); + InputSystem.AddDeviceUsage(gamepad, Usages.Vertical); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Vertical)); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Horizontal)); // Set "Horizontal" as the only one usage - InputSystem.SetDeviceUsage(gamepad, CommonUsages.Horizontal); - Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(CommonUsages.Vertical)); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Horizontal)); + InputSystem.SetDeviceUsage(gamepad, Usages.Horizontal); + Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(Usages.Vertical)); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Horizontal)); // Try to add "Horizontal" again - InputSystem.AddDeviceUsage(gamepad, CommonUsages.Horizontal); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Horizontal)); + InputSystem.AddDeviceUsage(gamepad, Usages.Horizontal); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Horizontal)); // Remove the existed "Horizontal" usage from usages - InputSystem.AddDeviceUsage(gamepad, CommonUsages.Vertical); - InputSystem.RemoveDeviceUsage(gamepad, CommonUsages.Horizontal); - Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.Vertical)); - Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(CommonUsages.Horizontal)); + InputSystem.AddDeviceUsage(gamepad, Usages.Vertical); + InputSystem.RemoveDeviceUsage(gamepad, Usages.Horizontal); + Assert.That(gamepad.usages, Has.Exactly(1).EqualTo(Usages.Vertical)); + Assert.That(gamepad.usages, Has.Exactly(0).EqualTo(Usages.Horizontal)); - InputSystem.RemoveDeviceUsage(gamepad, CommonUsages.Vertical); + InputSystem.RemoveDeviceUsage(gamepad, Usages.Vertical); Assert.That(gamepad.usages, Is.Empty); } diff --git a/Assets/Tests/InputSystem/CoreTests_Remoting.cs b/Assets/Tests/InputSystem/CoreTests_Remoting.cs index e8eb988e0a..fefde857aa 100644 --- a/Assets/Tests/InputSystem/CoreTests_Remoting.cs +++ b/Assets/Tests/InputSystem/CoreTests_Remoting.cs @@ -159,15 +159,15 @@ public void Remote_RemovingDevice_WillRemoveItFromRemotes() public void Remote_DevicesWithExistingUsage_WillUpdateSendToRemote() { var gamepad = InputSystem.AddDevice(); - InputSystem.SetDeviceUsage(gamepad, CommonUsages.LeftHand); - InputSystem.AddDeviceUsage(gamepad, CommonUsages.RightHand); + InputSystem.SetDeviceUsage(gamepad, Usages.LeftHand); + InputSystem.AddDeviceUsage(gamepad, Usages.RightHand); using (var remote = new FakeRemote()) { var remoteGamepad = (Gamepad)remote.remoteManager.devices[0]; Assert.That(remoteGamepad.usages, Has.Count.EqualTo(2)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.LeftHand)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.RightHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.LeftHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.RightHand)); } } @@ -182,26 +182,26 @@ public void Remote_SettingUsageOnDevice_WillSendChangeToRemotes() Assert.That(remoteGamepad.usages, Has.Count.Zero); // Can Set - InputSystem.SetDeviceUsage(gamepad, CommonUsages.LeftHand); + InputSystem.SetDeviceUsage(gamepad, Usages.LeftHand); Assert.That(remoteGamepad.usages, Has.Count.EqualTo(1)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.LeftHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.LeftHand)); // Can Replace - InputSystem.SetDeviceUsage(gamepad, CommonUsages.RightHand); + InputSystem.SetDeviceUsage(gamepad, Usages.RightHand); Assert.That(remoteGamepad.usages, Has.Count.EqualTo(1)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.RightHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.RightHand)); //Can Clear - InputSystem.RemoveDeviceUsage(gamepad, CommonUsages.LeftHand); - InputSystem.RemoveDeviceUsage(gamepad, CommonUsages.RightHand); + InputSystem.RemoveDeviceUsage(gamepad, Usages.LeftHand); + InputSystem.RemoveDeviceUsage(gamepad, Usages.RightHand); Assert.That(remoteGamepad.usages, Has.Count.Zero); //Can Set Multiple - InputSystem.AddDeviceUsage(gamepad, CommonUsages.LeftHand); - InputSystem.AddDeviceUsage(gamepad, CommonUsages.RightHand); + InputSystem.AddDeviceUsage(gamepad, Usages.LeftHand); + InputSystem.AddDeviceUsage(gamepad, Usages.RightHand); Assert.That(remoteGamepad.usages, Has.Count.EqualTo(2)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.LeftHand)); - Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(CommonUsages.RightHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.LeftHand)); + Assert.That(remoteGamepad.usages, Has.Exactly(1).EqualTo(Usages.RightHand)); } } diff --git a/Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs b/Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs index dd7323d1ab..df138f53fa 100644 --- a/Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs +++ b/Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs @@ -2556,7 +2556,7 @@ public void PlayerInput_WhenOverridingDeviceLayout_LostDeviceShouldBeResolvedAnd { ""name"" : ""GamepadPlayerUsageTags"", ""extend"" : ""Gamepad"", - ""commonUsages"" : [ + ""usages"" : [ ""Player1"", ""Player2"" ] } diff --git a/Assets/Tests/InputSystem/Plugins/XRTests.cs b/Assets/Tests/InputSystem/Plugins/XRTests.cs index 6f0e9cd1fd..1e27d58b0b 100644 --- a/Assets/Tests/InputSystem/Plugins/XRTests.cs +++ b/Assets/Tests/InputSystem/Plugins/XRTests.cs @@ -15,7 +15,7 @@ using UnityEngine.TestTools; using UnityEngine.XR; -using Usages = UnityEngine.InputSystem.CommonUsages; +using Usages = UnityEngine.InputSystem.Usages; using InputDeviceRole = UnityEngine.XR.InputDeviceRole; diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/InputControlScheme.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/InputControlScheme.cs index 7508bb984c..8bb64557e9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/InputControlScheme.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/InputControlScheme.cs @@ -907,7 +907,7 @@ public void Dispose() /// /// Note that device requirements may require specific controls to be present rather than only requiring /// the presence of a certain type of device. For example, a requirement with a - /// of "*/{PrimaryAction}" will be satisfied by any device that has a control marked as . + /// of "*/{PrimaryAction}" will be satisfied by any device that has a control marked as . /// /// Requirements are ordered in a list and can combine with their previous requirement in either /// AND or in OR fashion. The default is for requirements to combine with AND. diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs index 3d7430d722..350466da90 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs @@ -418,7 +418,7 @@ private enum Flags public IEnumerable appliedOverrides => m_AppliedOverrides; - public ReadOnlyArray commonUsages => new ReadOnlyArray(m_CommonUsages); + public ReadOnlyArray usages => new ReadOnlyArray(m_Usages); /// /// List of child controls defined for the layout. @@ -996,9 +996,9 @@ public static InputControlLayout FromType(string name, Type type) isNoisy = layoutAttribute?.isNoisy ?? false }; - if (layoutAttribute?.commonUsages != null) - layout.m_CommonUsages = - ArrayHelpers.Select(layoutAttribute.commonUsages, x => new InternedString(x)); + if (layoutAttribute?.usages != null) + layout.m_Usages = + ArrayHelpers.Select(layoutAttribute.usages, x => new InternedString(x)); return layout; } @@ -1027,7 +1027,7 @@ public static InputControlLayout FromJson(string json) internal bool? m_UpdateBeforeRender; internal InlinedArray m_BaseLayouts; private InlinedArray m_AppliedOverrides; - private InternedString[] m_CommonUsages; + private InternedString[] m_Usages; internal ControlItem[] m_Controls; internal string m_DisplayName; private string m_Description; @@ -1368,7 +1368,7 @@ public void MergeLayout(InputControlLayout other) m_StateFormat = other.m_StateFormat; // Combine common usages. - m_CommonUsages = ArrayHelpers.Merge(other.m_CommonUsages, m_CommonUsages); + m_Usages = ArrayHelpers.Merge(other.m_Usages, m_Usages); // Retain list of overrides. m_AppliedOverrides.Merge(other.m_AppliedOverrides); @@ -1614,7 +1614,7 @@ private struct LayoutJson public string format; public string beforeRender; // Can't be simple bool as otherwise we can't tell whether it was set or not. public string runInBackground; - public string[] commonUsages; + public string[] usages; public string displayName; public string description; public string type; // This is mostly for when we turn arbitrary InputControlLayouts into JSON; less for layouts *coming* from JSON. @@ -1658,7 +1658,7 @@ public InputControlLayout ToLayout() isGenericTypeOfDevice = isGenericTypeOfDevice, hideInUI = hideInUI, m_Variants = new InternedString(variant), - m_CommonUsages = ArrayHelpers.Select(commonUsages, x => new InternedString(x)), + m_Usages = ArrayHelpers.Select(usages, x => new InternedString(x)), }; if (!string.IsNullOrEmpty(format)) layout.m_StateFormat = new FourCC(format); @@ -1725,7 +1725,7 @@ public static LayoutJson FromLayout(InputControlLayout layout) extend = layout.m_BaseLayouts.length == 1 ? layout.m_BaseLayouts[0].ToString() : null, extendMultiple = layout.m_BaseLayouts.length > 1 ? layout.m_BaseLayouts.ToArray(x => x.ToString()) : null, format = layout.stateFormat.ToString(), - commonUsages = ArrayHelpers.Select(layout.m_CommonUsages, x => x.ToString()), + usages = ArrayHelpers.Select(layout.m_Usages, x => x.ToString()), controls = ControlItemJson.FromControlItems(layout.m_Controls), beforeRender = layout.m_UpdateBeforeRender != null ? (layout.m_UpdateBeforeRender.Value ? "Update" : "Ignore") : null, }; diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayoutAttribute.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayoutAttribute.cs index 70928594ab..06e9ad57b9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayoutAttribute.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayoutAttribute.cs @@ -49,9 +49,11 @@ public sealed class InputControlLayoutAttribute : Attribute /// public string stateFormat { get; set; } - ////TODO: rename this to just "usages"; "commonUsages" is such a weird name + /// + /// Provides a set of commonly used input usage strings. + /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "According to MSDN, this message can be ignored for attribute parameters, as there are no better alternatives.")] - public string[] commonUsages { get; set; } + public string[] usages { get; set; } public string variants { get; set; } diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/CommonUsages.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/Usages.cs similarity index 98% rename from Packages/com.unity.inputsystem/InputSystem/Controls/CommonUsages.cs rename to Packages/com.unity.inputsystem/InputSystem/Controls/Usages.cs index 90681e9623..48ac1efa8a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/CommonUsages.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/Usages.cs @@ -3,9 +3,9 @@ namespace UnityEngine.InputSystem { /// - /// A collection of common usage string values as reported by . + /// A collection of usage string values as reported by . /// - public static class CommonUsages + public static class Usages { /// /// Primary 2D motion control. diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs index 59cb845ea5..5d603d053f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Joystick.cs @@ -58,7 +58,7 @@ public class Joystick : InputDevice /// Control representing the primary trigger button. /// /// This is the type control on the joystick - /// that has the usage. + /// that has the usage. /// public ButtonControl trigger { get; protected set; } @@ -68,7 +68,7 @@ public class Joystick : InputDevice /// Control representing the main joystick axis. /// /// This is the type control on the joystick - /// that has the usage. + /// that has the usage. /// public StickControl stick { get; protected set; } @@ -80,7 +80,7 @@ public class Joystick : InputDevice /// Control representing the twist motion of the joystick. /// /// This is the type control on the joystick - /// that has the usage. + /// that has the usage. /// public AxisControl twist { get; protected set; } @@ -93,7 +93,7 @@ public class Joystick : InputDevice /// Hat switches are usually thumb-operated four-way switches that operate /// much like the "d-pad" on a gamepad (see ). /// If present, this is the type control on the - /// joystick that has the usage. + /// joystick that has the usage. /// public Vector2Control hatswitch { get; protected set; } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlDropdownItem.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlDropdownItem.cs index a1bc18709d..c1543b1360 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlDropdownItem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlDropdownItem.cs @@ -60,12 +60,12 @@ protected InputControlDropdownItem(string name) // internal control names rather than display names. internal sealed class OptionalControlDropdownItem : InputControlDropdownItem { - public OptionalControlDropdownItem(EditorInputControlLayoutCache.OptionalControl optionalControl, string deviceControlId, string commonUsage) + public OptionalControlDropdownItem(EditorInputControlLayoutCache.OptionalControl optionalControl, string deviceControlId, string usage) : base(optionalControl.name) { m_ControlPath = optionalControl.name; m_Device = deviceControlId; - m_Usage = commonUsage; + m_Usage = usage; // Not searchable. } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs index b8f29118a6..9610984753 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPickerDropdown.cs @@ -185,10 +185,10 @@ private void AddDeviceTreeItemRecursive(InputControlLayout layout, AdvancedDropd var defaultControlPickerLayout = new DefaultInputControlPickerLayout(); - // Add common usage variants of the device - if (layout.commonUsages.Count > 0) + // Add usage variants of the device + if (layout.usages.Count > 0) { - foreach (var usage in layout.commonUsages) + foreach (var usage in layout.usages) { var usageItem = new DeviceDropdownItem(layout, usage); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs index a2f04acd35..293c899d7a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDebuggerWindow.cs @@ -778,11 +778,11 @@ private TreeViewItem AddControlLayoutItem(InputControlLayout layout, TreeViewIte var value = layout.m_UpdateBeforeRender.Value ? "Update" : "Disabled"; AddChild(item, "Before Render: " + value, ref id); } - if (layout.commonUsages.Count > 0) + if (layout.usages.Count > 0) { AddChild(item, - "Common Usages: " + - string.Join(", ", layout.commonUsages.Select(x => x.ToString()).ToArray()), + "Usages: " + + string.Join(", ", layout.usages.Select(x => x.ToString()).ToArray()), ref id); } if (layout.appliedOverrides.Count() > 0) diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs index a5beeb412f..24b7888185 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs @@ -1645,7 +1645,7 @@ public static InputDevice GetDevice(Type type) /// /// /// // Get the left hand XRController. - /// var leftHand = InputSystem.GetDevice<XRController>(CommonUsages.leftHand); + /// var leftHand = InputSystem.GetDevice<XRController>(Usages.leftHand); /// /// // Mark gamepad #2 as being for player 1. /// InputSystem.SetDeviceUsage(Gamepad.all[1], "Player1"); @@ -2016,7 +2016,7 @@ public static void ResetHaptics() /// /// /// - /// + /// /// public static void SetDeviceUsage(InputDevice device, string usage) { @@ -2063,7 +2063,7 @@ public static void SetDeviceUsage(InputDevice device, string usage) /// /// /// - /// + /// /// public static void SetDeviceUsage(InputDevice device, InternedString usage) { @@ -2096,7 +2096,7 @@ public static void SetDeviceUsage(InputDevice device, InternedString usage) /// /// /// - /// + /// /// public static void AddDeviceUsage(InputDevice device, string usage) { @@ -2129,7 +2129,7 @@ public static void AddDeviceUsage(InputDevice device, string usage) /// /// /// - /// + /// /// public static void AddDeviceUsage(InputDevice device, InternedString usage) { @@ -2157,7 +2157,7 @@ public static void AddDeviceUsage(InputDevice device, InternedString usage) /// /// /// - /// + /// /// public static void RemoveDeviceUsage(InputDevice device, string usage) { @@ -2185,7 +2185,7 @@ public static void RemoveDeviceUsage(InputDevice device, string usage) /// /// /// - /// + /// /// public static void RemoveDeviceUsage(InputDevice device, InternedString usage) { diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs index ca156f0a8c..24c178991d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs @@ -17,7 +17,7 @@ public class DaydreamHMD : XRHMD /// /// An XR controller powered by Google Daydream. /// - [InputControlLayout(displayName = "Daydream Controller", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Daydream Controller", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class DaydreamController : XRController { [InputControl] diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs index 9c8e0e65b5..e7a9a5be93 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/Oculus.cs @@ -66,7 +66,7 @@ protected override void FinishSetup() /// /// An Oculus Touch controller. /// - [InputControlLayout(displayName = "Oculus Touch Controller", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Oculus Touch Controller", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class OculusTouchController : XRControllerWithRumble { [InputControl(aliases = new[] { "Primary2DAxis", "Joystick" })] @@ -198,7 +198,7 @@ protected override void FinishSetup() /// /// A Gear VR controller. /// - [InputControlLayout(displayName = "GearVR Controller", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "GearVR Controller", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class GearVRTrackedController : XRController { [InputControl] diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs index a099be99fc..0a3728c0c6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs @@ -42,7 +42,7 @@ protected override void FinishSetup() } } - [InputControlLayout(displayName = "Windows MR Controller (OpenVR)", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Windows MR Controller (OpenVR)", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class OpenVRControllerWMR : XRController { [InputControl(noisy = true)] @@ -95,7 +95,7 @@ protected override void FinishSetup() /// /// An HTC Vive Wand controller. /// - [InputControlLayout(displayName = "Vive Wand", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Vive Wand", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class ViveWand : XRControllerWithRumble { [InputControl] @@ -166,7 +166,7 @@ protected override void FinishSetup() } } - [InputControlLayout(displayName = "Handed Vive Tracker", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Handed Vive Tracker", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class HandedViveTracker : ViveTracker { [InputControl] @@ -195,7 +195,7 @@ protected override void FinishSetup() /// /// An Oculus Touch controller. /// - [InputControlLayout(displayName = "Oculus Touch Controller (OpenVR)", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Oculus Touch Controller (OpenVR)", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class OpenVROculusTouchController : XRControllerWithRumble { [InputControl] diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs index d8b3513e9f..8a92af22fa 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/Devices/WindowsMR.cs @@ -28,7 +28,7 @@ protected override void FinishSetup() /// /// A Windows Mixed Reality XR controller. /// - [InputControlLayout(displayName = "HoloLens Hand", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "HoloLens Hand", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class HololensHand : XRController { [InputControl(noisy = true, aliases = new[] { "gripVelocity" })] @@ -51,7 +51,7 @@ protected override void FinishSetup() } } - [InputControlLayout(displayName = "Windows MR Controller", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] + [InputControlLayout(displayName = "Windows MR Controller", usages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class WMRSpatialController : XRControllerWithRumble { [InputControl(aliases = new[] { "Primary2DAxis", "thumbstickaxes" })] diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs index b84d47ef0e..19ac6d7275 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/GenericXRDevice.cs @@ -82,7 +82,7 @@ protected override void FinishSetup() /// /// The base type for all XR handed controllers. /// - [InputControlLayout(commonUsages = new[] { "LeftHand", "RightHand" }, isGenericTypeOfDevice = true, displayName = "XR Controller")] + [InputControlLayout(usages = new[] { "LeftHand", "RightHand" }, isGenericTypeOfDevice = true, displayName = "XR Controller")] public class XRController : TrackedDevice { /// @@ -96,7 +96,7 @@ public class XRController : TrackedDevice /// var action = new InputAction(binding: "/<XRController>{leftHand}/position"); /// To make the left-hand XR controller behave like the right-hand one /// var controller = XRController.leftHand; - /// InputSystem.SetUsage(controller, CommonUsages.RightHand); + /// InputSystem.SetUsage(controller, Usages.RightHand); /// public static XRController leftHand => InputSystem.GetDevice(CommonUsages.LeftHand);