# Reversing Player Controls

### Difficulty: 1/10 <img src="https://1229800202-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQAkTlyeVttU3CJdmYk%2F-MfzOs8r_UzTe7WhP3Tc%2F-MfzUfw94jUTyreywn9u%2Fdifficulty_1.png?alt=media&#x26;token=feabeb3d-303c-456f-81cc-d8b65fefeacd" alt="" data-size="original">&#x20;

To reverse controls drop this code block into whatever class you will have reversing the controls.

make sure you are `using InControl;` at the top

```csharp
        private BindingSource[] ActionDownValueP1 = new BindingSource[4];
        private BindingSource[] ActionUpValueP1 = new BindingSource[4];
        private BindingSource[] ActionRightValueP1 = new BindingSource[4];
        private BindingSource[] ActionLeftValueP1 = new BindingSource[4];
        
        private bool HasAlreadyReversedControls = false;
        
        public void ReverseControlsP1(float AmountOfTimeControlsReversed)
        {
            
            GungeonActions actions = BraveInput.PrimaryPlayerInstance.ActiveActions;
            var ActionLeft = actions.Left.Bindings;
            for(int i = 0; i < ActionLeft.Count; i++)
                ActionLeftValueP1[i] = ActionLeft[i];
            var ActionRight = actions.Right.Bindings;
            for (int i = 0; i < ActionRight.Count; i++)
                ActionRightValueP1[i] = ActionRight[i];
            var ActionUp = actions.Up.Bindings;
            for (int i = 0; i < ActionUp.Count; i++)
                ActionUpValueP1[i] = ActionUp[i];
            var ActionDown = actions.Down.Bindings;
            for (int i = 0; i < ActionDown.Count; i++)
                ActionDownValueP1[i] = ActionDown[i];

            actions.Left.ClearBindings();
            actions.Up.ClearBindings();
            actions.Down.ClearBindings();
            actions.Right.ClearBindings();

            for (int i = 0; i < ActionRightValueP1.Length; i++)
                actions.Left.AddBinding(ActionRightValueP1[i]);
            for (int i = 0; i < ActionLeftValueP1.Length; i++)
                actions.Right.AddBinding(ActionLeftValueP1[i]);
            for (int i = 0; i < ActionUpValueP1.Length; i++)
                actions.Down.AddBinding(ActionUpValueP1[i]);
            for (int i = 0; i < ActionDownValueP1.Length; i++)
                actions.Up.AddBinding(ActionDownValueP1[i]);

            HasAlreadyReversedControls = true;
            GameManager.Instance.StartCoroutine(FixControlsP1(AmountOfTimeControlsReversed));
        }

      private IEnumerator FixControlsP1(float SecondsToWait)
        {
            yield return new WaitForSeconds(SecondsToWait);
            GungeonActions actions = BraveInput.PrimaryPlayerInstance.ActiveActions;
            actions.Left.ClearBindings();
            actions.Up.ClearBindings();
            actions.Down.ClearBindings();
            actions.Right.ClearBindings();

            for (int i = 0; i < ActionLeftValueP1.Length; i++)
                actions.Left.AddBinding(ActionLeftValueP1[i]);
            for (int i = 0; i < ActionRightValueP1.Length; i++)
                actions.Right.AddBinding(ActionRightValueP1[i]);
            for (int i = 0; i < ActionDownValueP1.Length; i++)
                actions.Down.AddBinding(ActionDownValueP1[i]);
            for (int i = 0; i < ActionUpValueP1.Length; i++)
                actions.Up.AddBinding(ActionUpValueP1[i]);

            HasAlreadyReversedControls = false;
        }
```

This grabs the current movement bindings and stores them in fields. It then takes what was up, and uses it for down, takes what was down and uses it for up, etc. Now I hear you cry, "But An3s, can't we just use negative movement speed to reverse controls?" No, you're stupid, and I hate you. Setting the value to a negative can lead to all sorts of jank and bugs: 1) touching a wall sticks you to that wall and you cant walk off it. 2) trying to enter a boss room soft locks the game. 3) the running dust particles are a never-ending stream. So it is just better to subtly switch the player binds.

Now things will break terribly if you try to reverse controls while they are already reversed, which is why we have the bool `HasReversedControls` in there. so whenever you call ReverseControls you make sure HasReversedControlls is equal to false. This code can work with player two with some tweaking, but I leave that up to you if you want it.\
\
to call it simply go:

```csharp
if(HasAlreadyReversedControls == false)
    ReverseControlsP1(4);
```

where 4 is replaced with however many seconds you want controls to be reversed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mtgmodders.gitbook.io/etg-modding-guide/misc/reversing-player-controls.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
