Reference
C++ API
Use the DualSense subsystem and trigger effect factories from C++.
Module dependency
Add the plugin module to your game's .Build.cs:
MyGame.Build.cs
PublicDependencyModuleNames.Add("DualSenseUnrealEnginePlugin");
UDualSenseSubsystem
#include "UDualSenseSubsystem.h"
A UGameInstanceSubsystem that stores the output state of each controller and sends it. Get it from the Game Instance:
UDualSenseSubsystem* DualSense = GetGameInstance()->GetSubsystem<UDualSenseSubsystem>();
The Blueprint nodes are thin wrappers around these functions, with the same behaviour: setters change the stored state, UpdateOutput sends it.
Output
void UpdateOutput(int32 ControllerId = 0);
void SetLightbarColor(int32 ControllerId, FLinearColor Color);
void DisableLightbar(int32 ControllerId);
void SetPlayerLeds(int32 ControllerId, EPlayerLedPreset Preset,
ELedBrightness Brightness = ELedBrightness::High, bool bFade = false);
void SetPlayerLedsBitmask(int32 ControllerId, EPlayerLed Bitmask,
ELedBrightness Brightness = ELedBrightness::High, bool bFade = false);
void SetMicLed(int32 ControllerId, EMicLed State);
void SetRumble(int32 ControllerId, float LeftIntensity, float RightIntensity);
void StopRumble(int32 ControllerId);
void SetTriggerEffect(int32 ControllerId, EDSTriggerHand Hand, const FDS5TriggerEffect& Effect);
void StopTrigger(int32 ControllerId, EDSTriggerHand Hand);
void SetFullOutputState(int32 ControllerId, const FDS5OutputState& State);
void ResetOutputState(int32 ControllerId);
State and status
bool IsControllerConnected(int32 ControllerId = 0) const;
int32 GetConnectedControllerCount() const;
// The stored output state of a slot, or nullptr if nothing was set for it yet.
const FDS5OutputState* GetCachedState(int32 ControllerId) const;
UpdateOutput on a slot that was never set sends the default state: everything off.FDS5TriggerEffect factories
#include "DS5States.h"
Static functions that build a trigger effect with the same parameters as the DS Make Trigger ... nodes:
static FDS5TriggerEffect MakeOff();
static FDS5TriggerEffect MakeFeedback(int32 Position, int32 Strength);
static FDS5TriggerEffect MakeWeapon(int32 StartPosition, int32 EndPosition, int32 Strength);
static FDS5TriggerEffect MakeVibration(int32 Position, int32 Amplitude, int32 Frequency);
static FDS5TriggerEffect MakeSlopeFeedback(int32 StartPosition, int32 EndPosition, int32 StartStrength, int32 EndStrength);
static FDS5TriggerEffect MakeMultiplePositionFeedback(const TArray<int32>& ZoneStrengths);
static FDS5TriggerEffect MakeMultiplePositionVibration(int32 Frequency, const TArray<int32>& ZoneAmplitudes);
static FDS5TriggerEffect MakeBow(int32 StartPosition, int32 EndPosition, int32 Strength, int32 SnapForce);
static FDS5TriggerEffect MakeGalloping(int32 StartPosition, int32 EndPosition, int32 FirstFoot, int32 SecondFoot, int32 Frequency);
static FDS5TriggerEffect MakeMachine(int32 StartPosition, int32 EndPosition, int32 AmplitudeA, int32 AmplitudeB, int32 Frequency, int32 Period);
static FDS5TriggerEffect MakeRaw(const TArray<uint8>& Bytes);
Example: a weapon component
MyWeaponComponent.cpp
#include "UDualSenseSubsystem.h"
void UMyWeaponComponent::OnEquipped()
{
if (UDualSenseSubsystem* DualSense = GetWorld()->GetGameInstance()->GetSubsystem<UDualSenseSubsystem>())
{
DualSense->SetTriggerEffect(0, EDSTriggerHand::Right, FDS5TriggerEffect::MakeWeapon(2, 5, 3));
DualSense->SetLightbarColor(0, FLinearColor(1.f, 0.35f, 0.f));
DualSense->UpdateOutput(0);
}
}
void UMyWeaponComponent::OnUnequipped()
{
if (UDualSenseSubsystem* DualSense = GetWorld()->GetGameInstance()->GetSubsystem<UDualSenseSubsystem>())
{
DualSense->StopTrigger(0, EDSTriggerHand::Right);
DualSense->DisableLightbar(0);
DualSense->UpdateOutput(0);
}
}
Input keys
The DualSense-only keys are registered as FKeys named DualSense_PS, DualSense_Touchpad and DualSense_Mic:
static const FKey PSButton(TEXT("DualSense_PS"));
if (PlayerController->WasInputKeyJustPressed(PSButton))
{
OpenPauseMenu();
}
The other buttons use the standard EKeys::Gamepad_* keys. See Input.
Logging
The plugin logs to the LogDualSense category: connections, disconnections and failed writes to the controller.