Input System: How to limit a Vector2 input to be only up, down, left or right.

I have an Action in the new input system that has 2 bindings, the arrow keys and Gamepad DPad. I want to limit the Vector2 to be on only the 4 cardinal directions (up, down, left, right) and if 2 arrows are pressed or diagonal DPad input is detected ignore one or use the last one detected.

If i got it right, you could use variables e.g. vertical , horizontal
if (vertical)
if (Input.GetKeyDown(KeyCode.W))
vertical = true;
horizontal =false;
if (horizontal)
if (Input.GetKeyDown(KeyCode.S))
vertical = false;
horizontal = true;

You will have to handle that in script like when you get the Vector 2 check the value and if the values are between 1 and 0 set the to either 1 or zero depending on how close they are to either value and if both x and y axis are used you should use some clever way to decide which axis of the 2 to use. for example if axis.x = 0.7f and axis.y = 0.2f you would most likely want to use the axis.x and set it to 1, or in direction the player would move right. I don’t think there is a way to do what you want in the input actions.