Slate.RequireFocusForGamepadInput

Slate.RequireFocusForGamepadInput

#Overview

name: Slate.RequireFocusForGamepadInput

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.RequireFocusForGamepadInput is to control whether gamepad input should be ignored by the engine when the application is not currently active. This setting is primarily used in the Slate subsystem, which is responsible for Unreal Engine’s user interface framework.

The Unreal Engine subsystem that relies on this setting variable is the Slate module, specifically within the SlateApplication class. This can be seen from the file path where the variable is defined and used: Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through the console. It’s initialized to false by default.

The associated variable that interacts with Slate.RequireFocusForGamepadInput is bRequireFocusForGamepadInput. They share the same value and are used interchangeably in the code.

Developers must be aware that when this variable is set to true, gamepad input will be ignored if the application is not the active window. This can affect the behavior of games, especially in scenarios where the game might be running in the background or on a second monitor.

Best practices when using this variable include:

  1. Consider the target platform and use case of your game. For example, in a multi-tasking environment like PC, you might want to set this to true to prevent accidental input when the game is not in focus.
  2. If you’re developing a game that needs to receive gamepad input even when not in focus (e.g., for certain types of party games), you should keep this set to false.
  3. Be aware that changing this setting might affect user experience, so test thoroughly with different scenarios.

Regarding the associated variable bRequireFocusForGamepadInput:

The purpose of bRequireFocusForGamepadInput is the same as Slate.RequireFocusForGamepadInput, as they share the same value. It’s used internally within the Slate module to implement the behavior controlled by the console variable.

This variable is used in the PollGameDeviceState function of the SlateApplication class. When bRequireFocusForGamepadInput is true, the function will only poll for game device input if the application is active (IsActive() returns true).

Developers should be aware that this variable directly affects the behavior of input polling in the Slate subsystem. Changes to Slate.RequireFocusForGamepadInput will be reflected in bRequireFocusForGamepadInput, and vice versa.

Best practices for bRequireFocusForGamepadInput are the same as those for Slate.RequireFocusForGamepadInput, as they are effectively the same setting. The choice of which to use depends on whether you’re working within the engine code (use bRequireFocusForGamepadInput) or setting it via console commands (use Slate.RequireFocusForGamepadInput).

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:568

Scope: file

Source code excerpt:

static bool bRequireFocusForGamepadInput = false;
FAutoConsoleVariableRef CVarRequireFocusForGamepadInput(
	TEXT("Slate.RequireFocusForGamepadInput"),
	bRequireFocusForGamepadInput,
	TEXT("Whether gamepad input should be ignored by the engine if the application is not currently active")
);

static bool TransformFullscreenMouseInput = true;
FAutoConsoleVariableRef CVarSlateTransformFullscreenMouseInput(

#Associated Variable and Callsites

This variable is associated with another variable named bRequireFocusForGamepadInput. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:566

Scope: file

Source code excerpt:

	TEXT("The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers)."));

static bool bRequireFocusForGamepadInput = false;
FAutoConsoleVariableRef CVarRequireFocusForGamepadInput(
	TEXT("Slate.RequireFocusForGamepadInput"),
	bRequireFocusForGamepadInput,
	TEXT("Whether gamepad input should be ignored by the engine if the application is not currently active")
);

static bool TransformFullscreenMouseInput = true;
FAutoConsoleVariableRef CVarSlateTransformFullscreenMouseInput(
	TEXT("Slate.Transform.FullscreenMouseInput"),

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:1412

Scope (from outer to inner):

file
function     void FSlateApplication::PollGameDeviceState

Source code excerpt:

void FSlateApplication::PollGameDeviceState()
{
	if( ActiveModalWindows.Num() == 0 && !GIntraFrameDebuggingGameThread && (!bRequireFocusForGamepadInput || IsActive()))
	{
		// Don't poll when a modal window open or intra frame debugging is happening
		PlatformApplication->PollGameDeviceState( GetDeltaTime() );
	}
}