48 lines
1.7 KiB
C++
48 lines
1.7 KiB
C++
// Copyright
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "EnhancedInputComponent.h"
|
|
#include "VRInputConfig.h"
|
|
#include "VRInputComponent.generated.h"
|
|
|
|
|
|
UCLASS()
|
|
class VRGAS_API UVRInputComponent : public UEnhancedInputComponent
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
template <class UserClass, typename FuncType>
|
|
void BindNativeActions(const UVRInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent,
|
|
UserClass* Object,FuncType Func, bool bLogNotFound = true);
|
|
|
|
template <class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
|
void BindAbilityActions(const UVRInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc);
|
|
};
|
|
|
|
template <class UserClass, typename FuncType>
|
|
void UVRInputComponent::BindNativeActions(const UVRInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent,
|
|
UserClass* Object,FuncType Func, const bool bLogNotFound)
|
|
{
|
|
check(InputConfig)
|
|
if (UInputAction* Action = InputConfig->FindNativeInputActionForTag(InputTag, bLogNotFound))
|
|
{
|
|
BindAction(Action, TriggerEvent, Object, Func);
|
|
}
|
|
}
|
|
|
|
template <class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
|
void UVRInputComponent::BindAbilityActions(const UVRInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc);
|
|
{
|
|
check(InputConfig)
|
|
for (const FVRTagInputBinding& Binding : InputConfig->AbilityInputActions)
|
|
{
|
|
if (Binding.IsValid())
|
|
{
|
|
if (PressedFunc) BindAction(Binding.InputAction, ETriggerEvent::Started, Object, PressedFunc, Binding.InputTag);
|
|
|
|
if (ReleasedFunc) BindAction(Binding.InputAction, ETriggerEvent::Completed, Object, ReleasedFunc, Binding.InputTag);
|
|
}
|
|
}
|
|
} |