Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Assets/QA/Tests/XRDeviceActions/_SharedScripts/Handedness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public void Update()
{
var handedness = "";

var leftHand = InputSystem.GetDevice<XRController>(CommonUsages.LeftHand);
var rightHand = InputSystem.GetDevice<XRController>(CommonUsages.RightHand);
var leftHand = InputSystem.GetDevice<XRController>(Usages.LeftHand);
var rightHand = InputSystem.GetDevice<XRController>(Usages.RightHand);

if (leftHand != null)
handedness += "Left ";
Expand Down
12 changes: 6 additions & 6 deletions Assets/QA/Tests/XRHaptics/XRHaptics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ private enum RumbleState

public void Update()
{
var leftHandController = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.LeftHand);
var leftHandController = InputSystem.GetDevice<XRControllerWithRumble>(Usages.LeftHand);
leftHapticDetected.color = leftHandController != null ? Color.red : Color.white;
var rightHandController = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.RightHand);
var rightHandController = InputSystem.GetDevice<XRControllerWithRumble>(Usages.RightHand);
rightHapticDetected.color = rightHandController != null ? Color.red : Color.white;

UpdateTimer();
Expand All @@ -50,7 +50,7 @@ private void UpdateTimer()
switch (state)
{
case RumbleState.Left:
controller = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.LeftHand);
controller = InputSystem.GetDevice<XRControllerWithRumble>(Usages.LeftHand);
controller.SendImpulse(1f, m_RumblePeriod);
leftTryingToRumble.color = Color.red;
leftTryingToRumbleHalf.color = Color.white;
Expand All @@ -59,7 +59,7 @@ private void UpdateTimer()
state = RumbleState.LeftHalf;
break;
case RumbleState.LeftHalf:
controller = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.LeftHand);
controller = InputSystem.GetDevice<XRControllerWithRumble>(Usages.LeftHand);
controller.SendImpulse(0.5f, m_RumblePeriod);

leftTryingToRumble.color = Color.white;
Expand All @@ -69,7 +69,7 @@ private void UpdateTimer()
state = RumbleState.Right;
break;
case RumbleState.Right:
controller = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.RightHand);
controller = InputSystem.GetDevice<XRControllerWithRumble>(Usages.RightHand);
controller.SendImpulse(1f, m_RumblePeriod);
leftTryingToRumble.color = Color.white;
leftTryingToRumbleHalf.color = Color.white;
Expand All @@ -78,7 +78,7 @@ private void UpdateTimer()
state = RumbleState.RightHalf;
break;
case RumbleState.RightHalf:
controller = InputSystem.GetDevice<XRControllerWithRumble>(CommonUsages.RightHand);
controller = InputSystem.GetDevice<XRControllerWithRumble>(Usages.RightHand);
controller.SendImpulse(0.5f, m_RumblePeriod);
leftTryingToRumble.color = Color.white;
leftTryingToRumbleHalf.color = Color.white;
Expand Down
4 changes: 2 additions & 2 deletions Assets/Samples/CustomDeviceUsages/CustomDeviceUsages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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""
]
}
Expand Down
6 changes: 3 additions & 3 deletions Assets/Tests/InputSystem/CoreTests_Actions_Rebinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ public void Actions_InteractiveRebinding_IfDeviceHasUsages_UsagesAreAppliedToOve
var action = new InputAction(binding: "<Gamepad>/buttonSouth");

var rightHand = InputSystem.AddDevice<Gamepad>();
InputSystem.SetDeviceUsage(rightHand, CommonUsages.RightHand);
InputSystem.SetDeviceUsage(rightHand, Usages.RightHand);

using (var rebind = new InputActionRebindingExtensions.RebindingOperation().WithAction(action).Start())
{
Expand Down Expand Up @@ -1122,8 +1122,8 @@ public void Actions_InteractiveRebinding_IfDeviceHasMultipleUsages_UsagesAreAppl

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

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())
{
Expand Down
20 changes: 10 additions & 10 deletions Assets/Tests/InputSystem/CoreTests_Devices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -223,7 +223,7 @@ public void Devices_CanFindDeviceByUsage()
InputSystem.AddDevice<Gamepad>();
var device = InputSystem.AddDevice<Keyboard>();

InputSystem.SetDeviceUsage(device, CommonUsages.LeftHand);
InputSystem.SetDeviceUsage(device, Usages.LeftHand);

using (var controls = InputSystem.FindControls("/{LeftHand}"))
{
Expand Down Expand Up @@ -292,8 +292,8 @@ public void Devices_CanFindDeviceByMultipleUsages()
InputSystem.AddDevice<Gamepad>();
var device = InputSystem.AddDevice<Gamepad>();

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}"))
Expand Down Expand Up @@ -328,10 +328,10 @@ public void Devices_CanFindDeviceByMultipleUsages()
public void Devices_CanFindDeviceByUsageAndLayout()
{
var gamepad = InputSystem.AddDevice<Gamepad>();
InputSystem.SetDeviceUsage(gamepad, CommonUsages.LeftHand);
InputSystem.SetDeviceUsage(gamepad, Usages.LeftHand);

var keyboard = InputSystem.AddDevice<Keyboard>();
InputSystem.SetDeviceUsage(keyboard, CommonUsages.LeftHand);
InputSystem.SetDeviceUsage(keyboard, Usages.LeftHand);

using (var controls = InputSystem.FindControls("/<Keyboard>{LeftHand}"))
{
Expand Down Expand Up @@ -925,11 +925,11 @@ public void Devices_CanLookUpDeviceByTypeAndUsage()
var rightHand = InputSystem.AddDevice<Gamepad>();
InputSystem.AddDevice<Gamepad>(); // 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<Gamepad>(CommonUsages.LeftHand), Is.SameAs(leftHand));
Assert.That(InputSystem.GetDevice<Gamepad>(CommonUsages.RightHand), Is.SameAs(rightHand));
Assert.That(InputSystem.GetDevice<Gamepad>(Usages.LeftHand), Is.SameAs(leftHand));
Assert.That(InputSystem.GetDevice<Gamepad>(Usages.RightHand), Is.SameAs(rightHand));
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions Assets/Tests/InputSystem/CoreTests_Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ public void Editor_DomainReload_CanRestoreDevicesBuiltWithDynamicallyGeneratedLa
public void Editor_DomainReload_PreservesUsagesOnDevices()
{
var device = InputSystem.AddDevice<Gamepad>();
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
Expand Down
62 changes: 31 additions & 31 deletions Assets/Tests/InputSystem/CoreTests_Layouts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void Layouts_CanSetUsagesThroughControlAttribute()
{
var gamepad = InputSystem.AddDevice<Gamepad>();

Assert.That(gamepad.leftStick.usages, Has.Exactly(1).EqualTo(CommonUsages.Primary2DMotion));
Assert.That(gamepad.leftStick.usages, Has.Exactly(1).EqualTo(Usages.Primary2DMotion));
}

[Test]
Expand Down Expand Up @@ -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
{
}
Expand All @@ -460,7 +460,7 @@ public void Layouts_CanSpecifyCommonUsagesForDevices()
{
""name"" : ""DerivedDevice"",
""extend"" : ""BaseDevice"",
""commonUsages"" : [ ""LeftToe"" ]
""usages"" : [ ""LeftToe"" ]
}
";

Expand All @@ -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]
Expand Down Expand Up @@ -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"" ]
}
";

Expand All @@ -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")));
Expand Down Expand Up @@ -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);
}

Expand Down
28 changes: 14 additions & 14 deletions Assets/Tests/InputSystem/CoreTests_Remoting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ public void Remote_RemovingDevice_WillRemoveItFromRemotes()
public void Remote_DevicesWithExistingUsage_WillUpdateSendToRemote()
{
var gamepad = InputSystem.AddDevice<Gamepad>();
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));
}
}

Expand All @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,7 @@ public void PlayerInput_WhenOverridingDeviceLayout_LostDeviceShouldBeResolvedAnd
{
""name"" : ""GamepadPlayerUsageTags"",
""extend"" : ""Gamepad"",
""commonUsages"" : [
""usages"" : [
""Player1"", ""Player2""
]
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/InputSystem/Plugins/XRTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ public void Dispose()
/// <remarks>
/// 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 <see cref="controlPath"/>
/// of "*/{PrimaryAction}" will be satisfied by any device that has a control marked as <see cref="CommonUsages.PrimaryAction"/>.
/// of "*/{PrimaryAction}" will be satisfied by any device that has a control marked as <see cref="Usages.PrimaryAction"/>.
///
/// Requirements are ordered in a list and can combine with their previous requirement in either <see cref="isAND">
/// AND</see> or in <see cref="isOR">OR</see> fashion. The default is for requirements to combine with AND.
Expand Down
Loading