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

**URL:** <https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314>\
**Category:** Community & Industry Discussion\
**Tags:** unreal-engine\
**Created:** [November 11, 2019, 4:30pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314 "2019-11-11T16:30:24Z")\
**Posts on this page:** 14\
**Page:** 3

<div class="post-metadata">

**Author:** ![iouzzr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iouzzr](https://forums.unrealengine.com/u/iouzzr)\
**Post date:** [February 23, 2022, 8:57am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/42 "2022-02-23T08:57:11Z")

</div>

I think you don’t understand the analog stick’s output value and the settings in Raw Input. If you leave Gamepad Stick option unchecked which is the default, Raw Input will map analog stick’s output range from 0 to 1. For example, if you are using analog stick to move forward or backward, you will get 0 when you move analog stick to backward extreme position and get 1 when move to forward extreme. This means that if you leave your analog stick to rest position, it will output 0.5. This value will make your character move forward in template project.  
Raw Input is doing right, you just don’t know it well.

---

<div class="post-metadata">

**Author:** ![iouzzr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iouzzr](https://forums.unrealengine.com/u/iouzzr)\
**Post date:** [February 23, 2022, 10:19am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/43 "2022-02-23T10:19:20Z")

</div>

I have the same behavior as you, the whole Dpad is detected as Axis 5, I am on 4.27.2. I am very worried at first and thinking what’s wrong with this Raw Input plugin. However, I don’t think this is an “issue” now and I am started to think what if the “correct” information @DarknessFX gave is wrong? I am saying this because I use the XInputChecker in DS4 Windows to check my DS4 input. In the XInputChecker, the LS X and Y axis are separate channels which is same as Raw Input. The Dpad however is one channel and the output it gave is one of these: centered, up, upright, right, downright, down, downleft, left, upleft. This makes sense for Raw Input to put the whole Dpad as axis 5. You can also check these Dpad output values in showdebug.  
My conclusion is that below information @DarknessFX gave is not correct:  
Dpad V - Axis 5  
Dpad H - Axis 6  
Instead, Raw Input maps the whole Dpad to axis 5.

---

<div class="post-metadata">

**Author:** ![Suecus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Suecus](https://forums.unrealengine.com/u/Suecus)\
**Post date:** [February 23, 2022, 2:51pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/44 "2022-02-23T14:51:57Z")

</div>

If you look at the value given from Axis 5 for DPad, you can quickly calculate what button on the DPad you are pressing. If you press the “Up” button on the DPad the value is 0. And if you go clockvise then the value goes from 0 - 1. (This is on the DS4)

In the blueprint you can see that I just print the direction of which button is pressed.

 ![DPad_DS4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/4/1/d412d3f684f4bf997f7ecc2234af0f2dfcfd462f.png)

---

<div class="post-metadata">

**Author:** ![DarknessFX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/darknessfx/32/1194676_2.png) [@DarknessFX](https://forums.unrealengine.com/u/DarknessFX)\
**Post date:** [February 23, 2022, 7:16pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/45 "2022-02-23T19:16:31Z")

</div>

@iouzzr At that time, Nov/2019 with UE4.23 and PS4 gamepad (1st gen?), it worked like that. But since then looks like a lot of things changed.  
Philv123 post (from Sep/2020 with UE4.25.3) mentioned USB Axis5 having DpadV&H and Axis6 not displaying anything.

> [@\[Tutorial\] UE4 using Dualshock4 controller (via USB, PS4 DS4 Gamepad)](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/24):
>
> 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](https://docs.unrealengine.com/en-US/Gameplay/Input/RawInput/index.html) shows how to find this). Here’s all my sett…

---

<div class="post-metadata">

**Author:** ![SteadySoliloquy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteadySoliloquy](https://forums.unrealengine.com/u/SteadySoliloquy)\
**Post date:** [March 2, 2022, 2:30am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/46 "2022-03-02T02:30:09Z")

</div>

![DpadBP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/5/b/f5b534d40dd979cb78560709f07b0242de719a53.png)

---

<div class="post-metadata">

**Author:** ![SteadySoliloquy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteadySoliloquy](https://forums.unrealengine.com/u/SteadySoliloquy)\
**Post date:** [March 4, 2022, 11:10pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/47 "2022-03-04T23:10:57Z")

</div>

![dpad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/2/ff23e813583ca2fce455bcf5ceb5ff8f40022363.png)

Thank you all so much!

---

<div class="post-metadata">

**Author:** ![jumpAkross](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jumpakross/32/903172_2.png) [@jumpAkross](https://forums.unrealengine.com/u/jumpAkross)\
**Post date:** [March 18, 2022, 6:22am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/48 "2022-03-18T06:22:50Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/c/8/1c8748faddfd2609aed5abc63d3a2f1ac463acd9.png)

For me, my issue was that my character kept moving, almost as if the game-pad had no DeadZone. The “Nearly Equal” fixed it. Thanks for the tips everyone!

---

<div class="post-metadata">

**Author:** ![SteadySoliloquy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteadySoliloquy](https://forums.unrealengine.com/u/SteadySoliloquy)\
**Post date:** [March 19, 2022, 2:04am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/49 "2022-03-19T02:04:33Z")

</div>

It’s Dangerous to go Alone! Take This:  
//// Adding Dualshock4 controller support to UnrealEngine4 project with C++  
Edit \> Plugins \> Add Windows Raw Input.  
Edit \> Project Settings \> Raw Input :  
Set Register Default Device True.  
Add 1 Device Configurations.  
VendorID 0x054C // sony  
ProductID 0x09CC // 2nd gen dualshock4  
Axis 1,2,4 Properties \> Joystick True  
Axis 3 Properties \> Inverted True, Joystick True  
Edit \> Project Settings \> Input :  
Assign Axis/Action Bindings  
Use Scale 2.0 for GenericUSBController Joystick Axis  
Make RawDpadAxis Input, use scale 1.0 for Dpad Axis

//// GenericUSBController config/events:  
X - Generic USB Button 2  
[] - Generic USB Button 1  
O - Generic USB Button 3  
/\ - Generic USB Button 4  
L1 - Generic USB Button 5  
L2 - Generic USB Button 7 + Axis 8  
L3 - Generic USB Button 11  
R1 - Generic USB Button 6  
R2 - Generic USB Button 8 + Axis 7  
R3 - Generic USB Button 12  
RStick V - Axis 1  
RStick H - Axis 2  
LStick V - Axis 3  
LStick H - Axis 4  
Dpad - Axis 5 // 2nd gen dualshock4  
Share - Generic USB Button 9  
Options - Generic USB Button 10  
PSButton - Generic USB Button 13  
TouchPad Click - Generic USB Button 14

//// all possible Dpad axis values  
Neutral Nearly = 1.14  
Up = 0.0  
Up/Right Nearly = 0.14  
Right Nearly = 0.28  
Down/Right Nearly = 0.42  
Down Nearly = 0.57  
Down/Left Nearly = 0.71  
Left Nearly = 0.85  
Up/Left = 1.0  
Error Tollerance = 0.05

//// input.ini joystick deadzones  
+AxisConfig=(AxisKeyName=“GenericUSBController\_Axis1”,AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))  
+AxisConfig=(AxisKeyName=“GenericUSBController\_Axis2”,AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))  
+AxisConfig=(AxisKeyName=“GenericUSBController\_Axis3”,AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))  
+AxisConfig=(AxisKeyName=“GenericUSBController\_Axis4”,AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))

//// using these headers in the cpp file:  
// using debug messages  
#include “Engine/GameEngine.h”  
// using FMath::IsNearlyEqual  
#include “Math/UnrealMathUtility.h”

//// create and initialize local bools above the Dpad Axis function.  
/\*  
bool bDpadNeutral = false;  
_/  
bool bDpadUp = false; // UP  
/_  
bool bDpadUpRight = false;  
_/  
bool bDpadRight = false; // RIGHT  
/_  
bool bDpadDownRight = false;  
_/  
bool bDpadDown = false; // DOWN  
/_  
bool bDpadDownLeft = false;  
_/  
bool bDpadLeft = false; // LEFT  
/_  
bool bDpadUpLeft = false;  
\*/

//// Windows RawInput Dpad Axis  
// using a bool as a set/reset latch to treat a specific axis value as a button event.  
void ABaseCharacter::RawDpadAxis(float Value)  
{  
// Neutral  
/\*  
if (FMath::IsNearlyEqual(Value, 1.14f, 0.05f)) // is Dpad returning correct value for desired position?  
{  
if (!bDpadNeutral) // is latch reset?  
{  
bDpadNeutral = true; // set latch  
if (GEngine) // print string for debugging  
{  
GEngine-\>AddOnScreenDebugMessage(-1, 0.5f, FColor::Yellow, TEXT(“Neutral!”));  
}  
}  
}  
else if (bDpadNeutral) // when Dpad is not returning correct value for desired position, is latch set?  
{  
bDpadNeutral = false; // reset latch  
}  
\*/

```
// Up
if (Value == 0.0f)
{
	if (!bDpadUp)
	{
		bDpadUp = !bDpadUp;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Green, TEXT("Up!"));
		}
	}
}
else if (bDpadUp)
{
	bDpadUp = !bDpadUp;
}

// UpRight
/*
if (FMath::IsNearlyEqual(Value, 0.14f, 0.05f))
{
	if (!bDpadUpRight)
	{
		bDpadUpRight = true;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Blue, TEXT("UpRight!"));
		}
	}
}
else if (bDpadUpRight)
{
	bDpadUpRight = false;
}
*/

// Right
if (FMath::IsNearlyEqual(Value, 0.28f, 0.05f))
{
	if (!bDpadRight)
	{
		bDpadRight = !bDpadRight;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Orange, TEXT("Right!"));
		}
	}
}
else if (bDpadRight)
{
	bDpadRight = !bDpadRight;
}

// DownRight
/*
if (FMath::IsNearlyEqual(Value, 0.42f, 0.05f))
{
	if (!bDpadDownRight)
	{
		bDpadDownRight = true;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Blue, TEXT("DownRight!"));
		}
	}
}
else if (bDpadDownRight)
{
	bDpadDownRight = false;
}
*/

// Down
if (FMath::IsNearlyEqual(Value, 0.57f, 0.05f))
{
	if (!bDpadDown)
	{
		bDpadDown = !bDpadDown;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Red, TEXT("Down!"));
		}
	}
}
else if (bDpadDown)
{
	bDpadDown = !bDpadDown;
}

// DownLeft
/*
if (FMath::IsNearlyEqual(Value, 0.71f, 0.05f))
{
	if (!bDpadDownLeft)
	{
		bDpadDownLeft = true;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Blue, TEXT("DownLeft!"));
		}
	}
}
else if (bDpadDownLeft)
{
	bDpadDownLeft = false;
}
*/

// Left
if (FMath::IsNearlyEqual(Value, 0.85f, 0.05f))
{
	if (!bDpadLeft)
	{
		bDpadLeft = !bDpadLeft;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Purple, TEXT("Left!"));
		}
	}
}
else if (bDpadLeft)
{
	bDpadLeft = !bDpadLeft;
}

// UpLeft
/*
if (Value == 1.0f)
{
	if (!bDpadUpLeft)
	{
		bDpadUpLeft = true;
		if (GEngine)
		{
			GEngine->AddOnScreenDebugMessage(-1, 0.5f, FColor::Blue, TEXT("UpLeft!"));
		}
	}
}
else if (bDpadUpLeft)
{
	bDpadUpLeft = false;
}
*/

```

}

---

<div class="post-metadata">

**Author:** ![SteadySoliloquy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteadySoliloquy](https://forums.unrealengine.com/u/SteadySoliloquy)\
**Post date:** [March 22, 2022, 12:32am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/50 "2022-03-22T00:32:09Z")

</div>

If you enable Windows RawInput Plugin the default “Gamepad” input will stop working properly on Windows, you could add another device configuration to raw input and just not use “Gamepad” inputs, but you’d need to change the input bindings based on what configuration was detected as the xbox controller has different native input definitions than the dualshock controller.

---

<div class="post-metadata">

**Author:** ![RealGAMEBR0VIP1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RealGAMEBR0VIP1](https://forums.unrealengine.com/u/RealGAMEBR0VIP1)\
**Post date:** [October 8, 2022, 1:16pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/51 "2022-10-08T13:16:40Z")

</div>

Someone Just Share To Us The Input Profile With The Generic Buttons Mapped To Xbox Already done.???Same with the raw input profile?..make life easier onn everyone.

---

<div class="post-metadata">

**Author:** ![Akari\_Enderwolf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/akari_enderwolf/32/598749_2.png) [@Akari\_Enderwolf](https://forums.unrealengine.com/u/Akari_Enderwolf)\
**Post date:** [October 16, 2022, 2:23pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/52 "2022-10-16T14:23:27Z")

</div>

Here’s the other image I wanted to include since I can currently only put one per post.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/c/e4cbbfa546f85aa359c3a1b89286ba508161d20d.png)

---

<div class="post-metadata">

**Author:** ![Akari\_Enderwolf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/akari_enderwolf/32/598749_2.png) [@Akari\_Enderwolf](https://forums.unrealengine.com/u/Akari_Enderwolf)\
**Post date:** [October 16, 2022, 2:24pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/53 "2022-10-16T14:24:14Z")

</div>

I got my D-pad working with full 8-directional movement for a top-down game.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/2/9722a1b355c60344241945c049a5efffffca4f32.jpeg)

Axis 3 and Axis 4 in the up/down and left/right Axis Mappings should be set to a scale of 2 still.  
The below portion is the .ini to import for RawInput

```auto
[/Script/RawInput.RawInputSettings]
DeviceConfigurations=(VendorID="0x054c",ProductID="0x09cc",AxisProperties=((Key=GenericUSBController_Axis1,bInverted=True,bGamepadStick=True),(Key=GenericUSBController_Axis2,bGamepadStick=True),(Key=GenericUSBController_Axis3,bInverted=True,bGamepadStick=True),(Key=GenericUSBController_Axis4,bGamepadStick=True),(Key=GenericUSBController_Axis5),(Key=GenericUSBController_Axis6),(Key=GenericUSBController_Axis7,bInverted=True),(Key=GenericUSBController_Axis8,bInverted=True)),ButtonProperties=((Key=GenericUSBController_Button1),(Key=GenericUSBController_Button2),(Key=GenericUSBController_Button3),(Key=GenericUSBController_Button4),(Key=GenericUSBController_Button5),(Key=GenericUSBController_Button6),(Key=GenericUSBController_Button7),(Key=GenericUSBController_Button8),(Key=GenericUSBController_Button9),(Key=GenericUSBController_Button10),(Key=GenericUSBController_Button11),(Key=GenericUSBController_Button12),(Key=GenericUSBController_Button13),(Key=GenericUSBController_Button14),(Key=GenericUSBController_Button15),(Key=GenericUSBController_Button16),(Key=GenericUSBController_Button17),(Key=GenericUSBController_Button18),(Key=GenericUSBController_Button19),(Key=GenericUSBController_Button20)))
bRegisterDefaultDevice=True

```

---

<div class="post-metadata">

**Author:** ![CorentinG78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/corenting78/32/1109769_2.png) [@CorentinG78](https://forums.unrealengine.com/u/CorentinG78)\
**Post date:** [January 5, 2023, 1:12pm UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/54 "2023-01-05T13:12:51Z")

</div>

I allow myself to up this post because with UE5.1 I think all the solutions above are broken (at least in my experience).  
With the enhanced input system + Raw input plugin:

- The axis configs in the “input” are ignored with the enhanced input system
- The axis proprieties in the “Raw input” section are ignored with the enhanced input system

So the only way to make it work is to:

1. Create your own Enhanced input modifier (create new bp\>class=input modifier)
2. Hover Functions with mouse \>override button\>Modify raw
3. Add the nodes as the screenshot attached
4. Add your custom modifier to your controller input
5. (Optional) Add the “DeadZone” or the “Negate” modifier on top of your custom modifier

Depending on what you want, the nodes below might need modifications, but at least you know where to modify stuff 😅

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/e/3eeb956117f7c7bfaded5f1c36bb49158ffb78bf.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/9/5b9d610b4a529cb170a6c70943fb913b0a22fe62.png)

---

<div class="post-metadata">

**Author:** ![DarknessFX](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/darknessfx/32/1194676_2.png) [@DarknessFX](https://forums.unrealengine.com/u/DarknessFX)\
**Post date:** [January 21, 2023, 10:04am UTC](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314/55 "2023-01-21T10:04:12Z")

</div>

For everyone using #UnrealEngine5.1 and have a Playstation DualShock4, I published a project that have RawInputWindows + EnhancedInput ready for this gamepad.

–

Free and open source : [GitHub - DarknessFX/DualShock4-For-Unreal-Engine-5: DualShock4 For Unreal Engine 5.1 using Raw Input and Enhanced Input.](https://github.com/DarknessFX/DualShock4-For-Unreal-Engine-5)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/2/6c2a5c0106fff1e44c3057f633c6a9f99233ce51.jpeg)

[Previous page](https://forums.unrealengine.com/t/tutorial-ue4-using-dualshock4-controller-via-usb-ps4-ds4-gamepad/133314.md?page=2)
