|
|
|
|
| #include "LyraPlayerInput.h"
|
| #include "Performance/LatencyMarkerModule.h"
|
| #include "Settings/LyraSettingsLocal.h"
|
|
|
| ULyraPlayerInput::ULyraPlayerInput()
|
| : Super()
|
| {
|
|
|
|
|
| if (HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject))
|
| {
|
| return;
|
| }
|
|
|
| BindToLatencyMarkerSettingChange();
|
| }
|
|
|
| ULyraPlayerInput::~ULyraPlayerInput()
|
| {
|
| UnbindLatencyMarkerSettingChangeListener();
|
| }
|
|
|
| bool ULyraPlayerInput::InputKey(const FInputKeyEventArgs& Params)
|
| {
|
| const bool bResult = Super::InputKey(Params);
|
|
|
|
|
|
|
|
|
| ProcessInputEventForLatencyMarker(Params);
|
|
|
| return bResult;
|
| }
|
|
|
| void ULyraPlayerInput::ProcessInputEventForLatencyMarker(const FInputKeyEventArgs& Params)
|
| {
|
| if (!bShouldTriggerLatencyFlash)
|
| {
|
| return;
|
| }
|
|
|
|
|
| if (Params.Key == EKeys::LeftMouseButton)
|
| {
|
| TArray<ILatencyMarkerModule*> LatencyMarkerModules = IModularFeatures::Get().GetModularFeatureImplementations<ILatencyMarkerModule>(ILatencyMarkerModule::GetModularFeatureName());
|
|
|
| for (ILatencyMarkerModule* LatencyMarkerModule : LatencyMarkerModules)
|
| {
|
|
|
| LatencyMarkerModule->SetCustomLatencyMarker(7, GFrameCounter);
|
| }
|
| }
|
| }
|
|
|
| void ULyraPlayerInput::BindToLatencyMarkerSettingChange()
|
| {
|
| if (!ULyraSettingsLocal::DoesPlatformSupportLatencyMarkers())
|
| {
|
| return;
|
| }
|
|
|
| ULyraSettingsLocal* Settings = ULyraSettingsLocal::Get();
|
| if (!Settings)
|
| {
|
| return;
|
| }
|
|
|
| Settings->OnLatencyFlashInidicatorSettingsChangedEvent().AddUObject(this, &ThisClass::HandleLatencyMarkerSettingChanged);
|
|
|
|
|
| HandleLatencyMarkerSettingChanged();
|
| }
|
|
|
| void ULyraPlayerInput::UnbindLatencyMarkerSettingChangeListener()
|
| {
|
| ULyraSettingsLocal* Settings = ULyraSettingsLocal::Get();
|
| if (!Settings)
|
| {
|
| return;
|
| }
|
|
|
| Settings->OnLatencyFlashInidicatorSettingsChangedEvent().RemoveAll(this);
|
| }
|
|
|
| void ULyraPlayerInput::HandleLatencyMarkerSettingChanged()
|
| {
|
|
|
| ensure(ULyraSettingsLocal::DoesPlatformSupportLatencyMarkers());
|
|
|
| const ULyraSettingsLocal* Settings = ULyraSettingsLocal::Get();
|
| if (!Settings)
|
| {
|
| return;
|
| }
|
|
|
|
|
| bShouldTriggerLatencyFlash = Settings->GetEnableLatencyFlashIndicators();
|
|
|
| TArray<ILatencyMarkerModule*> LatencyMarkerModules = IModularFeatures::Get().GetModularFeatureImplementations<ILatencyMarkerModule>(ILatencyMarkerModule::GetModularFeatureName());
|
| for (ILatencyMarkerModule* LatencyMarkerModule : LatencyMarkerModules)
|
| {
|
| LatencyMarkerModule->SetFlashIndicatorEnabled(bShouldTriggerLatencyFlash);
|
| }
|
| } |