Pause menu gamepad input suddenly stops working
Posted: 21 Oct 2020, 13:30
Hi!
I have a pause menu with a few buttons. I'll post the XAML code for the pause menu user control below. The pause menu has a few buttons, namely Resume, Load Game and Exit. The pause menu works great 95% of the time, but occasionally I run into a problem where pressing a button on the gamepad no longer causes any of the buttons on the pause menu to be pressed. I can still use the gamepad to move the selection up/down among the buttons, but pressing A no longer executes the button code. Using the mouse or keyboard to press the buttons continues to work fine.
What makes the issue annoying is that it is hard to reproduce and usually only occurs after playing the game for a few minutes. I haven't been able to reliably reproduce it ever. I have traced the input from my own code in the debugger and made sure that Noesis::Key_GamepadAccept is sent to KeyDown and KeyUp.
I don't know exactly how to continue investigating this issue. Any ideas? I am currently on Noesis 2.2.6 if that matters. I am looking into updating to version 3 later, but that is not possible right now.
I have a pause menu with a few buttons. I'll post the XAML code for the pause menu user control below. The pause menu has a few buttons, namely Resume, Load Game and Exit. The pause menu works great 95% of the time, but occasionally I run into a problem where pressing a button on the gamepad no longer causes any of the buttons on the pause menu to be pressed. I can still use the gamepad to move the selection up/down among the buttons, but pressing A no longer executes the button code. Using the mouse or keyboard to press the buttons continues to work fine.
What makes the issue annoying is that it is hard to reproduce and usually only occurs after playing the game for a few minutes. I haven't been able to reliably reproduce it ever. I have traced the input from my own code in the debugger and made sure that Noesis::Key_GamepadAccept is sent to KeyDown and KeyUp.
I don't know exactly how to continue investigating this issue. Any ideas? I am currently on Noesis 2.2.6 if that matters. I am looking into updating to version 3 later, but that is not possible right now.
Code: Select all
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:local="clr-namespace:Slide"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
mc:Ignorable="d"
x:Class="Slide.PauseMenu"
x:Name="PauseMenuControl"
d:DesignHeight="1080" d:DesignWidth="1920" Background="#88000000"
FontSize="20">
<UserControl.Resources>
<ResourceDictionary>
<!-- We use this to convert the IsCampaignActive bool property to a visibility value. -->
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<Storyboard x:Key="ShowPauseMenu">
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Visibility)"
Storyboard.TargetName="PauseMenuControl">
<!-- Visibility is an enum. This is how we set it to the "Visible" value. -->
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PauseMenuControl">
<LinearDoubleKeyFrame KeyTime="0" Value="0"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="HidePauseMenu">
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Visibility)"
Storyboard.TargetName="PauseMenuControl">
<!-- Visibility is an enum. This is how we set it to the "Collapsed" value. -->
<DiscreteObjectKeyFrame KeyTime="0:0:0.1" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PauseMenuControl">
<LinearDoubleKeyFrame KeyTime="0" Value="1"/>
<LinearDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</UserControl.Resources>
<i:Interaction.Triggers>
<!-- When State changes to PauseMenu, play the ShowPauseMenu storyboard. -->
<ei:DataTrigger Binding="{Binding State}" Value="{x:Static local:InGameUIState.PauseMenu}">
<!--<local:DebugOutputAction Output="Show pause menu"/>-->
<ei:ControlStoryboardAction Storyboard="{StaticResource ShowPauseMenu}"/>
</ei:DataTrigger>
<!-- When State changes to something other than PauseMenu, play the HidePauseMenu storyboard. -->
<ei:DataTrigger Binding="{Binding State}" Comparison="NotEqual" Value="{x:Static local:InGameUIState.PauseMenu}">
<!--<local:DebugOutputAction Output="Hide pause menu"/>-->
<ei:ControlStoryboardAction Storyboard="{StaticResource HidePauseMenu}"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
<Grid x:Name="LayoutRoot">
<i:Interaction.Triggers>
<ei:StoryboardCompletedTrigger Storyboard="{StaticResource ShowPauseMenu}">
<noesis:SetFocusAction TargetName="ResumeButton"/>
</ei:StoryboardCompletedTrigger>
</i:Interaction.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="1" Grid.Column="1" Background="#FF474F54" BorderBrush="#FF2F3538" BorderThickness="2" CornerRadius="5">
<StackPanel Margin="5" KeyboardNavigation.DirectionalNavigation="Cycle">
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20" Foreground="#FFC9CCCF"
FontSize="30" Text="{Binding UILanguage.Resources[TEXT_UI_PAUSED], FallbackValue='Paused'}"/>
<Button x:Name="ResumeButton" Margin="0,0,0,10" Command="{Binding PauseResume}" Content="{Binding UILanguage.Resources[TEXT_UI_RESUME], FallbackValue='Resume'}"/>
<Button x:Name="LoadButton" Margin="0,0,0,10" Command="{Binding PauseLoadGame}" Content="{Binding UILanguage.Resources[TEXT_UI_LOAD_GAME], FallbackValue='Load game'}"
Visibility="{Binding IsCampaignActive, Converter={StaticResource BoolToVis}}"/>
<Button x:Name="ExitButton" Command="{Binding PauseExit}" Content="{Binding UILanguage.Resources[TEXT_UI_EXIT], FallbackValue='Exit'}"/>
</StackPanel>
</Border>
</Grid>
</UserControl>