From c7f73d16e03477d53bc7d8bb0a2c972df28be87c Mon Sep 17 00:00:00 2001 From: acdemiralp <demiralpali@gmail.com> Date: Thu, 22 Nov 2018 17:31:16 +0100 Subject: [PATCH] DisplayClusterPawnCAVE OnFire and OnAction events now listen to and provide whether the button was pressed/released. --- .../Private/DisplayClusterPawnCAVE.cpp | 34 ++++++++++++------- .../Public/DisplayClusterPawnCAVE.h | 15 ++++---- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp index 5855da42..45ae5d75 100644 --- a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp +++ b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp @@ -71,11 +71,11 @@ void ADisplayClusterPawnCAVE::OnLookUpRate_Implementation(flo AddControllerPitchInput(BaseTurnRate * Rate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation); } } -void ADisplayClusterPawnCAVE::OnFire_Implementation () +void ADisplayClusterPawnCAVE::OnFire_Implementation (bool Pressed) { } -void ADisplayClusterPawnCAVE::OnAction_Implementation (int32 Index) +void ADisplayClusterPawnCAVE::OnAction_Implementation (bool Pressed, int32 Index) { } @@ -110,7 +110,7 @@ void ADisplayClusterPawnCAVE::Tick (flo const float Mult = GetWorld()->GetWorldSettings()->WorldToMeters / 100.f; SetActorScale3D(FVector(Mult, Mult, Mult)); - if (!Flystick) + if (!Flystick && IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster) Flystick = IDisplayCluster::Get().GetGameMgr()->GetNodeById(TEXT("flystick")); // There MUST be an scene node called flystick in the config. } void ADisplayClusterPawnCAVE::BeginDestroy () @@ -124,16 +124,24 @@ void ADisplayClusterPawnCAVE::SetupPlayerInputComponent (UIn Super::SetupPlayerInputComponent(PlayerInputComponent); if (PlayerInputComponent) { - PlayerInputComponent->BindAxis ("MoveForward" , this, &ADisplayClusterPawnCAVE::OnForward ); - PlayerInputComponent->BindAxis ("MoveRight" , this, &ADisplayClusterPawnCAVE::OnRight ); - PlayerInputComponent->BindAxis ("TurnRate" , this, &ADisplayClusterPawnCAVE::OnTurnRate ); - PlayerInputComponent->BindAxis ("LookUpRate" , this, &ADisplayClusterPawnCAVE::OnLookUpRate); - PlayerInputComponent->BindAction ("Fire" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnFire ); - PlayerInputComponent->BindAction<FButtonDelegate>("Action1" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , 1); - PlayerInputComponent->BindAction<FButtonDelegate>("Action2" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , 2); - PlayerInputComponent->BindAction<FButtonDelegate>("Action3" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , 3); - PlayerInputComponent->BindAction<FButtonDelegate>("Action4" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , 4); - PlayerInputComponent->BindAction<FButtonDelegate>("Action5" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , 5); + PlayerInputComponent->BindAxis ("MoveForward" , this, &ADisplayClusterPawnCAVE::OnForward ); + PlayerInputComponent->BindAxis ("MoveRight" , this, &ADisplayClusterPawnCAVE::OnRight ); + PlayerInputComponent->BindAxis ("TurnRate" , this, &ADisplayClusterPawnCAVE::OnTurnRate ); + PlayerInputComponent->BindAxis ("LookUpRate" , this, &ADisplayClusterPawnCAVE::OnLookUpRate ); + + PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnFire , true ); + PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 1); + PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 2); + PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 3); + PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 4); + PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 5); + + PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Released, this, &ADisplayClusterPawnCAVE::OnFire , false ); + PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 1); + PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 2); + PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 3); + PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 4); + PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 5); } } UPawnMovementComponent* ADisplayClusterPawnCAVE::GetMovementComponent () const diff --git a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h index 09ec2f3f..e2e9b9e6 100644 --- a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h +++ b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h @@ -15,18 +15,19 @@ class DISPLAYCLUSTEREXTENSIONS_API ADisplayClusterPawnCAVE : public ADisplayClus GENERATED_UCLASS_BODY() public: - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnForward (float Value); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnRight (float Value); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnTurnRate (float Rate ); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnLookUpRate(float Rate ); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnFire (); - UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnAction (int32 Index); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnForward (float Value ); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnRight (float Value ); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnTurnRate (float Rate ); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnLookUpRate(float Rate ); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnFire (bool Pressed); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn") void OnAction (bool Pressed, int32 Index); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn") float BaseTurnRate = 45.0f ; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn") UDisplayClusterSceneComponent* Flystick = nullptr; protected: - DECLARE_DELEGATE_OneParam(FButtonDelegate, int32); + DECLARE_DELEGATE_OneParam (FFireDelegate , bool); + DECLARE_DELEGATE_TwoParams(FActionDelegate, bool, int32); virtual void BeginPlay () override; virtual void Tick (float DeltaSeconds ) override; -- GitLab