|
|
|
|
| #pragma once
|
|
|
| #include "EnhancedInputComponent.h"
|
| #include "LyraInputConfig.h"
|
|
|
| #include "LyraInputComponent.generated.h"
|
|
|
| class UEnhancedInputLocalPlayerSubsystem;
|
| class UInputAction;
|
| class UObject;
|
|
|
|
|
| |
| |
| |
| |
|
|
| UCLASS(Config = Input)
|
| class ULyraInputComponent : public UEnhancedInputComponent
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
|
|
| ULyraInputComponent(const FObjectInitializer& ObjectInitializer);
|
|
|
| void AddInputMappings(const ULyraInputConfig* InputConfig, UEnhancedInputLocalPlayerSubsystem* InputSubsystem) const;
|
| void RemoveInputMappings(const ULyraInputConfig* InputConfig, UEnhancedInputLocalPlayerSubsystem* InputSubsystem) const;
|
|
|
| template<class UserClass, typename FuncType>
|
| void BindNativeAction(const ULyraInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent, UserClass* Object, FuncType Func, bool bLogIfNotFound);
|
|
|
| template<class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
| void BindAbilityActions(const ULyraInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, TArray<uint32>& BindHandles);
|
|
|
| void RemoveBinds(TArray<uint32>& BindHandles);
|
| };
|
|
|
|
|
| template<class UserClass, typename FuncType>
|
| void ULyraInputComponent::BindNativeAction(const ULyraInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent, UserClass* Object, FuncType Func, bool bLogIfNotFound)
|
| {
|
| check(InputConfig);
|
| if (const UInputAction* IA = InputConfig->FindNativeInputActionForTag(InputTag, bLogIfNotFound))
|
| {
|
| BindAction(IA, TriggerEvent, Object, Func);
|
| }
|
| }
|
|
|
| template<class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
| void ULyraInputComponent::BindAbilityActions(const ULyraInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc, TArray<uint32>& BindHandles)
|
| {
|
| check(InputConfig);
|
|
|
| for (const FLyraInputAction& Action : InputConfig->AbilityInputActions)
|
| {
|
| if (Action.InputAction && Action.InputTag.IsValid())
|
| {
|
| if (PressedFunc)
|
| {
|
| BindHandles.Add(BindAction(Action.InputAction, ETriggerEvent::Triggered, Object, PressedFunc, Action.InputTag).GetHandle());
|
| }
|
|
|
| if (ReleasedFunc)
|
| {
|
| BindHandles.Add(BindAction(Action.InputAction, ETriggerEvent::Completed, Object, ReleasedFunc, Action.InputTag).GetHandle());
|
| }
|
| }
|
| }
|
| }
|
|
|