DefaultViewportMouseLockMode
DefaultViewportMouseLockMode
#Overview
name: DefaultViewportMouseLockMode
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 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of DefaultViewportMouseLockMode is to control the default behavior of mouse locking when the viewport acquires capture in Unreal Engine 5. This setting is part of the input system and affects how the mouse interacts with the game viewport.
This setting variable is primarily used by the Engine module, specifically within the input and viewport management systems. It is defined in the UInputSettings class, which is part of the core engine functionality for handling input configurations.
The value of this variable is set in the constructor of UInputSettings, where it is initialized to EMouseLockMode::LockOnCapture. However, it can be modified through project settings or configuration files, as indicated by the UPROPERTY(config) attribute.
DefaultViewportMouseLockMode interacts with other input-related variables, such as DefaultViewportMouseCaptureMode, which controls how the mouse is captured by the viewport. Together, these settings determine how the mouse behaves when interacting with the game viewport.
Developers must be aware that this variable affects the default behavior for all viewports in the game. It’s important to consider how this setting might impact different platforms or input scenarios, especially when developing for multiple platforms with varying input methods.
Best practices when using this variable include:
- Carefully consider the appropriate mouse lock mode for your game’s needs, as it can significantly affect the player’s experience.
- Be mindful of platform-specific requirements or expectations regarding mouse behavior.
- Test thoroughly on all target platforms to ensure the chosen setting provides the desired user experience.
- Consider providing in-game options for players to adjust this setting if mouse behavior is crucial to gameplay or comfort.
- Be aware of how this setting interacts with other input and viewport settings to create a cohesive input experience.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultInput.ini:28, section: [/Script/Engine.InputSettings]
- INI Section:
/Script/Engine.InputSettings
- Raw value:
LockOnCapture
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/InputSettings.h:145
Scope (from outer to inner):
file
class class UInputSettings : public UObject
Source code excerpt:
/** The default mouse lock state behavior when the viewport acquires capture */
UPROPERTY(config, EditAnywhere, Category = "ViewportProperties")
EMouseLockMode DefaultViewportMouseLockMode;
// The scaling value to multiply the field of view by
UPROPERTY(config, EditAnywhere, Category="MouseProperties", AdvancedDisplay, meta=(editcondition="bEnableFOVScaling"))
float FOVScale;
/** If a key is pressed twice in this amount of time it is considered a "double click" */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:508
Scope (from outer to inner):
file
function void UGameViewportClient::Init
Source code excerpt:
}
}
MouseLockMode = GetDefault<UInputSettings>()->DefaultViewportMouseLockMode;
// Don't capture mouse when headless
if(!FApp::CanEverRender())
{
MouseCaptureMode = EMouseCaptureMode::NoCapture;
MouseLockMode = EMouseLockMode::DoNotLock;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:31
Scope (from outer to inner):
file
function UInputSettings::UInputSettings
Source code excerpt:
, bEnableDynamicComponentInputBinding(true)
, DefaultViewportMouseCaptureMode(EMouseCaptureMode::CapturePermanently_IncludingInitialMouseDown)
, DefaultViewportMouseLockMode(EMouseLockMode::LockOnCapture)
, DefaultPlayerInputClass(UPlayerInput::StaticClass())
, DefaultInputComponentClass(UInputComponent::StaticClass())
{
PlatformSettings.Initialize(UInputPlatformSettings::StaticClass());
}