init
This commit is contained in:
70
Source/AudioVideoRecord/AudioVideoRecordPlayerController.cpp
Normal file
70
Source/AudioVideoRecord/AudioVideoRecordPlayerController.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
|
||||
#include "AudioVideoRecordPlayerController.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "InputMappingContext.h"
|
||||
#include "AudioVideoRecordCameraManager.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "AudioVideoRecord.h"
|
||||
#include "Widgets/Input/SVirtualJoystick.h"
|
||||
|
||||
AAudioVideoRecordPlayerController::AAudioVideoRecordPlayerController()
|
||||
{
|
||||
// set the player camera manager class
|
||||
PlayerCameraManagerClass = AAudioVideoRecordCameraManager::StaticClass();
|
||||
}
|
||||
|
||||
void AAudioVideoRecordPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
|
||||
// only spawn touch controls on local player controllers
|
||||
if (SVirtualJoystick::ShouldDisplayTouchInterface() && IsLocalPlayerController())
|
||||
{
|
||||
// spawn the mobile controls widget
|
||||
MobileControlsWidget = CreateWidget<UUserWidget>(this, MobileControlsWidgetClass);
|
||||
|
||||
if (MobileControlsWidget)
|
||||
{
|
||||
// add the controls to the player screen
|
||||
MobileControlsWidget->AddToPlayerScreen(0);
|
||||
|
||||
} else {
|
||||
|
||||
UE_LOG(LogAudioVideoRecord, Error, TEXT("Could not spawn mobile controls widget."));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AAudioVideoRecordPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
// only add IMCs for local player controllers
|
||||
if (IsLocalPlayerController())
|
||||
{
|
||||
// Add Input Mapping Context
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
|
||||
{
|
||||
for (UInputMappingContext* CurrentContext : DefaultMappingContexts)
|
||||
{
|
||||
Subsystem->AddMappingContext(CurrentContext, 0);
|
||||
}
|
||||
|
||||
// only add these IMCs if we're not using mobile touch input
|
||||
if (!SVirtualJoystick::ShouldDisplayTouchInterface())
|
||||
{
|
||||
for (UInputMappingContext* CurrentContext : MobileExcludedMappingContexts)
|
||||
{
|
||||
Subsystem->AddMappingContext(CurrentContext, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user