Initial work on prompt widget

This commit is contained in:
2026-05-04 02:14:14 -04:00
parent ae0defbad9
commit 97b5a3c593
10 changed files with 324 additions and 84 deletions

View File

@@ -1,5 +1,7 @@
#include "PlayerControllerBase.h"
#include "Common.h"
#include "GameFramework/InputDeviceSubsystem.h"
#include "GameFramework/InputSettings.h"
#include "RootCanvas.h"
#include "Tangible.h"
#include "TangibleManager.h"
@@ -246,6 +248,25 @@ void AlxPlayerControllerBase::BuildInputStack(TArray<UInputComponent*>& InputSta
}
}
static ElxInputMode DetectInputMode(const ULocalPlayer *LocalPlayer)
{
UInputDeviceSubsystem *IDS = GEngine->GetEngineSubsystem<UInputDeviceSubsystem>();
if (!IDS) return ElxInputMode::KeyboardMouse;
FHardwareDeviceIdentifier Device = IDS->GetMostRecentlyUsedHardwareDevice(LocalPlayer->GetPlatformUserId());
if (Device.PrimaryDeviceType != EHardwareDevicePrimaryType::Gamepad)
{
return ElxInputMode::KeyboardMouse;
}
FString DeviceName = Device.HardwareDeviceIdentifier.ToString();
if (DeviceName.Contains(TEXT("PS4")) || DeviceName.Contains(TEXT("PS5")) || DeviceName.Contains(TEXT("PlayStation")))
{
return ElxInputMode::PlayStationGamepad;
}
return ElxInputMode::XboxGamepad;
}
void AlxPlayerControllerBase::UpdateInputMode()
{
// Get all the various objects we need to be able to manipulate
@@ -302,6 +323,13 @@ void AlxPlayerControllerBase::UpdateInputMode()
GameViewportClient->SetIgnoreInput(false);
ElxInputMode NewInputMode = DetectInputMode(LocalPlayer);
if (NewInputMode != CurrentInputMode)
{
CurrentInputMode = NewInputMode;
OnInputModeChanged.Broadcast(CurrentInputMode);
}
// We always put keyboard focus on whatever user widget is in
// front. If the front widget doesn't want keyboard focus,
// then we put keyboard focus on the viewport.
@@ -318,6 +346,11 @@ void AlxPlayerControllerBase::UpdateInputMode()
}
}
ElxInputMode AlxPlayerControllerBase::GetInputMode(const UObject *Context)
{
return FromContext(Context)->CurrentInputMode;
}
void AlxPlayerControllerBase::UpdateLookAt()
{
UlxTangibleManager *TM = GetGameInstance()->GetSubsystem<UlxTangibleManager>();