[Tutorial] UE4 using Dualshock4 controller (via USB, PS4 DS4 Gamepad).

Hi all. Thanks for your patience. Sincerely sorry for taking so long to get back to you on this. I’ve finally been able to find the post that I was able to use to solve the “unresponsive” button issue:

In RawInputWindows.cpp (around line 584 as of UE 4.22):

 [FONT=Helvetica Neue]DeviceButtonData.bPreviousButtonState = DeviceButtonData.bButtonState;

is redundant. From what I remember, (this was a long time ago I looked at it), it’s basically creating an infinite loop that continues til interrupted and floods the program with input. By commenting out that line, the inputs all worked perfectly and predictably with the exception of the d-pad.

Perhaps this line of code served some purpose related to the d-pad? My level in C++ is too low to really get it. But hopefully this will help someone more advanced than myself track down a more proper way to fix the issue.

Does anyone know how to make this work without messing up input for every other game controller? When I setup inputs for the PS4 controller, every other controller gets messed up. It’s basically this bug report Unreal Engine Issues and Bug Tracker (UE-66123)

Try to change “Set Register Default Device” to False.

Thanks so much for this tutorial! I’m using UE 4.25.3 and Windows RawInput 1.0. I got this working with slightly different values than the original post, and I think it’s because either my version of UE or RawInput is newer than when this was originally posted.

In my Edit > Project Settings > RawInput, there’s a option for each axis called “Gamepad Stick” which makes things very easy. Also my ProductID is 0x09CC (the documentation for RawInput Plugin shows how to find this).

Here’s all my settings under Edit > Project Setings > RawInput in case it helps someone else. I’ve also included what each axis and button maps to for me. For me the Dpad V & Dpad H are both on Axis 5 with nothing on Axis 6.

Vendor ID: 0x054C
ProductID: 0x09CC
Axis[0]:USB Axis 1 - RStick V Inverted: Yes
Gamepad Stick: Yes
Offset: 0.0

Axis[1]:USB Axis 2 - RStick H Inverted: No
Gamepad Stick: Yes
Offset: 0.0

Axis[2]:USB Axis 3 - LStick V Inverted: Yes
Gamepad Stick: Yes
Offset: 0.0

Axis[3]:USB Axis 4 - LStick H Inverted: No
Gamepad Stick: Yes
Offset: 0.0

Axis[4]:USB Axis 5 - Dpad V & H Inverted: No
Gamepad Stick: No
Offset: 0.0

Axis[5]:USB Axis 6 - doesn’t do anything Maybe it’s supposed to be the touchpad area?

Axis[6]:USB Axis 7 - R2 trigger axis (also Button 8) Inverted: No
Gamepad Stick: No
Offset: 0.0

Axis[7]:USB Axis 8 - L2 trigger axis (also Button 7) Inverted: No
Gamepad Stick: No
Offset: 0.0

Button[0]: USB Button 1 - Square
Button[1]: USB Button 2 - X
Button[2]: USB Button 3 - O
Button[3]: USB Button 4 - Triangle
Button[4]: USB Button 5 - L1
Button[5]: USB Button 6 - R1
Button[6]: USB Button 7 - L2 trigger (also Axis 8)
Button[7]: USB Button 8 - R2 trigger (also Axis 7)
Button[8]: USB Button 9 - Share
Button[9]: USB Button 10 - Options
Button[10]: USB Button 11 - L3
Button[11]: USB Button 12 - R3
Button[12]: USB Button 13 - PS
Button[13]: USB Button 14 - Touchpad Click
One thing that was really helpful to figure the axis values and mapping was to open the game console (press the [FONT=Lucida Sans Unicode]` (backtick) key) and type [FONT=Lucida Sans Unicode]showdebug input

Paste to notepad and save as .ini and inport to Edit > Project Settings > RawInput by click Import button


I still not find a way to set the Dead Zone values for RAW Input.

Ok, I just figured out how to set the Dead Zone values:


I just input this logic on all Event Axis of my Character Blueprint:

I dont think RawInput has a deadzone feature. I made a blueprint function that does deadzone

Yeah, I was able do to do like my previous post, and also I was able to put support “native” for DualShock 4 and DualShock 3 using the RAW input, for DualShock 3 I’m using the official driver from Playstation Now PC version.

I wasn’t able to get RawInput working for me (steam was somehow messing it up), but I did add UE4Editor.exe to steam library, then launched it from steam. I connected my ps4 controller via bluetooth, set the configuration specifically to the “gamepad - ps4 controller” and it recognizes my controller. Might have issues with a build version, but I can at least work in editor for now.

This was really helpful!

One additional thing that made things simpler for me to support both PS4 and non-PS4 controllers - when you’re setting up the RawInput, you can modify what “Key” each Axis or Action gets interpreted as. That way, you only need to set up “Gamepad Left Thumbstick Y-Axis” or whatnot and it will work for both PS4 and XBox controllers. I also didn’t need to set an offset for any of my axes, and only inverted for the Left Thumbstick Y-Axis.

Here’s what mine ended up looking like:

Hi folks,
Thanks for all the great info sharing here. For some reason, the minute I play the game, the character will run forwards and to the right ignoring any controller input. In fact there is no input form controller whatsoever. Am I doing something wrong here?
I checked the Vendor & Product ID and they are the same as you guys mentioned.
The controller is definitely plugged in and Windows can read the movements. Furthermore, the controller works fine when I use DS Windows App btw.