Smarter Controller / Keyboard Mapping?

I’m creating a context-sensitive UserWidget that is supposed to show at any time what the controls are to navigate through the menu or dialog boxes etc. The Widget has a bunch of ‘slots’ - basically an image and a text block that change to whatever I want.


What I want to do is create a TMap in the Widget that has all of the possible hardware input bindings (as shown in the Input list when you create new Input Mappings), and use those as the keys. The Value will then be the texture asset. I’ll have to fill it up in code with some hard-coded references but that’s not a problem really, since they’ll never move or not be there. The idea is that whenever I tell the widget what to display, I can do it based on what the actual input button / key is supposed to be.

Trouble is, I have no idea what the Input Keys really are in Unreal, does anybody know? The other reason I’m doing this is because I want the buttons to dynamically switch to the correct controller type, depending on what the player is using (e.g., PS4, Keyboard, Xbone etc). I have all the images, just no system yet. Hopefully if I can keep this modular enough I can continue to redevelop the UI as much as I want without having to always check that the input bindings match up.

So I figured out how to get access to the actual keys themselves, part of InputCoreTypes is the ‘EKeys’ type which you can access the individual keys from. So now I want to create a static const TMap of the FKey and UTexture2D, but how can I assign textures to this since it’s static and const - is it even possible?

This is where I am right now, I just don’t know how to actually specify what asset to use for the TMap value… You can Initialize TMaps this way I believe in C++11, but how can I load the textures?


class BZGAME_API UBZGame_ControlWidget : public UBZGame_MenuWidget

	/* Maps Keys to Textures */
	static const TMap<FKey, UTexture2D*> KeyTextureMap;


TMap<FKey, UTexture2D*> UBZGame_ControlWidget::KeyTextureMap = {
	{EKeys::A, TAssetPtr()},
	{EKeys::B, },
	{EKeys::C, },
	{EKeys::D, },