Read analog stick input without using the Input Manager

I’m making a quick prototype and there is no real reason for having a specific limit of players in the game (at this state) so I want to be able to read every single controller connected to the computer without having to make multiple axis in the Input Manager.

Yes indeed.

To ask for an arbitrary keycode you use the enumeration KeyCode.

The KeyCodes for the joysticks follow all the following formula:

KeyCode.JoystickXButtonY where you replace X with the joystick number (order is determined by the order they are identified (i.e plugged in) by the computer) and *Y with a number. numbers reach from 1 to 19.

hint: The * Behind Joystick is a bug.

for example Input.GetAxis(KeyCode.Joystick2Button1) should return either the vertical or horizontal axis of the left stick when im not mistaken.

Warning: I don’t know if GetAxis() actually works with KeyCodes.

  • If yes, this is the way.
  • If no, there is only GetKey(Down/Up) left and that function only returns bool which means you cannot make decent use of the sticks without actually configuring them in the InputManager.