39 lines
876 B
C++
39 lines
876 B
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "LyraBoundActionButton.h"
|
|
#include "CommonInputSubsystem.h"
|
|
|
|
void ULyraBoundActionButton::NativeConstruct()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
if (UCommonInputSubsystem* InputSubsystem = GetInputSubsystem())
|
|
{
|
|
InputSubsystem->OnInputMethodChangedNative.AddUObject(this, &ThisClass::HandleInputMethodChanged);
|
|
HandleInputMethodChanged(InputSubsystem->GetCurrentInputType());
|
|
}
|
|
}
|
|
|
|
void ULyraBoundActionButton::HandleInputMethodChanged(ECommonInputType NewInputMethod)
|
|
{
|
|
TSubclassOf<UCommonButtonStyle> NewStyle = nullptr;
|
|
|
|
if (NewInputMethod == ECommonInputType::Gamepad)
|
|
{
|
|
NewStyle = GamepadStyle;
|
|
}
|
|
else if (NewInputMethod == ECommonInputType::Touch)
|
|
{
|
|
NewStyle = TouchStyle;
|
|
}
|
|
else
|
|
{
|
|
NewStyle = KeyboardStyle;
|
|
}
|
|
|
|
if (NewStyle)
|
|
{
|
|
SetStyle(NewStyle);
|
|
}
|
|
}
|