Playstation 4 Controller Mapping Unity


In addition to keyboard controls, we’re also interested in using controllers. We don’t have any of those indie darling XBox controllers, but we do have some (too many) Playstation controllers lying around. For our ControlGet script we did some very minor reverse engineering to figure out what connects to what. Edit: in the process of trying to find a PS4 controller image we found someone who did it first. We can’t take credit for that above image, but we can tell you that it’s great. Click through to find out a little bit more.

The few things we found interesting is that 1) both analogue sticks’ vertical axes treat up as negative and down as positive which is the opposite of the d-pad and 2) L2 and R2 both function as axes and buttons. As axes they go from -1 to 1 giving them huge range. As far as Unity’s Input Manager goes, we found that 0.1 deadzone worked for us, but that was not nearly as extensive testing as we’d like.

We’d like to get other Steam/XBox/XBOne controllers to add compatibility to those ASAP. I’m thinking for completeness I’ll do USB PS2 and PS3 controllers soon. I’m sure there are minor differences?

Square = joystick button 0
X = joystick button 1
O = joystick button 2
Triangle = joystick button 3
L1 = joystick button 4
R1 = joystick button 5
L2* = joystick button 6
R2* = joystick button 7
Share = Joystick button 8
Options = joystick button 9
L3 = joystick button 10
R3 = joystick button 11
Playstation = joystick button 12
Trackpad Click = joystick button 13

Left Stick X = X-Axis
Left Stick Y = Y-Axis**
Right Stick X = 3rd Axis
Right Stick Y = 6th Axis**
L2* = 4th Axis
R2* = 5th Axis
Direction Pad X = 7th Axis
Direction Pad Y = 8th Axis

For completeness, this was developed on a Win7 machine with the white PS4 controller connected via USB. It is a classy setup with a Lenovo X230 that has been dropped one too many times. If your findings are different than our findings, please get at us. Thanks!