Skip to content
Snippets Groups Projects

N display input removal

Closed Jan Delember requested to merge nDisplayInput_removal into develop
4 files
+ 63
94
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -13,58 +13,60 @@
AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events.
AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events.
Movement = CreateDefaultSubobject<UFloatingPawnMovement> (TEXT("Movement"));
Movement->UpdatedComponent = RootComponent;
RotatingMovement = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovement"));
RotatingMovement->UpdatedComponent = RootComponent;
Movement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("Movement"));
Movement->UpdatedComponent = RootComponent;
RotatingMovement = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovement"));
RotatingMovement->UpdatedComponent = RootComponent;
RotatingMovement->bRotationInLocalSpace = false;
RotatingMovement->PivotTranslation = FVector::ZeroVector;
RotatingMovement->RotationRate = FRotator::ZeroRotator;
LeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftMotionController"));
LeftMotionController->SetupAttachment (RootComponent);
LeftMotionController->SetTrackingSource (EControllerHand::Left);
LeftMotionController->SetShowDeviceModel (true );
LeftMotionController->SetVisibility (false);
RotatingMovement->PivotTranslation = FVector::ZeroVector;
RotatingMovement->RotationRate = FRotator::ZeroRotator;
RightMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightMotionController"));
RightMotionController->SetupAttachment (RootComponent);
RightMotionController->SetTrackingSource (EControllerHand::Right);
RightMotionController->SetShowDeviceModel(true );
RightMotionController->SetVisibility (false);
LeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftMotionController"));
LeftMotionController->SetupAttachment(RootComponent);
LeftMotionController->SetTrackingSource(EControllerHand::Left);
LeftMotionController->SetShowDeviceModel(true);
LeftMotionController->SetVisibility(false);
RightMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightMotionController"));
RightMotionController->SetupAttachment(RootComponent);
RightMotionController->SetTrackingSource(EControllerHand::Right);
RightMotionController->SetShowDeviceModel(true);
RightMotionController->SetVisibility(false);
}
void AVirtualRealityPawn::OnForward_Implementation (float Value)
void AVirtualRealityPawn::OnForward (float Value)
{
if (NavigationMode == EVRNavigationModes::NAV_MODE_FLY || IDisplayCluster::Get().GetClusterMgr()->IsStandalone())
{
AddMovementInput(Forward->GetForwardVector(), Value);
if(Forward != nullptr)
AddMovementInput(Forward->GetForwardVector(), Value);
}
}
void AVirtualRealityPawn::OnRight_Implementation(float Value)
void AVirtualRealityPawn::OnRight(float Value)
{
if (NavigationMode == EVRNavigationModes::NAV_MODE_FLY || IDisplayCluster::Get().GetClusterMgr()->IsStandalone())
{
AddMovementInput(Forward->GetRightVector(), Value);
if (Forward != nullptr)
AddMovementInput(Forward->GetRightVector(), Value);
}
}
void AVirtualRealityPawn::OnTurnRate_Implementation (float Rate )
void AVirtualRealityPawn::OnTurnRate (float Rate )
{
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
const FVector CameraLocation = IDisplayCluster::Get().GetGameMgr()->GetActiveCamera()->GetComponentLocation();
const FVector CameraLocation = IDisplayCluster::Get().GetGameMgr()->GetActiveCamera()->GetComponentLocation();
RotatingMovement->PivotTranslation = RotatingMovement->UpdatedComponent->GetComponentTransform().InverseTransformPositionNoScale(CameraLocation);
RotatingMovement->RotationRate = FRotator(RotatingMovement->RotationRate.Pitch, Rate * BaseTurnRate, 0.0f);
RotatingMovement->RotationRate = FRotator(RotatingMovement->RotationRate.Pitch, Rate * BaseTurnRate, 0.0f);
}
else
{
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation);
}
}
void AVirtualRealityPawn::OnLookUpRate_Implementation(float Rate )
void AVirtualRealityPawn::OnLookUpRate(float Rate )
{
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
@@ -75,79 +77,69 @@ void AVirtualRealityPawn::OnLookUpRate_Implementation(float R
AddControllerPitchInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation);
}
}
void AVirtualRealityPawn::OnFire_Implementation (bool Pressed)
{
}
void AVirtualRealityPawn::OnAction_Implementation (bool Pressed, int32 Index)
{
}
void AVirtualRealityPawn::BeginPlay ()
{
Super::BeginPlay();
bUseControllerRotationYaw = true;
bUseControllerRotationYaw = true;
bUseControllerRotationPitch = true;
bUseControllerRotationRoll = true;
bUseControllerRotationRoll = true;
// Display cluster settings apply to all setups (PC, HMD, CAVE/ROLV) despite the unfortunate name due to being an UE4 internal.
TArray<AActor*> SettingsActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ADisplayClusterSettings::StaticClass(), SettingsActors);
if (SettingsActors.Num() > 0)
{
{
ADisplayClusterSettings* Settings = Cast<ADisplayClusterSettings>(SettingsActors[0]);
Movement->MaxSpeed = Settings->MovementMaxSpeed ;
Movement->MaxSpeed = Settings->MovementMaxSpeed;
Movement->Acceleration = Settings->MovementAcceleration;
Movement->Deceleration = Settings->MovementDeceleration;
Movement->TurningBoost = Settings->MovementTurningBoost;
BaseTurnRate = Settings->RotationSpeed ;
BaseTurnRate = Settings->RotationSpeed;
}
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster)
{
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("TurnRate" )), EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("TurnRate")), EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("LookUpRate")), EKeys::MouseY));
// Requires a scene node called flystick in the config.
Flystick = IDisplayCluster::Get().GetGameMgr()->GetNodeById(TEXT("flystick"));
Flystick = IDisplayCluster::Get().GetGameMgr()->GetNodeById(TEXT("flystick"));
Forward = Flystick;
LeftHand = Flystick;
Forward = Flystick;
LeftHand = Flystick;
RightHand = Flystick;
}
else if (UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayConnected())
{
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("TurnRate" )), EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("TurnRate")), EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping(FName(TEXT("LookUpRate")), EKeys::MouseY));
LeftMotionController ->SetVisibility(true);
LeftMotionController->SetVisibility(true);
RightMotionController->SetVisibility(true);
Forward = LeftMotionController ;
LeftHand = LeftMotionController ;
Forward = LeftMotionController;
LeftHand = LeftMotionController;
RightHand = RightMotionController;
}
else
{
Forward = RootComponent;
LeftHand = RootComponent;
Forward = RootComponent;
LeftHand = RootComponent;
RightHand = RootComponent;
}
}
void AVirtualRealityPawn::Tick (float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
// Flystick might not be available at start, hence is checked every frame.
Super::Tick(DeltaSeconds);
//Flystick might not be available at start, hence is checked every frame.
if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster && !Flystick)
{
{
// Requires a scene node called flystick in the config.
Flystick = IDisplayCluster::Get().GetGameMgr()->GetNodeById(TEXT("flystick"));
Forward = Flystick;
LeftHand = Flystick;
Flystick = IDisplayCluster::Get().GetGameMgr()->GetNodeById(TEXT("flystick"));
Forward = Flystick;
LeftHand = Flystick;
RightHand = Flystick;
}
}
@@ -158,28 +150,14 @@ void AVirtualRealityPawn::BeginDestroy ()
void AVirtualRealityPawn::SetupPlayerInputComponent (UInputComponent* PlayerInputComponent)
{
check(PlayerInputComponent);
check(PlayerInputComponent);
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (PlayerInputComponent)
{
PlayerInputComponent->BindAxis ("MoveForward" , this, &AVirtualRealityPawn::OnForward );
PlayerInputComponent->BindAxis ("MoveRight" , this, &AVirtualRealityPawn::OnRight );
PlayerInputComponent->BindAxis ("TurnRate" , this, &AVirtualRealityPawn::OnTurnRate );
PlayerInputComponent->BindAxis ("LookUpRate" , this, &AVirtualRealityPawn::OnLookUpRate );
PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Pressed , this, &AVirtualRealityPawn::OnFire , true );
PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 1);
PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 2);
PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 3);
PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 4);
PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 5);
PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Released, this, &AVirtualRealityPawn::OnFire , false );
PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 1);
PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 2);
PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 3);
PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 4);
PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 5);
PlayerInputComponent->BindAxis("MoveForward", this, &AVirtualRealityPawn::OnForward);
PlayerInputComponent->BindAxis("MoveRight", this, &AVirtualRealityPawn::OnRight);
PlayerInputComponent->BindAxis("TurnRate", this, &AVirtualRealityPawn::OnTurnRate);
PlayerInputComponent->BindAxis("LookUpRate", this, &AVirtualRealityPawn::OnLookUpRate);
}
}
UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent () const
Loading