More work on managing input events
This commit is contained in:
BIN
Content/Luprex/InputActions/IA_Console.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_Console.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_DPadD.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_DPadD.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_DPadL.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_DPadL.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_DPadR.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_DPadR.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_DPadU.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_DPadU.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_FaceL.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_FaceL.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_FaceM.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_FaceM.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_FaceR.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_FaceR.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_ShoulderL.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_ShoulderL.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_ShoulderR.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_ShoulderR.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_TriggerL.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_TriggerL.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/InputActions/IA_TriggerR.uasset
LFS
Normal file
BIN
Content/Luprex/InputActions/IA_TriggerR.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,7 @@
|
|||||||
bool FlxEventRequest::operator==(const FlxEventRequest &Other) const
|
bool FlxEventRequest::operator==(const FlxEventRequest &Other) const
|
||||||
{
|
{
|
||||||
return (Widget == Other.Widget) &&
|
return (Widget == Other.Widget) &&
|
||||||
(TakeControl == Other.TakeControl) &&
|
(UseUIOnly == Other.UseUIOnly) &&
|
||||||
(ShowPointer == Other.ShowPointer) &&
|
(ShowPointer == Other.ShowPointer) &&
|
||||||
(Hotkeys == Other.Hotkeys);
|
(Hotkeys == Other.Hotkeys);
|
||||||
}
|
}
|
||||||
@@ -22,12 +22,12 @@ bool FlxEventRequests::SanityCheck(const FlxEventRequest &Request)
|
|||||||
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents called with null widget."));
|
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents called with null widget."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Request.ShowPointer && !Request.TakeControl)
|
if (Request.ShowPointer && !Request.UseUIOnly)
|
||||||
{
|
{
|
||||||
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents: ShowPointer requires TakeControl."));
|
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents: ShowPointer requires UseUIOnly."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Request.TakeControl && !Request.Hotkeys.IsEmpty())
|
if (Request.UseUIOnly && !Request.Hotkeys.IsEmpty())
|
||||||
{
|
{
|
||||||
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents: Widget asked for all events, and also, specific events"));
|
UE_LOG(LogLuprexIntegration, Error, TEXT("RequestEvents: Widget asked for all events, and also, specific events"));
|
||||||
return false;
|
return false;
|
||||||
@@ -38,7 +38,7 @@ bool FlxEventRequests::SanityCheck(const FlxEventRequest &Request)
|
|||||||
void FlxEventRequests::SplitHighLow(View &High, View &Low)
|
void FlxEventRequests::SplitHighLow(View &High, View &Low)
|
||||||
{
|
{
|
||||||
int32 NumHigh = 0;
|
int32 NumHigh = 0;
|
||||||
while ((NumHigh < Requests.Num()) && (Requests[NumHigh].TakeControl)) NumHigh++;
|
while ((NumHigh < Requests.Num()) && (Requests[NumHigh].UseUIOnly)) NumHigh++;
|
||||||
int32 NumLow = Requests.Num() - NumHigh;
|
int32 NumLow = Requests.Num() - NumHigh;
|
||||||
High = View(Requests.GetData(), NumHigh);
|
High = View(Requests.GetData(), NumHigh);
|
||||||
Low = View(Requests.GetData() + NumHigh, NumLow);
|
Low = View(Requests.GetData() + NumHigh, NumLow);
|
||||||
@@ -52,7 +52,7 @@ void FlxEventRequests::Request(const FlxEventRequest &NewRequest)
|
|||||||
|
|
||||||
// This is a simple test to see if anything is going to change.
|
// This is a simple test to see if anything is going to change.
|
||||||
// If not, we return early and avoid setting the dirty bit.
|
// If not, we return early and avoid setting the dirty bit.
|
||||||
if (NewRequest.TakeControl)
|
if (NewRequest.UseUIOnly)
|
||||||
{
|
{
|
||||||
if ((High.Num() > 0) && (High[0] == NewRequest)) return;
|
if ((High.Num() > 0) && (High[0] == NewRequest)) return;
|
||||||
}
|
}
|
||||||
@@ -65,12 +65,12 @@ void FlxEventRequests::Request(const FlxEventRequest &NewRequest)
|
|||||||
TArray<FlxEventRequest> Updated;
|
TArray<FlxEventRequest> Updated;
|
||||||
|
|
||||||
// Add all high priority requests to the updated array, new request first.
|
// Add all high priority requests to the updated array, new request first.
|
||||||
if (NewRequest.TakeControl) Updated.Add(NewRequest);
|
if (NewRequest.UseUIOnly) Updated.Add(NewRequest);
|
||||||
for (const FlxEventRequest &Req : High)
|
for (const FlxEventRequest &Req : High)
|
||||||
if (Req.Widget != NewRequest.Widget) Updated.Add(Req);
|
if (Req.Widget != NewRequest.Widget) Updated.Add(Req);
|
||||||
|
|
||||||
// Add all low priority requests to the updated array, new request first.
|
// Add all low priority requests to the updated array, new request first.
|
||||||
if (!NewRequest.TakeControl) Updated.Add(NewRequest);
|
if (!NewRequest.UseUIOnly) Updated.Add(NewRequest);
|
||||||
for (const FlxEventRequest &Req : Low)
|
for (const FlxEventRequest &Req : Low)
|
||||||
if (Req.Widget != NewRequest.Widget) Updated.Add(Req);
|
if (Req.Widget != NewRequest.Widget) Updated.Add(Req);
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ void FlxEventRequests::GarbageCollect()
|
|||||||
|
|
||||||
FlxEventRequests::InputMode FlxEventRequests::GetRequestedMode() const
|
FlxEventRequests::InputMode FlxEventRequests::GetRequestedMode() const
|
||||||
{
|
{
|
||||||
if ((Requests.Num() > 0) && (Requests[0].TakeControl))
|
if ((Requests.Num() > 0) && (Requests[0].UseUIOnly))
|
||||||
{
|
{
|
||||||
return InputMode::UIOnly;
|
return InputMode::UIOnly;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
// Custom input event dispatching system. Uses Unreal's
|
// Custom input event dispatching system. Uses Unreal's
|
||||||
// built-in input modes (GameOnly / UIOnly) with an
|
// built-in input modes (GameOnly / UIOnly) with an
|
||||||
// enhanced input component for character mode hotkeys.
|
// enhanced input component for GameOnly mode hotkeys.
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -22,12 +22,12 @@
|
|||||||
// A widget's declaration of interest in input events.
|
// A widget's declaration of interest in input events.
|
||||||
//
|
//
|
||||||
// Widget: The widget that wants to receive events.
|
// Widget: The widget that wants to receive events.
|
||||||
// TakeControl: If true, activating this request puts
|
// UseUIOnly: If true, activating this request puts
|
||||||
// the system into Widget Mode.
|
// the system into UIOnly mode.
|
||||||
// ShowPointer: If true, the mouse pointer should be
|
// ShowPointer: If true, the mouse pointer should be
|
||||||
// visible when this widget has control.
|
// visible when this widget has control.
|
||||||
// Hotkeys: Keys that go to this widget when the
|
// Hotkeys: Keys that go to this widget when the
|
||||||
// player is in Character mode.
|
// player is in GameOnly mode.
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ struct FlxEventRequest
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
FlxEventRequest() = default;
|
FlxEventRequest() = default;
|
||||||
FlxEventRequest(UUserWidget *InWidget, bool InTakeControl, bool InShowPointer, const TArray<FKey> &InHotkeys)
|
FlxEventRequest(UUserWidget *InWidget, bool InUseUIOnly, bool InShowPointer, const TArray<FKey> &InHotkeys)
|
||||||
: Widget(InWidget), TakeControl(InTakeControl), ShowPointer(InShowPointer), Hotkeys(InHotkeys) {}
|
: Widget(InWidget), UseUIOnly(InUseUIOnly), ShowPointer(InShowPointer), Hotkeys(InHotkeys) {}
|
||||||
|
|
||||||
bool operator == (const FlxEventRequest &Other) const;
|
bool operator == (const FlxEventRequest &Other) const;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ struct FlxEventRequest
|
|||||||
UUserWidget* Widget = nullptr;
|
UUserWidget* Widget = nullptr;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
bool TakeControl = false;
|
bool UseUIOnly = false;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite)
|
UPROPERTY(BlueprintReadWrite)
|
||||||
bool ShowPointer = false;
|
bool ShowPointer = false;
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ FVector2D AlxPlayerControllerBase::GetLookAtPixel(const UObject *Context)
|
|||||||
void AlxPlayerControllerBase::BeginPlay()
|
void AlxPlayerControllerBase::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
CharacterModeInput = NewObject<UInputComponent>(this);
|
HotkeyInputComponent = NewObject<UInputComponent>(this);
|
||||||
CharacterModeInput->bBlockInput = false;
|
HotkeyInputComponent->bBlockInput = false;
|
||||||
PushInputComponent(CharacterModeInput);
|
PushInputComponent(HotkeyInputComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlxPlayerControllerBase::UpdateEventDispatch()
|
void AlxPlayerControllerBase::UpdateEventDispatch()
|
||||||
@@ -121,7 +121,7 @@ void AlxPlayerControllerBase::UpdateEventDispatch()
|
|||||||
{
|
{
|
||||||
SetInputMode(FInputModeGameOnly());
|
SetInputMode(FInputModeGameOnly());
|
||||||
|
|
||||||
CharacterModeInput->KeyBindings.Empty();
|
HotkeyInputComponent->KeyBindings.Empty();
|
||||||
TSet<FKey> BoundKeys;
|
TSet<FKey> BoundKeys;
|
||||||
for (const FlxEventRequest &Req : Requests)
|
for (const FlxEventRequest &Req : Requests)
|
||||||
{
|
{
|
||||||
@@ -130,7 +130,7 @@ void AlxPlayerControllerBase::UpdateEventDispatch()
|
|||||||
if (!BoundKeys.Contains(Key))
|
if (!BoundKeys.Contains(Key))
|
||||||
{
|
{
|
||||||
BoundKeys.Add(Key);
|
BoundKeys.Add(Key);
|
||||||
CharacterModeInput->BindKey(Key, IE_Pressed, this, &AlxPlayerControllerBase::ForwardKeyEvent);
|
HotkeyInputComponent->BindKey(Key, IE_Pressed, this, &AlxPlayerControllerBase::ForwardKeyEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
// Rebuild input component and switch input mode.
|
// Rebuild input component and switch input mode.
|
||||||
void UpdateEventDispatch();
|
void UpdateEventDispatch();
|
||||||
|
|
||||||
// Handler for character mode hotkey presses.
|
// Handler for GameOnly mode hotkey presses.
|
||||||
void ForwardKeyEvent(FKey Key);
|
void ForwardKeyEvent(FKey Key);
|
||||||
|
|
||||||
// Walk up from a Slate widget to find the nearest UMG widget class name.
|
// Walk up from a Slate widget to find the nearest UMG widget class name.
|
||||||
@@ -65,9 +65,9 @@ public:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FlxEventRequests EventRequests;
|
FlxEventRequests EventRequests;
|
||||||
|
|
||||||
// Input component for Character Mode: catches hotkeys only.
|
// Input component for GameOnly mode: catches hotkeys only.
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UInputComponent *CharacterModeInput = nullptr;
|
UInputComponent *HotkeyInputComponent = nullptr;
|
||||||
|
|
||||||
// Current input mode.
|
// Current input mode.
|
||||||
InputMode CurrentInputMode = InputMode::GameOnly;
|
InputMode CurrentInputMode = InputMode::GameOnly;
|
||||||
|
|||||||
Reference in New Issue
Block a user