2021-04-08 14:32:07 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "CommonInputSettings.h"
|
2023-02-11 12:26:44 -05:00
|
|
|
|
2023-02-07 13:44:21 -05:00
|
|
|
#include "ICommonInputModule.h"
|
2022-12-19 13:28:22 -05:00
|
|
|
#include "Engine/DataTable.h"
|
|
|
|
|
#include "Engine/PlatformSettingsManager.h"
|
2021-04-08 14:32:07 -04:00
|
|
|
|
2022-09-28 01:06:15 -04:00
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(CommonInputSettings)
|
|
|
|
|
|
2022-12-19 13:28:22 -05:00
|
|
|
#if !WITH_EDITOR
|
|
|
|
|
#include "CommonInputPrivate.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-04-08 14:32:07 -04:00
|
|
|
UCommonInputSettings::UCommonInputSettings(const FObjectInitializer& Initializer)
|
|
|
|
|
: Super(Initializer)
|
|
|
|
|
, bInputDataLoaded(false)
|
|
|
|
|
{
|
2022-02-24 14:23:31 -05:00
|
|
|
PlatformInput.Initialize(UCommonInputPlatformSettings::StaticClass());
|
2021-04-08 14:32:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UCommonInputSettings::LoadData()
|
|
|
|
|
{
|
|
|
|
|
LoadInputData();
|
2022-01-31 23:46:45 -05:00
|
|
|
LoadActionDomainTable();
|
2021-04-08 14:32:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
void UCommonInputSettings::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
|
|
|
|
{
|
|
|
|
|
bInputDataLoaded = false;
|
2023-07-17 18:23:02 -04:00
|
|
|
bActionDomainTableLoaded = false;
|
2021-04-08 14:32:07 -04:00
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void UCommonInputSettings::LoadInputData()
|
|
|
|
|
{
|
|
|
|
|
if (!bInputDataLoaded)
|
|
|
|
|
{
|
|
|
|
|
// If we were created early enough to be disregarded by the GC (which we should be), then we need to
|
|
|
|
|
// add all of our members to the root set, since our hard reference to them is totally meaningless to the GC.
|
|
|
|
|
const bool bIsDisregardForGC = GUObjectArray.IsDisregardForGC(this);
|
|
|
|
|
|
|
|
|
|
InputDataClass = InputData.LoadSynchronous();
|
|
|
|
|
if (InputDataClass)
|
|
|
|
|
{
|
|
|
|
|
if (bIsDisregardForGC)
|
|
|
|
|
{
|
|
|
|
|
InputDataClass->AddToRoot();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
//CurrentPlatform = CommonInputPlatformData[FCommonInputBase::GetCurrentPlatformName()];
|
|
|
|
|
//for (TSoftClassPtr<UCommonInputBaseControllerData> ControllerData : CurrentPlatform.GetControllerData())
|
|
|
|
|
//{
|
|
|
|
|
// if (TSubclassOf<UCommonInputBaseControllerData> ControllerDataClass = ControllerData.LoadSynchronous())
|
|
|
|
|
// {
|
|
|
|
|
// CurrentPlatform.ControllerDataClasses.Add(ControllerDataClass);
|
|
|
|
|
// if (bIsDisregardForGC)
|
|
|
|
|
// {
|
|
|
|
|
// ControllerDataClass->AddToRoot();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2021-04-08 14:32:07 -04:00
|
|
|
bInputDataLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-31 23:46:45 -05:00
|
|
|
void UCommonInputSettings::LoadActionDomainTable()
|
|
|
|
|
{
|
|
|
|
|
if (!bActionDomainTableLoaded)
|
|
|
|
|
{
|
|
|
|
|
// If we were created early enough to be disregarded by the GC (which we should be), then we need to
|
|
|
|
|
// add all of our members to the root set, since our hard reference to them is totally meaningless to the GC.
|
|
|
|
|
const bool bIsDisregardForGC = GUObjectArray.IsDisregardForGC(this);
|
|
|
|
|
|
|
|
|
|
ActionDomainTablePtr = ActionDomainTable.LoadSynchronous();
|
|
|
|
|
if (ActionDomainTablePtr)
|
|
|
|
|
{
|
|
|
|
|
if (bIsDisregardForGC)
|
|
|
|
|
{
|
|
|
|
|
ActionDomainTablePtr->AddToRoot();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bActionDomainTableLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 14:32:07 -04:00
|
|
|
void UCommonInputSettings::ValidateData()
|
|
|
|
|
{
|
|
|
|
|
bInputDataLoaded &= !InputData.IsPending();
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
// for (TSoftClassPtr<UCommonInputBaseControllerData> ControllerData : CurrentPlatform.GetControllerData())
|
|
|
|
|
// {
|
|
|
|
|
//bInputDataLoaded &= CurrentPlatform.ControllerDataClasses.ContainsByPredicate([&ControllerData](const TSubclassOf<UCommonInputBaseControllerData>& ControllerDataClass)
|
|
|
|
|
// {
|
|
|
|
|
// return ControllerDataClass.Get() == ControllerData.Get();
|
|
|
|
|
// });
|
2021-04-08 14:32:07 -04:00
|
|
|
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
// bInputDataLoaded &= !ControllerData.IsPending();
|
|
|
|
|
// }
|
2021-04-08 14:32:07 -04:00
|
|
|
|
|
|
|
|
#if !WITH_EDITOR
|
|
|
|
|
UE_CLOG(!bInputDataLoaded, LogCommonInput, Warning, TEXT("Trying to access unloaded CommmonInputSettings data. This may force a sync load."));
|
|
|
|
|
#endif // !WITH_EDITOR
|
|
|
|
|
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDataTableRowHandle UCommonInputSettings::GetDefaultClickAction() const
|
|
|
|
|
{
|
|
|
|
|
ensure(bInputDataLoaded);
|
|
|
|
|
|
|
|
|
|
if (InputDataClass)
|
|
|
|
|
{
|
|
|
|
|
if (const UCommonUIInputData* InputDataPtr = InputDataClass.GetDefaultObject())
|
|
|
|
|
{
|
|
|
|
|
return InputDataPtr->DefaultClickAction;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FDataTableRowHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDataTableRowHandle UCommonInputSettings::GetDefaultBackAction() const
|
|
|
|
|
{
|
2023-04-17 16:08:51 -04:00
|
|
|
ensure(bInputDataLoaded);
|
|
|
|
|
|
2021-04-08 14:32:07 -04:00
|
|
|
if (InputDataClass)
|
|
|
|
|
{
|
|
|
|
|
if (const UCommonUIInputData* InputDataPtr = InputDataClass.GetDefaultObject())
|
|
|
|
|
{
|
|
|
|
|
return InputDataPtr->DefaultBackAction;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FDataTableRowHandle();
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-04 19:16:53 -04:00
|
|
|
TSubclassOf<UCommonUIHoldData> UCommonInputSettings::GetDefaultHoldData() const
|
|
|
|
|
{
|
2023-04-17 15:18:59 -04:00
|
|
|
if (InputDataClass)
|
|
|
|
|
{
|
|
|
|
|
if (const UCommonUIInputData* InputDataPtr = InputDataClass.GetDefaultObject())
|
2023-04-04 19:16:53 -04:00
|
|
|
{
|
2023-04-17 15:18:59 -04:00
|
|
|
TSubclassOf<UCommonUIHoldData> DefaultHoldDataLoaded = InputDataPtr->DefaultHoldData.LoadSynchronous();
|
|
|
|
|
return DefaultHoldDataLoaded;
|
2023-04-04 19:16:53 -04:00
|
|
|
}
|
2023-04-17 15:18:59 -04:00
|
|
|
}
|
|
|
|
|
return nullptr;
|
2023-04-04 19:16:53 -04:00
|
|
|
}
|
|
|
|
|
|
2023-02-11 12:26:44 -05:00
|
|
|
UInputAction* UCommonInputSettings::GetEnhancedInputClickAction() const
|
|
|
|
|
{
|
|
|
|
|
ensureMsgf(bInputDataLoaded, TEXT("Warning, CommonUI input data not loaded."));
|
|
|
|
|
|
|
|
|
|
if (InputDataClass && IsEnhancedInputSupportEnabled())
|
|
|
|
|
{
|
|
|
|
|
return InputDataClass.GetDefaultObject()->EnhancedInputClickAction;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UInputAction* UCommonInputSettings::GetEnhancedInputBackAction() const
|
|
|
|
|
{
|
|
|
|
|
ensureMsgf(bInputDataLoaded, TEXT("Warning, CommonUI input data not loaded."));
|
|
|
|
|
|
|
|
|
|
if (InputDataClass && IsEnhancedInputSupportEnabled())
|
|
|
|
|
{
|
|
|
|
|
return InputDataClass.GetDefaultObject()->EnhancedInputBackAction;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 13:44:21 -05:00
|
|
|
bool UCommonInputSettings::IsEnhancedInputSupportEnabled()
|
|
|
|
|
{
|
|
|
|
|
static bool bEnabled = ICommonInputModule::Get().GetSettings().GetEnableEnhancedInputSupport();
|
|
|
|
|
return bEnabled;
|
|
|
|
|
};
|
|
|
|
|
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
void UCommonInputSettings::PostInitProperties()
|
2021-04-08 14:32:07 -04:00
|
|
|
{
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
Super::PostInitProperties();
|
2021-04-08 14:32:07 -04:00
|
|
|
|
2021-06-09 12:11:38 -04:00
|
|
|
#if WITH_EDITOR
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
if (CommonInputPlatformData_DEPRECATED.Num())
|
|
|
|
|
{
|
|
|
|
|
for (const auto& PlatformData : CommonInputPlatformData_DEPRECATED)
|
|
|
|
|
{
|
|
|
|
|
const FCommonInputPlatformBaseData& OriginalData = PlatformData.Value;
|
|
|
|
|
|
2022-02-24 14:23:31 -05:00
|
|
|
if (UCommonInputPlatformSettings* Settings = UPlatformSettingsManager::Get().GetSettingsForPlatform<UCommonInputPlatformSettings>(PlatformData.Key))
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
{
|
|
|
|
|
Settings->bSupportsMouseAndKeyboard = OriginalData.bSupportsMouseAndKeyboard;
|
|
|
|
|
Settings->bSupportsGamepad = OriginalData.bSupportsGamepad;
|
|
|
|
|
Settings->bSupportsTouch = OriginalData.bSupportsTouch;
|
|
|
|
|
Settings->bCanChangeGamepadType = OriginalData.bCanChangeGamepadType;
|
|
|
|
|
Settings->DefaultGamepadName = OriginalData.DefaultGamepadName;
|
|
|
|
|
Settings->DefaultInputType = OriginalData.DefaultInputType;
|
|
|
|
|
Settings->ControllerData = OriginalData.ControllerData;
|
2021-06-09 15:32:32 -04:00
|
|
|
|
2021-10-27 15:14:40 -04:00
|
|
|
Settings->TryUpdateDefaultConfigFile();
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
}
|
|
|
|
|
else if (PlatformData.Key == FCommonInputDefaults::PlatformPC)
|
|
|
|
|
{
|
|
|
|
|
TArray<UCommonInputPlatformSettings*> PCPlatforms;
|
2022-02-24 14:23:31 -05:00
|
|
|
PCPlatforms.Add(UPlatformSettingsManager::Get().GetSettingsForPlatform<UCommonInputPlatformSettings>("Windows"));
|
|
|
|
|
PCPlatforms.Add(UPlatformSettingsManager::Get().GetSettingsForPlatform<UCommonInputPlatformSettings>("WinGDK"));
|
|
|
|
|
PCPlatforms.Add(UPlatformSettingsManager::Get().GetSettingsForPlatform<UCommonInputPlatformSettings>("Linux"));
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
|
|
|
|
|
for (UCommonInputPlatformSettings* PCPlatform : PCPlatforms)
|
|
|
|
|
{
|
2021-06-09 15:32:32 -04:00
|
|
|
if (PCPlatform)
|
|
|
|
|
{
|
|
|
|
|
PCPlatform->bSupportsMouseAndKeyboard = OriginalData.bSupportsMouseAndKeyboard;
|
|
|
|
|
PCPlatform->bSupportsGamepad = OriginalData.bSupportsGamepad;
|
|
|
|
|
PCPlatform->bSupportsTouch = OriginalData.bSupportsTouch;
|
|
|
|
|
PCPlatform->bCanChangeGamepadType = OriginalData.bCanChangeGamepadType;
|
|
|
|
|
PCPlatform->DefaultGamepadName = OriginalData.DefaultGamepadName;
|
|
|
|
|
PCPlatform->DefaultInputType = OriginalData.DefaultInputType;
|
|
|
|
|
PCPlatform->ControllerData = OriginalData.ControllerData;
|
|
|
|
|
|
2021-10-27 15:14:40 -04:00
|
|
|
PCPlatform->TryUpdateDefaultConfigFile();
|
2021-06-09 15:32:32 -04:00
|
|
|
}
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommonInputPlatformData_DEPRECATED.Reset();
|
2021-10-27 15:14:40 -04:00
|
|
|
TryUpdateDefaultConfigFile();
|
CommonInput - Using the new UPlatformSettings, to store per-platform information into an NDA location when each platform is configured. These changes make it so we use the 'real' platform ini name, e.g. There's no more "PC" platform as far as the common input exists for configuring the platforms. So if you setup linux, that's another platform you'd configure. The gamepads are still wonky, they're trying to use platform ini names for gamepad names, going to refactor that so it's not coming from platform names. Made an upgrade path for the old settings that will update and then clear the old configuration. Also removed some settings that were added to DataDrivenPlatformInfo that don't make sense, and updated some platforms that never got the settings to begin with.
#review-16605256 Josh.Adams, Michael.Noland, Daren.Cheng
#fyi Josh.Adams, Michael.Noland, Daren.Cheng
[CL 16605253 by Nick Darnell in ue5-main branch]
2021-06-09 10:44:46 -04:00
|
|
|
}
|
2021-06-09 12:11:38 -04:00
|
|
|
#endif
|
2021-04-08 14:32:07 -04:00
|
|
|
}
|
2022-09-28 01:06:15 -04:00
|
|
|
|