lowprofile
Topic Author
Posts: 4
Joined: 05 May 2021, 18:40

What is the best way to use Unreal Engine Input Actions in Xamls?

21 Jan 2022, 15:08

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.
 
User avatar
hcpizzi
Site Admin
Posts: 321
Joined: 09 Feb 2012, 12:40

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

21 Jan 2022, 18:15

Hi,

Could you tell us a bit about how you would use them?

Thank you
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

22 Jan 2022, 11:49

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.

Image
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.
 
lowprofile
Topic Author
Posts: 4
Joined: 05 May 2021, 18:40

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

24 Jan 2022, 13:32

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)
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

25 Jan 2022, 11:51

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.
 
lowprofile
Topic Author
Posts: 4
Joined: 05 May 2021, 18:40

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

25 Jan 2022, 15:00

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
 
lowprofile
Topic Author
Posts: 4
Joined: 05 May 2021, 18:40

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

25 Jan 2022, 16:45

or can we do it like this?
<Button Content="Back" Margin="10" Height="Auto" common:InputActionProperty.Action="Back" Command="{Binding BackCommand}"/>
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

26 Jan 2022, 11:15

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?
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: What is the best way to use Unreal Engine Input Actions in Xamls?

26 Jan 2022, 11:29

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.

Who is online

Users browsing this forum: Google [Bot] and 11 guests