ControllerData

ControllerData

#Overview

name: ControllerData

The value of this variable can be defined or overridden in .ini config files. 13 .ini config files referencing this setting variable.

It is referenced in 11 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ControllerData is to store and manage information about different types of controller inputs for various platforms in Unreal Engine 5. This variable is primarily used in the Common Input system, which is part of the CommonUI plugin.

ControllerData is used by the Common Input subsystem, which is part of the CommonUI plugin in Unreal Engine 5. This plugin provides a unified way to handle input across different platforms and input devices.

The value of this variable is typically set in the UCommonInputPlatformSettings class, which is a UPlatformSettings subclass. It can be configured through the engine’s configuration files or in the editor.

ControllerData interacts closely with ControllerDataClasses, which is a runtime-populated array of loaded controller data classes. It also interacts with other variables like DefaultGamepadName and DefaultInputType within the same context.

Developers must be aware that:

  1. ControllerData is an array of TSoftClassPtr, which means it uses soft references to controller data classes.
  2. The actual controller data classes are loaded asynchronously, so developers should ensure they’re loaded before use.
  3. This variable is used to define platform-specific controller data, so it may need to be configured differently for each supported platform.

Best practices when using this variable include:

  1. Ensure that all referenced controller data classes are valid and exist in the project.
  2. Use the GetControllerData() function to access the ControllerData array instead of accessing it directly.
  3. Be prepared to handle cases where controller data might not be loaded yet, especially in early game initialization.
  4. When adding new controller types or platforms, make sure to update the ControllerData array accordingly in the appropriate platform settings.
  5. Use the editor to configure ControllerData when possible, as it provides a more user-friendly interface and helps prevent errors.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/Android/AndroidGame.ini:12, section: [CommonInputPlatformSettings_Android CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Android/AndroidGame.ini:13, section: [CommonInputPlatformSettings_Android CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/IOS/IOSGame.ini:12, section: [CommonInputPlatformSettings_IOS CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/IOS/IOSGame.ini:13, section: [CommonInputPlatformSettings_IOS CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Linux/LinuxGame.ini:8, section: [CommonInputPlatformSettings_Linux CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Linux/LinuxGame.ini:9, section: [CommonInputPlatformSettings_Linux CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Linux/LinuxGame.ini:10, section: [CommonInputPlatformSettings_Linux CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Mac/MacGame.ini:8, section: [CommonInputPlatformSettings_Mac CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Mac/MacGame.ini:9, section: [CommonInputPlatformSettings_Mac CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Mac/MacGame.ini:10, section: [CommonInputPlatformSettings_Mac CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Windows/WindowsGame.ini:8, section: [CommonInputPlatformSettings_Windows CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Windows/WindowsGame.ini:9, section: [CommonInputPlatformSettings_Windows CommonInputPlatformSettings]

Location: <Workspace>/Projects/Lyra/Config/Windows/WindowsGame.ini:10, section: [CommonInputPlatformSettings_Windows CommonInputPlatformSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Private/CommonInputBaseTypes.cpp:232

Scope (from outer to inner):

file
function     void UCommonInputPlatformSettings::InitializeControllerData

Source code excerpt:

void UCommonInputPlatformSettings::InitializeControllerData() const
{
	if (ControllerData.Num() != ControllerDataClasses.Num())
	{
		for (TSoftClassPtr<UCommonInputBaseControllerData> ControllerDataPtr : ControllerData)
		{
			if (TSubclassOf<UCommonInputBaseControllerData> ControllerDataClass = ControllerDataPtr.LoadSynchronous())
			{
				ControllerDataClasses.Add(ControllerDataClass);
			}
		}

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Private/CommonInputSettings.cpp:52

Scope (from outer to inner):

file
function     void UCommonInputSettings::LoadInputData

Source code excerpt:

		
		//CurrentPlatform = CommonInputPlatformData[FCommonInputBase::GetCurrentPlatformName()];
		//for (TSoftClassPtr<UCommonInputBaseControllerData> ControllerData : CurrentPlatform.GetControllerData())
		//{
		//	if (TSubclassOf<UCommonInputBaseControllerData> ControllerDataClass = ControllerData.LoadSynchronous())
		//	{
		//		CurrentPlatform.ControllerDataClasses.Add(ControllerDataClass);
		//		if (bIsDisregardForGC)
		//		{
		//			ControllerDataClass->AddToRoot();
		//		}

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Private/CommonInputSettings.cpp:91

Scope (from outer to inner):

file
function     void UCommonInputSettings::ValidateData

Source code excerpt:

{
    bInputDataLoaded &= !InputData.IsPending();
  //  for (TSoftClassPtr<UCommonInputBaseControllerData> ControllerData : CurrentPlatform.GetControllerData())
  //  {
		//bInputDataLoaded &= CurrentPlatform.ControllerDataClasses.ContainsByPredicate([&ControllerData](const TSubclassOf<UCommonInputBaseControllerData>& ControllerDataClass)
		//	{
		//		return ControllerDataClass.Get() == ControllerData.Get();
		//	});

  //      bInputDataLoaded &= !ControllerData.IsPending();
  //  }
 
#if !WITH_EDITOR
    UE_CLOG(!bInputDataLoaded, LogCommonInput, Warning, TEXT("Trying to access unloaded CommmonInputSettings data. This may force a sync load."));
#endif // !WITH_EDITOR

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Private/CommonInputSettings.cpp:196

Scope (from outer to inner):

file
function     void UCommonInputSettings::PostInitProperties

Source code excerpt:

				Settings->DefaultGamepadName = OriginalData.DefaultGamepadName;
				Settings->DefaultInputType = OriginalData.DefaultInputType;
				Settings->ControllerData = OriginalData.ControllerData;

				Settings->TryUpdateDefaultConfigFile();
			}
			else if (PlatformData.Key == FCommonInputDefaults::PlatformPC)
			{
				TArray<UCommonInputPlatformSettings*> PCPlatforms;

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Private/CommonInputSettings.cpp:217

Scope (from outer to inner):

file
function     void UCommonInputSettings::PostInitProperties

Source code excerpt:

						PCPlatform->DefaultGamepadName = OriginalData.DefaultGamepadName;
						PCPlatform->DefaultInputType = OriginalData.DefaultInputType;
						PCPlatform->ControllerData = OriginalData.ControllerData;

						PCPlatform->TryUpdateDefaultConfigFile();
					}
				}
			}
		}

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Public/CommonInputBaseTypes.h:245

Scope (from outer to inner):

file
class        class UCommonInputPlatformSettings : public UPlatformSettings
function     TArray<TSoftClassPtr<UCommonInputBaseControllerData>> GetControllerData

Source code excerpt:

	TArray<TSoftClassPtr<UCommonInputBaseControllerData>> GetControllerData()
	{
		return ControllerData;
	}


#if WITH_EDITOR
	void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent);
#endif

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Public/CommonInputBaseTypes.h:276

Scope (from outer to inner):

file
class        class UCommonInputPlatformSettings : public UPlatformSettings

Source code excerpt:


	UPROPERTY(config, EditAnywhere, Category = "Default", Meta = (TitleProperty = "InputType"))
	TArray<TSoftClassPtr<UCommonInputBaseControllerData>> ControllerData;

	UPROPERTY(Transient)
	mutable TArray<TSubclassOf<UCommonInputBaseControllerData>> ControllerDataClasses;
};

/* DEPRECATED Legacy! */

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Public/CommonInputBaseTypes.h:346

Scope (from outer to inner):

file
function     TArray<TSoftClassPtr<UCommonInputBaseControllerData>> GetControllerData

Source code excerpt:

	TArray<TSoftClassPtr<UCommonInputBaseControllerData>> GetControllerData()
	{
		return ControllerData;
	}

	static const TArray<FName>& GetRegisteredPlatforms();

protected:
	UPROPERTY(EditDefaultsOnly, Category = "Properties")

#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonInput/Public/CommonInputBaseTypes.h:371

Scope: file

Source code excerpt:


	UPROPERTY(EditDefaultsOnly, Category = "Properties", Meta = (TitleProperty = "GamepadName"))
	TArray<TSoftClassPtr<UCommonInputBaseControllerData>> ControllerData;

	UPROPERTY(Transient)
	TArray<TSubclassOf<UCommonInputBaseControllerData>> ControllerDataClasses;
};

class FCommonInputBase

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Settings/LyraGameSettingRegistry_Gamepad.cpp:47

Scope (from outer to inner):

file
function     UGameSettingCollection* ULyraGameSettingRegistry::InitializeGamepadSettings

Source code excerpt:

					if (TSubclassOf<UCommonInputBaseControllerData> ControllerDataClass = ControllerDataPtr.LoadSynchronous())
					{
						const UCommonInputBaseControllerData* ControllerData = ControllerDataClass.GetDefaultObject();
						if (ControllerData->InputType == ECommonInputType::Gamepad)
						{
							Setting->AddDynamicOption(ControllerData->GamepadName.ToString(), ControllerData->GamepadDisplayName);
						}
					}
				}

				// Add the setting if we can select more than one game controller type on this platform
				// and we are allowed to change it

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/Settings/LyraSettingsLocal.h:459

Scope: file

Source code excerpt:

	 * The name of the controller the player is using.  This is maps to the name of a UCommonInputBaseControllerData
	 * that is available on this current platform.  The gamepad data are registered per platform, you'll find them
	 * in <Platform>Game.ini files listed under +ControllerData=...
	 */
	UPROPERTY(Config)
	FName ControllerPlatform;

	UPROPERTY(Config)
	FName ControllerPreset = TEXT("Default");

	/** The name of the current input config that the user has selected. */
	UPROPERTY(Config)
	FName InputConfigName = TEXT("Default");