EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation
EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation
#Overview
name: EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When true, Enhanced Input key mappings will throw an error during validation if they are mapped to an empty key.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation is to enable or disable error reporting during validation for Enhanced Input key mappings that are mapped to an empty key.
This setting variable is primarily used in the Enhanced Input plugin, which is part of Unreal Engine’s input system. Specifically, it’s used in the data validation process for Enhanced Action Key Mappings.
The value of this variable is set through a console variable (CVar) system. It’s defined as a static TAutoConsoleVariable
This variable interacts closely with the EKeys::Invalid value in the key mapping validation process. When the variable is set to true, the system will throw an error during validation if a key mapping is set to EKeys::Invalid.
Developers must be aware that enabling this setting will cause errors to be reported for any empty key mappings during validation. This can be useful for catching potential issues in input configurations, but it may also interfere with intentional design choices if empty mappings are used purposefully.
Best practices when using this variable include:
- Enable it during development and testing phases to catch unintended empty mappings.
- Consider disabling it before release if your game design intentionally uses empty mappings.
- Use it in conjunction with thorough testing of your input system to ensure all mappings are intentional.
Regarding the associated variable CVarCheckForEmptyKeyMappingsDuringValidation:
The purpose of CVarCheckForEmptyKeyMappingsDuringValidation is to serve as the actual console variable that controls the behavior defined by EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation.
This variable is part of the Enhanced Input plugin and is used in the FEnhancedActionKeyMapping::IsDataValid function to determine whether to validate against empty key mappings.
The value of this variable is set when the console variable is initialized, but it can be changed at runtime through console commands.
This variable directly interacts with the validation logic in the IsDataValid function. When it’s true, the function checks if the Key is EKeys::Invalid and reports an error if so.
Developers should be aware that changes to this variable will immediately affect the behavior of the input mapping validation system. It can be toggled on or off at runtime, which could be useful for debugging but should be used carefully in production environments.
Best practices for using this variable include:
- Use it for debugging input mapping issues during development.
- Consider exposing a way to toggle this setting in debug builds for easier testing.
- Ensure that the final state of this variable in release builds aligns with your game’s input design requirements.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Private/EnhancedActionKeyMapping.cpp:17
Scope (from outer to inner):
file
namespace UE::EnhancedInput
Source code excerpt:
static TAutoConsoleVariable<bool> CVarCheckForEmptyKeyMappingsDuringValidation
(
TEXT("EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation"),
false,
TEXT("When true, Enhanced Input key mappings will throw an error during validation if they are mapped to an empty key."),
ECVF_Default
);
}
#endif // WITH_EDITOR
#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Private/EnhancedActionKeyMapping.cpp:128
Scope (from outer to inner):
file
function EDataValidationResult FEnhancedActionKeyMapping::IsDataValid
Source code excerpt:
const FText ErrorMsg =
FText::Format(
LOCTEXT("MappedToInvalidKey", "Mapping to Input Action {ActionName}. \nEnhanced Input Key Mappings cannot be mapped to EKeys::Invalid when 'EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation' is true!"),
Args);
Context.AddError(ErrorMsg);
}
// Validate the triggers.
#Associated Variable and Callsites
This variable is associated with another variable named CVarCheckForEmptyKeyMappingsDuringValidation
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Private/EnhancedActionKeyMapping.cpp:15
Scope (from outer to inner):
file
namespace UE::EnhancedInput
Source code excerpt:
namespace UE::EnhancedInput
{
static TAutoConsoleVariable<bool> CVarCheckForEmptyKeyMappingsDuringValidation
(
TEXT("EnhancedInput.Mappings.bCheckForEmptyKeyMappingsDuringValidation"),
false,
TEXT("When true, Enhanced Input key mappings will throw an error during validation if they are mapped to an empty key."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Private/EnhancedActionKeyMapping.cpp:119
Scope (from outer to inner):
file
function EDataValidationResult FEnhancedActionKeyMapping::IsDataValid
Source code excerpt:
// can oftentimes having an invalid key mapping could be something that you want to track down because of some custom system you have
// made for your game. This setting makes it really easy to track down any empty mappings!
if (UE::EnhancedInput::CVarCheckForEmptyKeyMappingsDuringValidation.GetValueOnAnyThread() && Key == EKeys::Invalid)
{
Result = EDataValidationResult::Invalid;
FFormatNamedArguments Args;
Args.Add(TEXT("ActionName"), FText::FromString(GetNameSafe(Action)));