DefaultPlayerInputClass
DefaultPlayerInputClass
#Overview
name: DefaultPlayerInputClass
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of DefaultPlayerInputClass is to define the default class type for player input objects in Unreal Engine 5. This setting variable is primarily used for the input system, specifically for handling player input.
DefaultPlayerInputClass is primarily relied upon by the Engine module, particularly the input system and player controller components. It’s also referenced in the nDisplay plugin, which is part of the Runtime plugins collection.
The value of this variable is typically set in the DefaultInput.ini configuration file. It can be modified programmatically through the UInputSettings class or through the DisplayClusterEditorSettings in the case of the nDisplay plugin.
This variable interacts with other input-related variables and classes, such as UPlayerInput and UInputComponent. It’s also related to the OverridePlayerInputClass property in the PlayerController class, which can be used to override the default input class on a per-controller basis.
Developers must be aware that changing this variable affects the entire input system of the game. It determines what class will be instantiated to handle player input for all player controllers by default. Changing it incorrectly could lead to input-related issues throughout the game.
Best practices when using this variable include:
- Ensure that any custom class assigned to DefaultPlayerInputClass inherits from UPlayerInput.
- Be cautious when changing this value, as it affects the entire game’s input system.
- If you need to use a different input class for specific player controllers, consider using the OverridePlayerInputClass property on those controllers instead of changing the global default.
- When working with the nDisplay plugin, be aware that it may modify this setting as part of its functionality.
- Always validate that the class reference is valid before using it, as demonstrated in the GetDefaultPlayerInputClass() function.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultInput.ini:32, section: [/Script/Engine.InputSettings]
- INI Section:
/Script/Engine.InputSettings
- Raw value:
/Script/EnhancedInput.EnhancedPlayerInput
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterEditor/Private/Settings/DisplayClusterEditorSettings.cpp:62
Scope (from outer to inner):
file
function void UDisplayClusterEditorSettings::PostEditChangeProperty
Source code excerpt:
// DefaultInput.ini
GConfig->SetString(TEXT("/Script/Engine.InputSettings"), TEXT("DefaultPlayerInputClass"), TEXT("/Script/DisplayCluster.DisplayClusterPlayerInput"), DefaultInputPath);
}
// Process nDisplay 'disable' command
else
{
// DefaultEngine.ini
GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("GameEngine"), TEXT("/Script/Engine.GameEngine"), DefaultEnginePath);
#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterEditor/Private/Settings/DisplayClusterEditorSettings.cpp:76
Scope (from outer to inner):
file
function void UDisplayClusterEditorSettings::PostEditChangeProperty
Source code excerpt:
// DefaultInput.ini
GConfig->SetString(TEXT("/Script/Engine.InputSettings"), TEXT("DefaultPlayerInputClass"), TEXT("/Script/EnhancedInput.EnhancedPlayerInput"), DefaultInputPath);
}
// Save changes to the files
GConfig->Flush(false, DefaultEnginePath);
GConfig->Flush(false, DefaultGamePath);
GConfig->Flush(false, DefaultInputPath);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/InputSettings.h:170
Scope (from outer to inner):
file
class class UInputSettings : public UObject
Source code excerpt:
/** Default class type for player input object. May be overridden by player controller. */
UPROPERTY(config, EditAnywhere, NoClear, Category = DefaultClasses)
TSoftClassPtr<UPlayerInput> DefaultPlayerInputClass;
/** Default class type for pawn input components. */
UPROPERTY(config, EditAnywhere, NoClear, Category = DefaultClasses)
TSoftClassPtr<UInputComponent> DefaultInputComponentClass;
public:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/PlayerController.h:1720
Scope: file
Source code excerpt:
TObjectPtr<class UTouchInterface> CurrentTouchInterface;
/** If set, then this UPlayerInput class will be used instead of the Input Settings' DefaultPlayerInputClass */
UPROPERTY(EditDefaultsOnly, Category = Input)
TSubclassOf<UPlayerInput> OverridePlayerInputClass;
/** Handle for efficient management of UnFreeze timer */
FTimerHandle TimerHandle_UnFreeze;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:32
Scope (from outer to inner):
file
function UInputSettings::UInputSettings
Source code excerpt:
, DefaultViewportMouseCaptureMode(EMouseCaptureMode::CapturePermanently_IncludingInitialMouseDown)
, DefaultViewportMouseLockMode(EMouseLockMode::LockOnCapture)
, DefaultPlayerInputClass(UPlayerInput::StaticClass())
, DefaultInputComponentClass(UInputComponent::StaticClass())
{
PlatformSettings.Initialize(UInputPlatformSettings::StaticClass());
}
void UInputSettings::RemoveInvalidKeys()
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:493
Scope (from outer to inner):
file
function UClass* UInputSettings::GetDefaultPlayerInputClass
Source code excerpt:
UClass* UInputSettings::GetDefaultPlayerInputClass()
{
TSoftClassPtr<UPlayerInput> Class = UInputSettings::GetInputSettings()->DefaultPlayerInputClass;
ensureMsgf(Class.IsValid(), TEXT("Invalid PlayerInput class in Input Settings. Manual reset required."));
return Class.IsValid() ? Class.Get() : UPlayerInput::StaticClass();
}
UClass* UInputSettings::GetDefaultInputComponentClass()
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:510
Scope (from outer to inner):
file
function void UInputSettings::SetDefaultPlayerInputClass
Source code excerpt:
{
UInputSettings* InputSettings = Cast<UInputSettings>(UInputSettings::StaticClass()->GetDefaultObject());
InputSettings->DefaultPlayerInputClass = NewDefaultPlayerInputClass;
}
}
void UInputSettings::SetDefaultInputComponentClass(TSubclassOf<UInputComponent> NewDefaultInputComponentClass)
{
if(ensure(NewDefaultInputComponentClass))