
Out-of-the-box, Unity (among other engines) seems to only want to use Xinput-devices for inputs (like gamepads) in the Input Manager, which means that it doesn’t know how to talk to older, generic input devices by default. We learned this the hard way while trying to set up our Demo Arcade Machine.
After some experimentation, Colin (miniscule) figured out a solution which, even if you are not submitting a game for us to use in out demos, we still want to show you how to fix so that anyone, with any kind of controller, can play your game.
In order to support the controller you will need to type in the button paths manually on each binding. The bindings all start with:
<HID:: USB Gamepad >/
⚠ Yes that’s 10 spaces between Gamepad and ‘>’, yes from what I can tell you do need exactly 10 for it to work.
Afterwards you specify the button at the end, for example:
<HID:: USB Gamepad >/button3
If done correctly it should show up in your bindings list formatted like:
Button 3 [ USB Gamepad ]
If it shows up more like this:
button3 [HID:: USB Gamepad ]
..then you’ve made a mistake, likely in the number of spaces.
The following are the button names and their corresponding buttons on the controller (using PS2 names)
- Triangle
- Trigger
- Circle
- button2
- X
- button3
- Square
- button4
- L1
- button5
- R1
- button6
- L2
- button7
- R2
- button8
- Select
- button9
- Start
- button10
- D-Pad
- hat
- Left Stick
- Stick
If you need to set a specific direction on the dpad or left sick you can put the direction afterwards, separated by a slash, for example:
<HID:: USB Gamepad >/hat/up
<HID:: USB Gamepad >/stick/down
For the right stick it will not be recognized as its own thing, you’ll need to add it as a 2D Vector (choose add Up\Down\Left\Right Composite from the binding dropdown) For Up and Down, bind them to the Z axis:
<HID:: USB Gamepad >/z
For Left and Right, bind them to the RZ axis:
<HID:: USB Gamepad >/rz
On Up and Left, you will need to go to the processors dropdown (below bindings) and add an invert so that they will output negative values.