bCaptureMouseOnLaunch

bCaptureMouseOnLaunch

#Overview

name: bCaptureMouseOnLaunch

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 bCaptureMouseOnLaunch is to control whether the viewport captures the mouse cursor when the application is launched. This setting is primarily related to the input handling and viewport management system in Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the Game Viewport Client, which is part of the Engine module. This can be seen from the reference in the GameViewportClient.cpp file.

The value of this variable is set in the InputSettings class constructor (InputSettings.cpp) with a default value of true. It can be modified through the Unreal Engine editor in the project settings under the “Input” category, as it is marked with the UPROPERTY macro and the “config” and “EditAnywhere” specifiers.

There don’t appear to be any other variables directly interacting with bCaptureMouseOnLaunch based on the provided code snippets. However, it is used in conjunction with FApp::CanEverRender() to determine the final behavior in the CaptureMouseOnLaunch function.

Developers must be aware that this setting affects the initial mouse behavior when the game launches. If set to true, the mouse cursor will be captured by the game viewport, which is typically desired for first-person or third-person games. If set to false, the mouse cursor will remain free, which might be more suitable for strategy games or UIs that require mouse interaction outside the game viewport.

Best practices when using this variable include:

  1. Consider the game genre and required input style when setting this value.
  2. Ensure that there’s a way for players to release the mouse capture if needed (e.g., through an in-game menu or a specific key binding).
  3. Be aware that this setting might interact with platform-specific behaviors or other input-related settings.
  4. Document the chosen setting and its implications for other team members, especially those working on UI or input systems.
  5. Test the mouse capture behavior on different platforms to ensure consistency across various environments.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultInput.ini:25, section: [/Script/Engine.InputSettings]

#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:55

Scope (from outer to inner):

file
class        class UInputSettings : public UObject

Source code excerpt:

	/** Controls if the viewport will capture the mouse on Launch of the application */
	UPROPERTY(config, EditAnywhere, Category = "ViewportProperties")
	uint8 bCaptureMouseOnLaunch:1;

	/** Enable the use of legacy input scales on the player controller (InputYawScale, InputPitchScale, and InputRollScale) */
	UPROPERTY(config, EditAnywhere, Category = "Input")
	uint8 bEnableLegacyInputScales:1;
	
	/**

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:3076

Scope (from outer to inner):

file
function     bool UGameViewportClient::CaptureMouseOnLaunch

Source code excerpt:

{
	// Capture mouse unless headless
	return !FApp::CanEverRender() ? false : GetDefault<UInputSettings>()->bCaptureMouseOnLaunch;
}

void UGameViewportClient::SetMouseLockMode(EMouseLockMode InMouseLockMode)
{
	if (MouseLockMode != InMouseLockMode)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:23

Scope (from outer to inner):

file
function     UInputSettings::UInputSettings

Source code excerpt:

UInputSettings::UInputSettings(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
	, bCaptureMouseOnLaunch(true)
	, bEnableLegacyInputScales(true)
	, bEnableMotionControls(true)
	, bFilterInputByPlatformUser(false)
	, bEnableInputDeviceSubsystem(true)
	, bShouldFlushPressedKeysOnViewportFocusLost(true)
	, bEnableDynamicComponentInputBinding(true)