unity-game-engineinputjoystickgamepad

How to detect which joystick pressed button?


In Unity InputManager (Edit -> Project Settings -> Input) I can define and name different inputs. I have an event called "Draw" that happens when joystick button 0 is pressed. This seems to be working. However, I cannot tell which controller pressed the button as the Joy Num option only works with axis and not with buttons. How to do that?

// How to tell which controller?
bool pressedDraw = Input.GetButtonDown("Draw");

Solution

  • The same button on different joystick is defined as its own button, as documented here.

    Joystick1Button0
    Joystick2Button0
    ...