-
- ttermeer-reboundcg
- Posts: 31
- Joined:
- Contact:
Gamepad Trigger inside ListBox
We have a simple ListBox to select an item. I am trying to setup a gamepad button to trigger a command. Everything works fine when using InputBindings but I cannot get GamepadTrigger to work.
I am guessing it is because, the behavior is set on the ListBox itself which is not focused but I don't know how to move it to the ListBoxItem instead.
I am guessing it is because, the behavior is set on the ListBox itself which is not focused but I don't know how to move it to the ListBoxItem instead.
Code: Select all
<ListBox ItemsSource="{Binding Rewards}" SelectedItem="{Binding SelectedReward, Mode=TwoWay}"
ItemContainerStyle="{StaticResource BoosterTemplate}" KeyboardNavigation.DirectionalNavigation="Cycle"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<!-- display item -->
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<b:Interaction.Triggers>
<noesis:GamepadTrigger FiredOn="ButtonUp" Button="Accept">
<b:InvokeCommandAction Command="{Binding TakeCommand}" />
</noesis:GamepadTrigger>
</b:Interaction.Triggers>
<ListBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding TakeCommand}" />
<KeyBinding Key="Space" Command="{Binding TakeCommand}" />
</ListBox.InputBindings>
</ListBox>Re: Gamepad Trigger inside ListBox
Hi!
Controller key codes are not mapped by default. To use controller inputs with Noesis, you have to go through the EnahancedInput subsystem. The plugin contains a set of InputActions, one for each of the Gamepad key codes. There's also an InputMappingContext with default mappings, but you're free to use your own. The part that matters are the actual InputActions. You also have to check the Enable Actions box on your NoesisView class' Class Settings.
Please, let us know if this resolves your issue.
Thank you!
Controller key codes are not mapped by default. To use controller inputs with Noesis, you have to go through the EnahancedInput subsystem. The plugin contains a set of InputActions, one for each of the Gamepad key codes. There's also an InputMappingContext with default mappings, but you're free to use your own. The part that matters are the actual InputActions. You also have to check the Enable Actions box on your NoesisView class' Class Settings.
Please, let us know if this resolves your issue.
Thank you!
-
- ttermeer-reboundcg
- Posts: 31
- Joined:
- Contact:
Re: Gamepad Trigger inside ListBox
Those are already setup and it works as intended everywhere else. The issue is only with ListBox Items when trying to add a gamepad trigger.
-
- ttermeer-reboundcg
- Posts: 31
- Joined:
- Contact:
Re: Gamepad Trigger inside ListBox
Also tried settings the trigger in the ItemContainer style like so :
But that also doesn't work.
Code: Select all
<Style x:Key="BoosterTemplate" TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource FRRDefaultControlStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<!-- custom template -->
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="noesis:StyleInteraction.Triggers">
<Setter.Value>
<noesis:StyleTriggerCollection>
<noesis:GamepadTrigger FiredOn="ButtonUp" Button="Accept">
<b:InvokeCommandAction Command="{Binding DataContext.TakeCommand, ElementName=SelectBoonRewardPage}" />
</noesis:GamepadTrigger>
</noesis:StyleTriggerCollection>
</Setter.Value>
</Setter>
</Style>
-
- ttermeer-reboundcg
- Posts: 31
- Joined:
- Contact:
Re: Gamepad Trigger inside ListBox
Found the problem. It was unrelated to the XAML but an issue with Input Mapping priority and input consumption. We had set the input mapping for Noesis to -1 to not interfere with gameplay but the Input Action by default are set to consume the input for lower priority action. By unticking this option, gamepad is now properly working when poping UI elements during gameplay.
Re: Gamepad Trigger inside ListBox
I'm glad you figured it out!
Who is online
Users browsing this forum: Bing [Bot] and 3 guests