input.bRemapDeviceIdForOffsetPlayerGamepadIds

input.bRemapDeviceIdForOffsetPlayerGamepadIds

#Overview

name: input.bRemapDeviceIdForOffsetPlayerGamepadIds

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 input.bRemapDeviceIdForOffsetPlayerGamepadIds is to control the remapping of input device IDs for offset player gamepad IDs in split-screen scenarios. This setting is primarily used in the input handling system of Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the input system, specifically within the GameViewportClient module. This can be seen from the file location where the variable is defined and used: Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp.

The value of this variable is set as a console variable (CVar) using TAutoConsoleVariable. It is initialized with a default value of true.

The associated variable that interacts with it is CVarRemapDeviceIdForOffsetPlayerGamepadIds. This is the actual console variable object that holds the value of the setting.

Developers must be aware of the following when using this variable:

  1. It is specifically designed for split-screen scenarios.
  2. It affects the behavior of input device ID assignment for local players.
  3. It is intended as a temporary fix and will be removed in a future release.

Best practices when using this variable include:

  1. Only modify it if you’re experiencing issues with input in split-screen gameplay.
  2. Be prepared for its removal in future engine versions and plan for alternative solutions.
  3. Test thoroughly in split-screen scenarios when changing its value.

Regarding the associated variable CVarRemapDeviceIdForOffsetPlayerGamepadIds:

The purpose of CVarRemapDeviceIdForOffsetPlayerGamepadIds is to provide a runtime-accessible way to control the input.bRemapDeviceIdForOffsetPlayerGamepadIds setting.

This console variable is used within the UGameViewportClient::RemapControllerInput function to determine whether to remap the controller input for offset player gamepad IDs.

The value of this variable is set when it’s declared, with a default value of true. It can be changed at runtime through console commands.

Developers should be aware that:

  1. This variable directly controls the behavior defined by input.bRemapDeviceIdForOffsetPlayerGamepadIds.
  2. It’s accessed using GetValueOnAnyThread(), which suggests it can be safely read from any thread.
  3. Changing this value at runtime will immediately affect the input remapping behavior for split-screen scenarios.

Best practices for using CVarRemapDeviceIdForOffsetPlayerGamepadIds include:

  1. Use it for debugging or testing split-screen input issues.
  2. Be cautious when changing its value in a shipping game, as it may affect player experience.
  3. Consider exposing it as a configurable option if your game heavily relies on split-screen functionality and might benefit from runtime adjustment.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarRemapDeviceIdForOffsetPlayerGamepadIds(
	TEXT("input.bRemapDeviceIdForOffsetPlayerGamepadIds"),
	true,
	TEXT("If true, then when bOffsetPlayerGamepadIds is true we will create a new Input Device Id\n")
	TEXT("as needed for the next local player. This fixes the behavior in split screen.\n")
	TEXT("Note: This CVar will be removed in a future release, this is a temporary wrapper for bug fix behavior."),
	ECVF_Default);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:



static TAutoConsoleVariable<bool> CVarRemapDeviceIdForOffsetPlayerGamepadIds(
	TEXT("input.bRemapDeviceIdForOffsetPlayerGamepadIds"),
	true,
	TEXT("If true, then when bOffsetPlayerGamepadIds is true we will create a new Input Device Id\n")
	TEXT("as needed for the next local player. This fixes the behavior in split screen.\n")
	TEXT("Note: This CVar will be removed in a future release, this is a temporary wrapper for bug fix behavior."),
	ECVF_Default);

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

Scope (from outer to inner):

file
function     void UGameViewportClient::RemapControllerInput

Source code excerpt:

	{
		// Temp cvar in case this change somehow breaks input for any split screen games.
		if (CVarRemapDeviceIdForOffsetPlayerGamepadIds.GetValueOnAnyThread())
		{
			const TArray<ULocalPlayer*>& CurrentLocalPlayers = World->GetGameInstance()->GetLocalPlayers();
			if (CurrentLocalPlayers.IsValidIndex(InOutEventArgs.ControllerId) && CurrentLocalPlayers.IsValidIndex(InOutEventArgs.ControllerId + 1))
			{
				const FPlatformUserId DesiredPlatformUser = CurrentLocalPlayers[InOutEventArgs.ControllerId + 1]->GetPlatformUserId();