input.DisableHaptics
input.DisableHaptics
#Overview
name: input.DisableHaptics
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If greater than zero, no haptic feedback is processed.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of input.DisableHaptics is to provide a way to disable haptic feedback processing in the game. This setting variable is primarily used in the input and player controller systems of Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the player input system, specifically within the PlayerController class. This can be seen in the PlayerController.cpp file where the variable is used.
The value of this variable is set through a console variable (CVar) named CVarDisableHaptics. It is initialized with a default value of 0, meaning haptics are enabled by default. The value can be changed at runtime through the console or programmatically.
The associated variable CVarDisableHaptics interacts directly with input.DisableHaptics. They share the same value and purpose. CVarDisableHaptics is used in conjunction with a class member variable bDisableHaptics to determine if haptics should be disabled.
Developers must be aware that this variable affects all haptic feedback in the game when set to a value greater than zero. It’s a global setting that can impact the player’s experience across all controllers and haptic devices.
Best practices when using this variable include:
- Use it for debugging or testing purposes when you need to quickly disable all haptics.
- Consider providing a user-facing option in the game settings to toggle haptics, which could utilize this variable.
- Be cautious when setting this variable programmatically, as it affects all haptic feedback globally.
Regarding the associated variable CVarDisableHaptics:
- Its purpose is to provide programmatic access to the input.DisableHaptics setting.
- It’s used in the PlayerController class to check if haptics should be disabled.
- The value is retrieved using the GetValueOnGameThread() method.
- It’s combined with the bDisableHaptics class member in a boolean OR operation to determine if haptics are disabled.
- Developers should be aware that changes to CVarDisableHaptics will immediately affect haptic feedback processing.
- Best practices include using this variable for runtime toggling of haptics and ensuring it’s properly reset if temporary disabling is needed.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:4484
Scope: file
Source code excerpt:
}
static TAutoConsoleVariable<int32> CVarDisableHaptics(TEXT("input.DisableHaptics"),0,TEXT("If greater than zero, no haptic feedback is processed."));
void APlayerController::SetHapticsByValue(const float Frequency, const float Amplitude, EControllerHand Hand)
{
bool bAreHapticsDisabled = bDisableHaptics || (CVarDisableHaptics.GetValueOnGameThread() > 0);
if (bAreHapticsDisabled)
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarDisableHaptics
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:4484
Scope: file
Source code excerpt:
}
static TAutoConsoleVariable<int32> CVarDisableHaptics(TEXT("input.DisableHaptics"),0,TEXT("If greater than zero, no haptic feedback is processed."));
void APlayerController::SetHapticsByValue(const float Frequency, const float Amplitude, EControllerHand Hand)
{
bool bAreHapticsDisabled = bDisableHaptics || (CVarDisableHaptics.GetValueOnGameThread() > 0);
if (bAreHapticsDisabled)
{
return;
}
if (Hand == EControllerHand::Left)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:4714
Scope (from outer to inner):
file
function void APlayerController::ProcessForceFeedbackAndHaptics
Source code excerpt:
UpdateForceFeedback(InputInterface, ControllerId);
const bool bAreHapticsDisabled = (CVarDisableHaptics.GetValueOnGameThread() > 0) || bDisableHaptics;
if (!bAreHapticsDisabled)
{
// Haptic Updates
if (bLeftHapticsNeedUpdate)
{
InputInterface->SetHapticFeedbackValues(ControllerId, (int32)EControllerHand::Left, LeftHaptics);