Remapping keys + common UI?

So there are those things in the common UI plugin called “action widgets” that automatically display the key associated with an action.

Thing is, those actions are stored in a data table and as far as I’m concerned there’s no way to change the contents of a datatable during runtime…

I checked out Lyra but it didn’t have remap mechanic, so I’m kinda confused here. What’s the right way to remap actions to different keys and make it work with common UI?

1 Like

I was wondering the same thing. Even if in the Input Actions field is a array, it’s kind of useless to put in more than one entry. I tried putting in multiple, because of the same reason… key remapping. But i found out that if there are more than 2 entries, it breaks and shows nothing.

Funnily enough, i checked the code and …

const FCommonInputActionDataBase* UCommonActionWidget::GetInputActionData() const
{
	if (InputActions.Num() > 0)
	{
		const FCommonInputActionDataBase* InputActionData = CommonUI::GetInputActionData(InputActions[0]);
		return InputActionData;
	}

	return nullptr;
}

As you can see it just retrieves the 1st entry. Idk if it’s bugged or something, but iy would’ve been nice to have it so that it would detect if a certain key that you are trying to display has changed.
I think the system would need to be changed a bit, and actually get the reference to the players mapping context and give more control to what type of input actions you want to display, because that way, they could somehow listen to changes made to key bindings, that way maybe it could dynamically change to a different key brush from the list? But to be honest, it’s a bit unnecessary since you don’t really want to change certain actions, like Interaction or other actions from a default button.

I am using Common UI with Enhanced Input and as far as I can tell it looks up all mapped Keys to the referenced Action and then fetches a Brush for the first key found. I am pretty sure that this would work with Input Remapping since it dynamically looks up the mapped keys.

How do you reference an action? I can only reference keys

This is how they do it in C++:

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = CommonActionWidget, meta = (EditCondition = "CommonInput.CommonInputSettings.IsEnhancedInputSupportEnabled", EditConditionHides))
	TObjectPtr<class UInputAction> EnhancedInputAction;

I have never used C++, how and where should I add that code? And what does it do exactly?

This is how you reference it in Blueprints. Make sure you have both
Enhanced Input and CommonUI enabled.

And what do I do with it? I thought I had to use a common button base or something like that. I’m completely lost I’m sorry if I sound stupid lol

What exactly are you trying to do?

I’m using an enhanced input action to open the inventory and another one to pause the game. I want to use those same actions to close each menu but I can’t find a way since Common UI only allows static keys to cancel and accept among other options. Both enhanced input action keys can be remmapped by the player in the settings menu, so I can’t use a static button to close the inventory or the pause menu. When I activate enhanced input support in Common UI the accept/cancel keys stop working too. I’ve tried doing as in regular widgets/character blueprint and have the enhanced input action in the blueprint but it doesn’t trigger.

Well first off, I think it is common practice to not make the Pause Game action remappable. If you ever want to develop for consoles I believe that is a no-go.

Now it really depends on how you want to handle Toggling the Inventory.
You can open the Inventory via your Character Controller. When it’s opened, keep in mind: Enhanced Input Actions only work with Input Mode set to Game or Both, not when it is set to Menu. So you will have to use Both if you want to be able to close the inventory with the same button you open it with.
Then you can also close it via your Character Controller, just remember to block all other Inputs while it is open.

If you have the ToggleInventory action mapped in multiple Mapping Contexts, you will have to probably remap it in all of them if you intend to remap it. Otherwise only keep it in your Character Mapping Context.