Page 1 of 1
What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 21 Jan 2022, 15:08
by lowprofile
Is there a way to use Input Actions in xamls? As I see raw input events are mapped into noesis keys. But I am not sure how about Input Actions. I am planning to solve it by myself, but I wanted to be sure if there is a suggested way to do it.
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 21 Jan 2022, 18:15
by hcpizzi
Hi,
Could you tell us a bit about how you would use them?
Thank you
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 22 Jan 2022, 11:49
by jsantos
In our Unity plugin, the gamepad is configured using input actions. It allows you to define, for example, the different gamepad actions to invoke Up, Down, Left, Right, Accept, Cancel and so on.

But Unreal, already provides a high-level view of gamepad events (like EKeys::Gamepad_FaceButton_Bottom) so we didn't need using something similar to Unity input actions definitions.
Please, let us understand your scenario a bit better.
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 24 Jan 2022, 13:32
by lowprofile
Imagine I have "Back" action defined in UE ActionsMappings that is triggered with "Escape" and "Gamepad Face Button Right" keys
and in a xaml I have a button similar to this one
<Button Content="Back" Margin="10" Height="Auto" InputAction="Back" Command="{Binding BackCommand}"/>
As you see I want to just specify the InputAction here.
Depending on the solution when this action is triggered in UE, I could trigger Click even on this button. Or I could create a custom InputActionEvent in Noesis, so I could deal with the event manually in the xaml using interaction framework (eg. EventTrigger)
As I understand in the current system, I need to listen both "Escape" and "Game pad face button right" events manually in the xaml, right? (by using their Noesis key names)
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 25 Jan 2022, 11:51
by sfernandez
So if we got this right what you want is instead of having to write something like this in the xaml
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<b:Interaction.Triggers>
<b:KeyTrigger Key="Escape">
<b:InvokeCommandAction Command="{Biding BackCommand}"/>
</b:KeyTrigger>
<noesis:GamepadTrigger Button="Left">
<b:InvokeCommandAction Command="{Biding BackCommand}"/>
</noesis:GamepadTrigger>
</b:Interaction.Triggers>
<Button Content="BACK" Command="{Binding BackCommand}"/>
</Grid>
Specify a trigger for an Unreal's input action instead:
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<b:Interaction.Triggers>
<noesis:InputActionTrigger Action="Back">
<b:InvokeCommandAction Command="{Biding BackCommand}"/>
</noesis:InputActionTrigger>
</b:Interaction.Triggers>
<Button Content="BACK" Command="{Binding BackCommand}"/>
</Grid>
We can implement an extension like that in Unreal if it is what you require.
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 25 Jan 2022, 15:00
by lowprofile
This is a great solution. I believe it would be nice to have it as part of the extension
Would it be possible to have it like this?
This way:
- We do not need to specify Command two times.
- When Back button disabled, the ActionTrigger is also disabled
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<Button Content="BACK">
<b:Interaction.Triggers>
<noesis:InputActionTrigger Action="Back">
<b:InvokeCommandAction Command="{Biding BackCommand}"/>
</noesis:InputActionTrigger>
</b:Interaction.Triggers>
</Button>
</Grid>
If you can, could you also make the KeyboardNavigation work with InputActions instead of hardcoded input keys. Because we would like to be able to use W,S,A,D to navigate in menus. But we can't do it now. I believe all these changes would also allow us to have Input Settings panel where player could change key-bindings easily. Because all UI would depend on InputActions instead of hardcoded InputKeys
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 25 Jan 2022, 16:45
by lowprofile
or can we do it like this?
<Button Content="Back" Margin="10" Height="Auto" common:InputActionProperty.Action="Back" Command="{Binding BackCommand}"/>
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 26 Jan 2022, 11:15
by sfernandez
Hi,
I think your idea of using an attached property in combination with a Button is very practical and easy to use. We can implement that, but I think it will be also very useful to have the InputAction as a trigger so it can be used to invoke different type of actions, not only executing a command. Can you please ask for this feature in our bugtracker and we will implement both approaches?
Re: What is the best way to use Unreal Engine Input Actions in Xamls?
Posted: 26 Jan 2022, 11:29
by jsantos
If you can, could you also make the KeyboardNavigation work with InputActions instead of hardcoded input keys. Because we would like to be able to use W,S,A,D to navigate in menus. But we can't do it now. I believe all these changes would also allow us to have Input Settings panel where player could change key-bindings easily. Because all UI would depend on InputActions instead of hardcoded InputKeys
Yes, this is exactly what we are doing in Unity for the gamepad. We should do the same in Unreal. Please, file a ticket about this too.