Up to now, I just had used Input system doing nothing fancy, just statically using the definitions. Everything fine, both for Old and Enhanced Input.
Now starting to deal with player mappable input settings, I tried to go more in depth into Enhanced Input in C++.
The old input system has UInputSettings, which for example can use AddActionMapping() which uses FInputActionKeyMapping, basically allowing to use the FInputChord data from OnKeySelected() returned by an Input Key Selector in UMG. As said, I never did do player mappable input / saving custom settings with the old system, but from the API docs it at least looks like the logic is consistently covered with that system.
In the Enhanced Input System it looks like for example these booleans in FInputChord are not of any real practical use anymore. For example, AddPlayerMappedKey() only uses FKey, not FInputChord as parameter.
Instead, Enhanced Input solely seems to rely on Chorded Actions defined by Triggers. No doubt, this adds more flexibility not being limited to Shift, Alt, Ctrl and Cmd.
But how would one use InputKeySelector´s OnKeySelected() in UMG to actually make player mappable Shift-X actions? OnKeySelected() has FInputChord in the signature, but as said, AddActionMapping() can only use the FKey part of it.
Sure, it should be possible with doing a lot of own coding, but the question remains:
Which is the unrealistic way of doing it? With unrealistic I mean, how this is meant to be done, similar to the term pythonic in the Python world.
Are there any changes to be expected allowing to handle Chorded Actions with the InputKeySelector?
Same question arises for saving player mapped inputs: UInputSettings has a SaveKeyMappings() function, which seems to be the correct way to save custom mappings.
How is this meant to be done with the Enhanced Input?
My current approach: I use a SaveGame which holds a TMap<FName, FKey>. Any Mapping that is changed to a value not contained in the configuration itself is written to that SaveGame, and on Game Start, mappings loaded from PlayerMappable Config/Context(s) in the InputSubsystem simply get overridden by these values.
The SaveGame only keeps those mappings, that have been changed to values other than the default.
While it works perfectly, I feel uncomfortable with it. I believe, a SaveGame should be used for saving Game related data, as the name says. Storing config data kind of looks like a misuse.
But lot of tutorials go for this approach, and even in Lyra code, it looks like Epic themselves do it that way.
For this, the same question arises: what about Inputs like Shift-N? There’s no existing way to save this. It should of course be possible with a lot of own coding as well, extending that SaveGame data structure. The old UInputMappings SaveKeyMappings() even seems to handle this.
There are also Context based functions, like UInputMappingContext::MapKey(), but this also does not account for stuff like Shift-N. Nice about this: it immediately saves changes to the context uasset, which already started making me happy (I did not test, if this save happens in a packaged build as well).
Again, the questions is about multi key actions. I could even add new mappings to the context, but only was able to set the Key, even could not set other stuff like the bPlayerMappable flag, and also could not add any Triggers.
I found that Lyra also does not use the Context MapKey() function, but the Subsystem based AddPlayerMappedKey().
So all in all, it looks like the Enhanced Input System still has less functionality out of the box compared to the old one. Also when looking at the source, there are comments making me believe that it is (even while being there since 4.26) not yet mature compared to the old system.
Anyone out there, who can shed some light on this?