A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRLongHoldComponent.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "PixoVRLongHoldComponent.generated.h"
7
8DECLARE_DYNAMIC_DELEGATE(FOnLongHoldReleased);
9DECLARE_DYNAMIC_DELEGATE(FOnShortPressReleased);
10
14UENUM(BlueprintType)
15enum class EHoldingState : uint8
16{
17 NONE = 0 UMETA(DisplayName = "None"),
19 BUTTON_DOWN = 1 << 0 UMETA(DisplayName = "Button Is Down"),
21 BUTTON_HOLD = 1 << 1 UMETA(DisplayName = "Button Is Held"),
23 RELEASED = 1 << 2 UMETA(DisplayName = "Button Released"),
25};
26
31UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
32class PIXOCORE_API UPixoVRLongHoldComponent : public UActorComponent
33{
34 GENERATED_BODY()
35
36public:
38
39 virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
40
45 UFUNCTION(BlueprintCallable, Category = "PixoVR")
46 void ExecuteLongHold(const FOnLongHoldReleased& LongHoldFunction);
47
51 UFUNCTION(BlueprintCallable, Category = "PixoVR")
52 void StopLongHold();
53
58 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "PixoVR")
59 void IsShortPressValid(bool& IsShortPressValid);
60
65 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "PixoVR")
66 float GetCurrentTimePercentage() const;
67
72 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "PixoVR")
73 float GetCurrentTime() const;
74
79 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "PixoVR")
80 float GetNeededTime() const;
81
82protected:
83 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
84 float NeededTime;
85
86 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
87 float MaxShortPressTime;
88
89 UPROPERTY(BlueprintReadWrite, Category = "PixoVR")
90 EHoldingState ButtonState;
91
92private:
93 float CurrentTime;
94 FOnLongHoldReleased LongHoldReleasedEvent;
95};
DECLARE_DYNAMIC_DELEGATE(FOnLongHoldReleased)
EHoldingState
UENUM(BlueprintType)
@ BUTTON_DOWN
Button is pressed down.
@ RELEASED
Button is released.
@ BUTTON_HOLD
Button is being held.
@ NONE
No holding state.
Component for handling long hold functionality in PixoVR. Allows execution of a function when a butto...
EHoldingState ButtonState
UPROPERTY(BlueprintReadWrite, Category = "PixoVR")
float NeededTime
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
float MaxShortPressTime
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
float CurrentTime
The current time elapsed during the long hold.
FOnLongHoldReleased LongHoldReleasedEvent
The event to execute when the long hold is released.