Yeah I ran into the same interrogations back then.
I ended up making a simple helper utility like this
static bool IsKeyMappedToAction(const FKey& InKey, FName InActionName)
{
const UPlayerInput* PlayerInput = GetDefault<UPlayerInput>();
for (const auto& Action : PlayerInput->ActionMappings)
{
if (Action.ActionName == InActionName && Action.Key == InKey)
return true;
}
return false;
}
Which I then used directly in NativeOnKeyDown
FReply USomeMenu::NativeOnKeyDown(const FGeometry& InGeometry, const FKeyEvent& InKeyEvent)
{
if (ULib::IsKeyMappedToAction(InKeyEvent.GetKey(), "ToggleSomeMenu"))
{
Close();
return FReply::Handled();
}
return Super::NativeOnKeyDown(InGeometry, InKeyEvent);
}
I haven’t touched these things since then though, I wonder how it has evolved.
Lately I’ve been seeing more and more UE games ship out with lots of reconfigurable bindings, including fully reconfigurable UI navigation bindings, which was rarely ever the case before. Those config menus seem to suggest they are using input mapping contexts, so I’m guessing EnhancedInput probably had large contribution in this evolution. How does this whole thing work with EnhancedInput nowadays ? Can you just assign a mapping context to the UI, just like you assign a mapping context to a Pawn ?