- Home /
Getting input from joystick number X
I'd like to check the input from a given gamepad/joystick. I'm not ruling out how many players will be able to play on a single screen, so input could come from joystick 0, 1, 2, ...13, etc.
From googling around, I know unity's kind of difficult about dynamically mapping controls, though.
What I'd like to do is map Input.GetAxis("Forward") for all controller Y axis'. Then, in code, I'd like to check which controller gave that input. I'd think it's syntax is something like this:
for(int i = 0; i < Input.GetJoystickNames().Count; i++)
{
float curPlayerForward = Input.GetAxis("joystick " + i + " forward");
//use the forward value somehow.
}
Can I do something like that without creating a whole new set of input's in the input manager for all 11 controllers, or however many it is that unity supports?
Nobody commented to say my question was vague, so I guess that's not the problem. Is this mystery just too deep? Is there any way to get at the underlying input stuff? DirectInput or XInput or usb HID stuff? I just googled all those words, so I'm kind of making this up, but I'm looking for some way to get at input from an arbitrary controller. Unitys interface system has done me no favors, so I'm kind of looking for something else, now.
Your answer
![](https://koobas.hobune.stream/wayback/20220613083150im_/https://answers.unity.com/themes/thub/images/avi.jpg)