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.
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.
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.
@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.
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!
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;
}
*/
}
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.
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.
Here’s the other image I wanted to include since I can currently only put one per post.
I got my D-pad working with full 8-directional movement for a top-down game.
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
[/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
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:
- Create your own Enhanced input modifier (create new bp>class=input modifier)
- Hover Functions with mouse >override button>Modify raw
- Add the nodes as the screenshot attached
- Add your custom modifier to your controller input
- (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
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.