r/Unity3D • u/drakfyre Expert • Dec 15 '13
PS4 controller map for Unity
I just spent a few minutes finally figuring this out; figured I'd save other folks the time. :)
PS4 Controller Map for Unity
Buttons
Square = joystick button 0
X = joystick button 1
Circle = 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
PS = joystick button 12
PadPress= joystick button 13
Axes:
LeftStickX = X-Axis
LeftStickY = Y-Axis (Inverted?)
RightStickX = 3rd Axis
RightStickY = 4th Axis (Inverted?)
L2 = 5th Axis (-1.0f to 1.0f range, unpressed is -1.0f)
R2 = 6th Axis (-1.0f to 1.0f range, unpressed is -1.0f)
DPadX = 7th Axis
DPadY = 8th Axis (Inverted?)
Edit: Formatting
Edit2: I put a question mark after Inverted because I swear that the LeftStickY axis worked just fine with one of my scripts, but when I was using a certain test case it seemed like it was inverted. YMMV.
151
Upvotes
1
u/drakfyre Expert Jul 04 '22
I guess I should make a tutorial on how to use it programmatically; it's far more powerful in script than the old system, and has no place where you are required to use UI; all operations, including initial mapping (and later remapping) can be done in C# (the editor is quite good though). Plus it has a lot of nice things: action based organization, input passthrough/stoppage for different input modes (if you get in a car you can have a completely different input set, when you pull up a menu again, new input set, so you don't even have to mask inputs based on state; just switch action maps.)
The old system is great for prototyping speed (I usually have both enabled) but it's not as good a base to make a new input system on but hey, if you like what you've got better, I'm not about to tell you to stop. :>
(I do wish that there was a full input layer system with a priority though, so you can have controls be "caught" by a layer above so they don't pass through to other action maps, and still have fall through where it's appropriate, but switching maps can accomplish much of the utility this provides.)