Esempio n. 1
0
    public void Remote_DevicesWithExistingUsage_WillUpdateSendToRemote()
    {
        var gamepad = InputSystem.AddDevice <Gamepad>();

        InputSystem.SetDeviceUsage(gamepad, CommonUsages.LeftHand);
        InputSystem.AddDeviceUsage(gamepad, CommonUsages.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));
        }
    }
        void UpdateUsages(InputDevice device)
        {
            var usages = device.usages;

            if (usages.Contains(CommonUsages.LeftHand))
            {
                InputSystem.RemoveDeviceUsage(device, m_Handedness == XRControllerHandedness.LeftHanded ? k_SecondaryUsage : k_PrimaryUsage);
                InputSystem.AddDeviceUsage(device, m_Handedness == XRControllerHandedness.LeftHanded ? k_PrimaryUsage : k_SecondaryUsage);
            }
            else if (usages.Contains(CommonUsages.RightHand))
            {
                InputSystem.RemoveDeviceUsage(device, m_Handedness == XRControllerHandedness.RightHanded ? k_SecondaryUsage : k_PrimaryUsage);
                InputSystem.AddDeviceUsage(device, m_Handedness == XRControllerHandedness.RightHanded ? k_PrimaryUsage : k_SecondaryUsage);
            }
        }
Esempio n. 3
0
        void startInputDevice()
        {
#if DOWNLOADED_ARFOUNDATION
            if (XRController.leftHand == null && ThisEitherHand == EitherHand.Left)
            {
                var inputDevice = InputSystem.AddDevice <HandMRInputDevice>();
                InputSystem.AddDeviceUsage(inputDevice, UnityEngine.InputSystem.CommonUsages.LeftHand);
            }
            if (XRController.rightHand == null && ThisEitherHand == EitherHand.Right)
            {
                var inputDevice = InputSystem.AddDevice <HandMRInputDevice>();
                InputSystem.AddDeviceUsage(inputDevice, UnityEngine.InputSystem.CommonUsages.RightHand);
            }
#endif
        }
    public void Actions_InteractiveRebinding_IfDeviceHasMultipleUsages_UsagesAreAppliedToOverridePath()
    {
        var action = new InputAction(binding: "<Gamepad>/buttonSouth");

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

        InputSystem.SetDeviceUsage(rightHandVertical, CommonUsages.RightHand);
        InputSystem.AddDeviceUsage(rightHandVertical, CommonUsages.Vertical);

        using (var rebind = action.PerformInteractiveRebinding().Start())
        {
            InputSystem.QueueStateEvent(rightHandVertical, new GamepadState().WithButton(GamepadButton.South));
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>{RightHand}{Vertical}/buttonSouth"));
        }
    }