public void Actions_InteractiveRebinding_CanSpecifyMagnitudeThreshold()
    {
        var action  = new InputAction(binding: "<Gamepad>/buttonSouth");
        var gamepad = InputSystem.AddDevice <Gamepad>();

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithMagnitudeHavingToBeGreaterThan(0.5f)
                   .Start())
        {
            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftTrigger = 0.4f
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.Empty);

            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftTrigger = 0.6f
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/leftTrigger"));
        }
    }
    public void Actions_InteractiveRebinding_CanBeRestrictedToSpecificControlPaths()
    {
        var action   = new InputAction(binding: "<Gamepad>/buttonNorth");
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();
        var mouse    = InputSystem.AddDevice <Mouse>();

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithControlsHavingToMatchPath("<Keyboard>")
                   .WithControlsHavingToMatchPath("<Mouse>")
                   .OnPotentialMatch(operation => {})      // Don't complete. Just keep going.
                   .Start())
        {
            InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South));
            InputSystem.Update();

            Assert.That(rebind.candidates, Is.Empty);

            InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.Space));
            InputSystem.QueueStateEvent(mouse, new MouseState().WithButton(MouseButton.Left));
            InputSystem.Update();

            // The keyboard's synthetic AnyKey control and the mouse's button will get picked, too,
            // but will end up with the lowest scores.

            Assert.That(rebind.candidates, Has.Count.EqualTo(4));
            Assert.That(rebind.candidates, Has.Exactly(1).SameAs(keyboard.spaceKey));
            Assert.That(rebind.candidates, Has.Exactly(1).SameAs(mouse.leftButton));
            Assert.That(rebind.candidates[2], Is.SameAs(keyboard.anyKey));
            Assert.That(rebind.candidates[3], Is.SameAs(mouse.press));
        }
    }
    public void Actions_InteractiveRebinding_RequiresControlToBeActuatedStartingWithDefaultValue()
    {
        var action  = new InputAction(binding: "<Gamepad>/buttonSouth");
        var gamepad = InputSystem.AddDevice <Gamepad>();

        // Put buttonNorth in pressed state.
        InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.North));
        InputSystem.Update();

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation().WithAction(action).Start())
        {
            // Reset buttonNorth to unpressed state.
            InputSystem.QueueStateEvent(gamepad, new GamepadState());
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);

            // Now press it again.
            InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.North));
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/buttonNorth"));
        }
    }
    public void Actions_InteractiveRebinding_CanBeRestrictedToSpecificBindingGroups()
    {
        var action = new InputAction();

        action.AddBinding("<Keyboard>/space", groups: "Keyboard");
        action.AddBinding("<Gamepad>/buttonSouth", groups: "Gamepad");

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

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithBindingGroup("Gamepad")
                   .Start())
        {
            Assert.That(rebind.bindingMask, Is.EqualTo(new InputBinding {
                groups = "Gamepad"
            }));

            InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.North));
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].path, Is.EqualTo("<Keyboard>/space"));
            Assert.That(action.bindings[0].overridePath, Is.Null);
            Assert.That(action.bindings[1].path, Is.EqualTo("<Gamepad>/buttonSouth"));
            Assert.That(action.bindings[1].overridePath, Is.EqualTo("<Gamepad>/buttonNorth"));
        }
    }
    public void Actions_InteractiveRebinding_CanReuseRebindOperationMultipleTimes()
    {
        var gamepad = InputSystem.AddDevice <Gamepad>();

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation())
        {
            InputControl[] candidates = null;

            rebind
            .WithExpectedControlLayout("Button")
            .OnPotentialMatch(ctx => candidates = ctx.candidates.ToArray())
            .OnApplyBinding((operation, s) => {});

            rebind.Start();
            Press(gamepad.buttonSouth);

            Assert.That(candidates, Is.EquivalentTo(new[] { gamepad.buttonSouth }));

            rebind.Cancel();
            candidates = null;
            rebind.Start();
            Press(gamepad.buttonNorth);

            Assert.That(candidates, Is.EquivalentTo(new[] { gamepad.buttonNorth }));
        }
    }
    public void Actions_InteractiveRebinding_CanRebindWithoutAction()
    {
        var gamepad = InputSystem.AddDevice <Gamepad>();

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation())
        {
            // Must have OnApplyBinding() callback when not having an action as otherwise
            // RebindOperation doesn't know where to put the binding.
            Assert.That(() => rebind.Start(),
                        Throws.InvalidOperationException.With.Message.Contains("OnApplyBinding"));

            var receivedOnApplyBindingCall = false;
            rebind.OnApplyBinding(
                (operation, path) =>
            {
                receivedOnApplyBindingCall = true;
                Assert.That(path, Is.EqualTo("<Gamepad>/leftStick"));
            })
            .Start();

            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftStick = new Vector2(1, 0)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(receivedOnApplyBindingCall, Is.True);
        }
    }
    public void Actions_InteractiveRebinding_CanRestrictToSpecificBinding()
    {
        var action = new InputAction();

        action.AddCompositeBinding("dpad")
        .With("Up", "<Keyboard>/w")
        .With("Down", "<Keyboard>/s")
        .With("Left", "<Keyboard>/a")
        .With("Right", "<Keyboard>/d");
        var keyboard = InputSystem.AddDevice <Keyboard>();

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithTargetBinding(3)     // Left
                   .Start())
        {
            InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.U));
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].path, Is.EqualTo("dpad"));
            Assert.That(action.bindings[1].path, Is.EqualTo("<Keyboard>/w"));
            Assert.That(action.bindings[2].path, Is.EqualTo("<Keyboard>/s"));
            Assert.That(action.bindings[3].path, Is.EqualTo("<Keyboard>/a"));
            Assert.That(action.bindings[4].path, Is.EqualTo("<Keyboard>/d"));
            Assert.That(action.bindings[1].overridePath, Is.Null);
            Assert.That(action.bindings[2].overridePath, Is.Null);
            Assert.That(action.bindings[3].overridePath, Is.EqualTo("<Keyboard>/u"));
            Assert.That(action.bindings[4].overridePath, Is.Null);
        }
    }
    public void Actions_InteractiveRebinding_IgnoresControlsWithNoEffectiveValueChange()
    {
        var action  = new InputAction(binding: "<Gamepad>/leftStick");
        var gamepad = InputSystem.AddDevice <Gamepad>();

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithExpectedControlType("Stick")
                   .Start())
        {
            InputSystem.QueueStateEvent(gamepad,
                                        new GamepadState
            {
                rightStick = new Vector2(InputSystem.settings.defaultDeadzoneMin - 0.0001f, InputSystem.settings.defaultDeadzoneMin - 0.0001f)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);

            InputSystem.QueueStateEvent(gamepad,
                                        new GamepadState
            {
                rightStick = Vector2.one
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].path, Is.EqualTo("<Gamepad>/leftStick"));
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/rightStick"));
        }
    }
    public void Actions_CanCancelInteractiveRebinding_Manually()
    {
        var action = new InputAction(binding: "<Keyboard>/space");

        var receivedCancelCallback = false;

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .OnComplete(
                       operation =>
        {
            Assert.Fail("Should not complete");
        })
                   .OnCancel(
                       operation =>
        {
            Assert.That(receivedCancelCallback, Is.False);
            receivedCancelCallback = true;
        })
                   .Start())
        {
            rebind.Cancel();

            Assert.That(action.bindings[0].path, Is.EqualTo("<Keyboard>/space"));
            Assert.That(action.bindings[0].overridePath, Is.Null);
            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.canceled, Is.True);
            Assert.That(receivedCancelCallback, Is.True);
        }
    }
    public void Actions_CanCancelInteractiveRebinding_ThroughBinding()
    {
        var action   = new InputAction(binding: "<Keyboard>/space");
        var keyboard = InputSystem.AddDevice <Keyboard>();

        var receivedCancelCallback = false;

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .OnComplete(
                       operation =>
        {
            Assert.Fail("Should not complete");
        })
                   .OnCancel(
                       operation =>
        {
            Assert.That(receivedCancelCallback, Is.False);
            receivedCancelCallback = true;
        })
                   .WithCancelingThrough(keyboard.escapeKey)
                   .Start())
        {
            InputSystem.QueueStateEvent(keyboard, new KeyboardState(Key.Escape));
            InputSystem.Update();

            Assert.That(action.controls, Is.EquivalentTo(new[] { keyboard.spaceKey }));
            Assert.That(action.bindings[0].path, Is.EqualTo("<Keyboard>/space"));
            Assert.That(action.bindings[0].overridePath, Is.Null);
            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.canceled, Is.True);
            Assert.That(receivedCancelCallback, Is.True);
        }
    }
Beispiel #11
0
 void ButtonRebindCompleted()
 {
     m_RebindOperation.Dispose();
     m_RebindOperation = null;
     ResetButtonMappingTextValue();
     m_Button.enabled = true;
 }
    public void Actions_InteractiveRebinding_WhenControlAlreadyActuated_HasToCrossMagnitudeThresholdFromCurrentActuation()
    {
        var action  = new InputAction(binding: "<Gamepad>/buttonSouth");
        var gamepad = InputSystem.AddDevice <Gamepad>();

        // Actuate some controls.
        Press(gamepad.buttonNorth);
        Set(gamepad.leftTrigger, 0.75f);

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation()
                            .WithAction(action)
                            .WithMagnitudeHavingToBeGreaterThan(0.25f)
                            .Start())
        {
            Release(gamepad.buttonNorth);

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.Empty);

            Set(gamepad.leftTrigger, 0.9f);

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.Empty);

            Set(gamepad.leftTrigger, 0f);

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.Empty);

            Set(gamepad.leftTrigger, 0.7f);

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/leftTrigger"));
        }
    }
    public void Actions_InteractiveRebinding_CanExcludeSpecificControlPaths()
    {
        var action = new InputAction(binding: "<Gamepad>/leftStick");
        var mouse  = InputSystem.AddDevice <Mouse>();

        using (var rebind =
                   new InputActionRebindingExtensions.RebindingOperation()
                   .WithAction(action)
                   .WithControlsExcluding("<Mouse>/position")
                   .Start())
        {
            InputSystem.QueueStateEvent(mouse, new MouseState {
                position = new Vector2(123, 345)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.Empty);

            InputSystem.QueueStateEvent(mouse, new MouseState {
                delta = new Vector2(123, 345)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Pointer>/delta"));
        }
    }
Beispiel #14
0
    private void RebindCancel()
    {
        actionButtonText.text = _NameBeforeBind;
        actionReference.action.Enable();

        _RebindingOperation.Dispose();
        _RebindingOperation = null;
    }
 private void RebindKey()
 {
     _rebindingOperation = action.action.PerformInteractiveRebinding()
                           .WithControlsExcluding("Mouse")
                           .OnMatchWaitForAnother(0.1f)
                           .OnComplete(_ => RebindComplete())
                           .Start();
 }
Beispiel #16
0
 public void OnComplete(InputActionRebindingExtensions.RebindingOperation operation)
 {
     Debug.Log(InputActionRebindingExtensions.GetBindingDisplayString(operation.action));
     //control = operation.selectedControl;
     txtControl.text = Global.instance.ReplaceWithControlNames("[" + operation.action.name + "]");
     //txtControl.text = InputControlPath.ToHumanReadableString( operation.selectedControl.path );
     //txtControl.text = operation.action.GetBindingDisplayString( InputBinding.DisplayStringOptions.DontUseShortDisplayNames );
 }
Beispiel #17
0
 private void CleanUp()
 {
     if (rebindingOperation != null)
     {
         rebindingOperation.Cancel();
         rebindingOperation.Dispose();
         rebindingOperation = null;
     }
 }
    private void RemapButtonClicked(string name, Button uiButton, int mapIndex)
    {
        uiButton.enabled         = false;
        okButtonMessageText.text = "Press button/stick for " + name;

        var action = playerActionMap.actions[mapIndex];

        rebindOperation = action.PerformInteractiveRebinding().OnComplete(operation => ButtonRebindCompleted(uiButton)).Start();
    }
Beispiel #19
0
 public void StartRebinding(int control_)
 {
     control = control_;
     InputController.Instance.SwitchInputMap("EndGame");
     rebindOperation = inputReferenceArray[control].inputActions[0].action.PerformInteractiveRebinding()
                       .WithControlsExcluding("Mouse")
                       .OnMatchWaitForAnother(.1f)
                       .OnComplete(operation => RebindComplete())
                       .Start();
 }
 private void RefreshText(InputActionRebindingExtensions.RebindingOperation operation)
 {
     keybindInputField.text = operation.action.GetBindingDisplayString().Split('|')[0];
     keybindInputField.DeactivateInputField(true);
     keybindInputField.OnDeselect(new BaseEventData(EventSystem.current));
     keybindInputField.interactable = false;
     keybindInputField.interactable = true;
     operation.Dispose();
     action.Enable();
 }
Beispiel #21
0
    public void StartRebinding()
    {
        startRebindObject.SetActive(false);
        waitingForInputObject.SetActive(true);

        //playerInput.SwitchCurrentActionMap("MenuOperation");
        rebindingOperation = action.PerformInteractiveRebinding()
                             .OnMatchWaitForAnother(0.1f)
                             .OnComplete(operation => OnRebindComplete())
                             .Start();
    }
Beispiel #22
0
    public void RebindOneKey(int index)
    {
        InputAction actionRef = map.actions[index];

        rebindingText.text = "PRESS KEY FOR: " + actionRef.name;

        rebindingOperation = actionRef.PerformInteractiveRebinding()
                             .WithControlsExcluding("Mouse")
                             .OnMatchWaitForAnother(0.1f)
                             .OnComplete(operation => RebindComplete())
                             .Start();
    }
Beispiel #23
0
    public void StartRebinding()
    {
        startRebindObject.SetActive(false);

        PlayerInput.SwitchCurrentActionMap("Rebind");

        rebindingOperation = RebindingAction.action.PerformInteractiveRebinding()
                             .WithControlsExcluding("<Mouse>/left")
                             .OnMatchWaitForAnother(0.1f)
                             .OnComplete(operation => RebindComplete())
                             .Start();
    }
Beispiel #24
0
    void RemapButtonClicked(string name, int bindingIndex = 0)
    {
        m_Button.enabled = false;
        m_Text.text      = "Press button/stick for " + name;
        m_RebindOperation?.Dispose();
        m_RebindOperation = m_Action.PerformInteractiveRebinding()
                            .WithControlsExcluding("<Mouse>/position")
                            .WithControlsExcluding("<Mouse>/delta")
                            .OnMatchWaitForAnother(0.1f)
                            .OnComplete(operation => ButtonRebindCompleted());
        if (m_CompositeBindingIndices != null)
        {
            m_RebindOperation = m_RebindOperation
                                .OnComputeScore((x, y) => ScoreFunc(m_CompositeType, x, y))
                                .OnGeneratePath(x =>
            {
                if (!ControlMatchesCompositeType(x, m_CompositeType))
                {
                    m_IsUsingComposite = true;
                }
                else
                {
                    m_IsUsingComposite = false;
                }
                return(null);
            })
                                .OnApplyBinding((x, path) =>
            {
                if (m_IsUsingComposite)
                {
                    m_Action.ApplyBindingOverride(m_DefaultBindingIndex, "");
                    m_Action.ApplyBindingOverride(
                        bindingIndex != m_DefaultBindingIndex ? bindingIndex : m_CompositeBindingIndices[0], path);

                    GameObject myEventSystem = GameObject.Find("EventSystem");
                    myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(m_CompositeButtons[0].gameObject);
                    m_CompositeButtons[0].OnSelect(null);
                }
                else
                {
                    m_Action.ApplyBindingOverride(m_DefaultBindingIndex, path);
                    foreach (var i in m_CompositeBindingIndices)
                    {
                        m_Action.ApplyBindingOverride(i, "");
                    }
                    GameObject myEventSystem = GameObject.Find("EventSystem");
                    myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(m_Button.gameObject);
                    m_Button.OnSelect(null);
                }
            });
        }
        m_RebindOperation.Start();
    }
Beispiel #25
0
    void RebindCompleted()
    {
        rebindOperation.Dispose();
        rebindOperation = null;

        ToggleGameObjectState(rebindButtonObject, true);
        ToggleGameObjectState(resetButtonObject, true);
        ToggleGameObjectState(listeningForInputObject, false);

        UpdateActionDisplayUI();
        UpdateBindingDisplayUI();
    }
    public void Actions_InteractiveRebinding_UsesSyntheticControlsOnlyWhenBestMatch()
    {
        var action = new InputAction(binding: "<Gamepad>/buttonSouth");

        action.expectedControlType = "Axis";
        var gamepad = InputSystem.AddDevice <Gamepad>();

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation()
                            .WithAction(action)
                            .OnPotentialMatch(
                   operation =>
        {
            // Complete only when leftStick/right has been picked.
            if (operation.selectedControl == gamepad.leftStick.right)
            {
                operation.Complete();
            }
        })
                            .Start())
        {
            // Actuate X axis on left stick. This makes both the leftStick/right button (buttons are axes)
            // a candidate as well as leftStick/x. However, leftStick/right is synthetic so X axis should
            // win. Note that if we set expectedControlType to "Button", leftStick/x will get ignored
            // and leftStick/left will get picked.
            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftStick = new Vector2(1, 0)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.candidates, Is.EquivalentTo(new[] { gamepad.leftStick.x, gamepad.leftStick.right }));
            Assert.That(rebind.scores, Has.Count.EqualTo(2));
            Assert.That(rebind.scores[0], Is.GreaterThan(rebind.scores[1]));

            // Reset.
            InputSystem.QueueStateEvent(gamepad, new GamepadState());
            InputSystem.Update();
            rebind.RemoveCandidate(gamepad.leftStick.x);
            rebind.RemoveCandidate(gamepad.leftStick.right);

            // Switch to looking only for buttons. leftStick/x will no longer be a suitable pick.
            rebind.WithExpectedControlType("Button");

            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftStick = new Vector2(1, 0)
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/leftStick/right"));
        }
    }
    public void Actions_InteractiveRebinding_RespectsExpectedControlLayoutIfSet()
    {
        var action = new InputAction(binding: "<Gamepad>/buttonSouth")
        {
            expectedControlType = "Button",
        };

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

        using (var rebind = new InputActionRebindingExtensions.RebindingOperation()
                            .WithAction(action)
                            .OnPotentialMatch(
                   operation =>
        {
            ////REVIEW: is there a better way to deal with this?
            // Sticks have buttons for each of the directions. We want to ignore them
            // for the sake of this test.
            operation.RemoveCandidate(gamepad.leftStick.up);
            operation.RemoveCandidate(gamepad.leftStick.down);
            operation.RemoveCandidate(gamepad.leftStick.left);
            operation.RemoveCandidate(gamepad.leftStick.right);

            if (operation.candidates.Count > 0)
            {
                operation.Complete();
            }
        })
                            .Start())
        {
            // Gamepad leftStick should get ignored.
            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftStick = Vector2.one
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.False);
            Assert.That(rebind.canceled, Is.False);
            Assert.That(action.bindings[0].path, Is.EqualTo("<Gamepad>/buttonSouth"));
            Assert.That(action.bindings[0].overridePath, Is.Null);

            // Gamepad leftTrigger should bind.
            InputSystem.QueueStateEvent(gamepad, new GamepadState {
                leftTrigger = 0.5f
            });
            InputSystem.Update();

            Assert.That(rebind.completed, Is.True);
            Assert.That(rebind.canceled, Is.False);
            Assert.That(action.bindings[0].path, Is.EqualTo("<Gamepad>/buttonSouth"));
            Assert.That(action.bindings[0].overridePath, Is.EqualTo("<Gamepad>/leftTrigger"));
        }
    }
Beispiel #28
0
        private void StartListening()
        {
            if (m_RebindingOperation == null)
            {
                m_RebindingOperation = new InputActionRebindingExtensions.RebindingOperation();
            }

            ////TODO: for keyboard, generate both possible paths (physical and by display name)

            m_RebindingOperation.Reset();
            m_RebindingOperation
            .WithExpectedControlType(m_ExpectedControlLayout)
            // Require minimum actuation of 0.15f. This is after deadzoning has been applied.
            .WithMagnitudeHavingToBeGreaterThan(0.15f)
            ////REVIEW: should we exclude only the system's active pointing device?
            // With the mouse operating the UI, its cursor control is too fickle a thing to
            // bind to. Ignore mouse position and delta and clicks.
            // NOTE: We go for all types of pointers here, not just mice.
            .WithControlsExcluding("<Pointer>/position")
            .WithControlsExcluding("<Pointer>/delta")
            .WithControlsExcluding("<Pointer>/press")
            .WithControlsExcluding("<Pointer>/clickCount")
            .WithControlsExcluding("<Pointer>/{PrimaryAction}")
            .WithControlsExcluding("<Mouse>/scroll")
            .OnPotentialMatch(
                operation =>
            {
                // We never really complete the pick but keep listening for as long as the "Interactive"
                // button is toggled on.

                Repaint();
            })
            .OnCancel(
                operation =>
            {
                Repaint();
            })
            .OnApplyBinding(
                (operation, newPath) =>
            {
                // This is never invoked (because we don't complete the pick) but we need it nevertheless
                // as RebindingOperation requires the callback if we don't supply an action to apply the binding to.
            });

            // If we have control paths to match, pass them on.
            if (m_ControlPathsToMatch.LengthSafe() > 0)
            {
                m_ControlPathsToMatch.Select(x => m_RebindingOperation.WithControlsHavingToMatchPath(x));
            }

            m_RebindingOperation.Start();
        }
    //When the button is clicked, rebind it.
    public void OnClick()
    {
        PersistantVars.pVars.PlaySound(SoundEffects.MENU_CHANGE_SETTING);
        InputAction actionRef = map.actions[myIndex];

        inputScript.RebindStarted();

        rebindingOperation = actionRef.PerformInteractiveRebinding()
                             .WithControlsExcluding("Mouse")
                             .OnMatchWaitForAnother(0.1f)
                             .OnComplete(operation => RebindComplete())
                             .Start();
    }
Beispiel #30
0
        public void StartRebinding()
        {
            startRebindObject.SetActive(false);
            waitingForInputObject.SetActive(true);

            playerController.PlayerInput.SwitchCurrentActionMap("Menu");

            rebindingOperation = jumpAction.action.PerformInteractiveRebinding()
                                 .WithControlsExcluding("Mouse")
                                 .OnMatchWaitForAnother(0.1f)
                                 .OnComplete(operation => RebindComplete())
                                 .Start();
        }