Show a warning if the low FSR threshold is set too low.

This commit is contained in:
Glenn Maynard 2019-09-14 21:18:42 -05:00
parent 37e5b445cd
commit bbb49b6ae4
6 changed files with 54 additions and 1 deletions

View File

@ -145,8 +145,13 @@ Use if the platform is too sensitive.</clr:String>
<Label Margin="5,0,0,0" x:Name="LowerValue" Content="0" Width="30" HorizontalContentAlignment="Right" <Label Margin="5,0,0,0" x:Name="LowerValue" Content="0" Width="30" HorizontalContentAlignment="Right"
HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalAlignment="Left" VerticalAlignment="Top"
/> />
<Image x:Name="ThresholdWarning"
Source="Resources/threshold_warning.png" Width="9" Height="28"
Margin="10,0,0,0"
Visibility="Visible"
/>
<controls:DoubleSlider x:Name="Slider" <controls:DoubleSlider x:Name="Slider"
Margin="32,5,0,0" Margin="24,5,0,0"
MinimumDistance="10" MinimumDistance="10"
LowerValue="20" UpperValue="35" LowerValue="20" UpperValue="35"
VerticalAlignment="Top" VerticalAlignment="Top"
@ -854,6 +859,14 @@ a panel to activate and deactivate.
A panel will activate when it reaches the right side of the A panel will activate when it reaches the right side of the
slider, and deactivate when it reaches the left side of the slider.</TextBlock> slider, and deactivate when it reaches the left side of the slider.</TextBlock>
<TextBlock x:Name="ThresholdWarningText" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="0,15,0,0"
xml:space="preserve"
TextAlignment="Center"
Foreground="#F00"
>Low thresholds above 140 are recommended. Higher thresholds allow the
panel to detect releases more quickly.
</TextBlock>
<DockPanel DockPanel.Dock="Bottom" <DockPanel DockPanel.Dock="Bottom"
VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="0,0,5,0"> VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="0,0,5,0">

View File

@ -182,6 +182,19 @@ namespace smx_config
RefreshUploadPadText(args); RefreshUploadPadText(args);
RefreshSelectedColorPicker(); RefreshSelectedColorPicker();
// Show the threshold warning explanation if any panels are showing the threshold warning icon.
bool ShowThresholdWarningText = false;
foreach(Tuple<int, SMX.SMXConfig> activePad in ActivePad.ActivePads())
{
SMX.SMXConfig config = activePad.Item2;
for(int panelIdx = 0; panelIdx < 9; ++panelIdx)
{
if(config.ShowThresholdWarning(panelIdx))
ShowThresholdWarningText = true;
}
}
ThresholdWarningText.Visibility = ShowThresholdWarningText? Visibility.Visible : Visibility.Hidden;
// If a second controller has connected and we're on Both, see if we need to prompt // If a second controller has connected and we're on Both, see if we need to prompt
// to sync configs. We only actually need to do this if a controller just connected. // to sync configs. We only actually need to do this if a controller just connected.
if(args.ConfigurationChanged) if(args.ConfigurationChanged)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -112,6 +112,24 @@ namespace SMX
return masterVersion >= 4 && (configFlags & SMXConfigFlags.PlatformFlags_FSR) != 0; return masterVersion >= 4 && (configFlags & SMXConfigFlags.PlatformFlags_FSR) != 0;
} }
// Return true if the low threshold is set too low.
//
// Higher low threshold values make the panel respond to the panel being released more
// quickly. It shouldn't be set too low.
public bool ShowThresholdWarning(int panel)
{
if(!fsr())
return false;
// Don't show warnings for disabled panels.
if(!GetEnabledPanels()[panel])
return false;
int lower = panelSettings[panel].fsrLowThreshold[0];
int MinimumRecommendedLowThreshold = 140;
return lower < MinimumRecommendedLowThreshold;
}
// enabledSensors is a mask of which panels are enabled. Return this as an array // enabledSensors is a mask of which panels are enabled. Return this as an array
// for convenience. // for convenience.
public bool[] GetEnabledPanels() public bool[] GetEnabledPanels()

View File

@ -218,6 +218,9 @@
<Resource Include="Resources\sensor_right.png" /> <Resource Include="Resources\sensor_right.png" />
<Resource Include="Resources\sensor_up.png" /> <Resource Include="Resources\sensor_up.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Resources\threshold_warning.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -122,6 +122,7 @@ namespace smx_config
DoubleSlider slider; DoubleSlider slider;
Label LowerLabel, UpperLabel; Label LowerLabel, UpperLabel;
Image ThresholdWarning;
OnConfigChange onConfigChange; OnConfigChange onConfigChange;
@ -132,6 +133,7 @@ namespace smx_config
slider = GetTemplateChild("Slider") as DoubleSlider; slider = GetTemplateChild("Slider") as DoubleSlider;
LowerLabel = GetTemplateChild("LowerValue") as Label; LowerLabel = GetTemplateChild("LowerValue") as Label;
UpperLabel = GetTemplateChild("UpperValue") as Label; UpperLabel = GetTemplateChild("UpperValue") as Label;
ThresholdWarning = GetTemplateChild("ThresholdWarning") as Image;
slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); }; slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); };
@ -249,6 +251,10 @@ namespace smx_config
UpperLabel.Content = upper.ToString(); UpperLabel.Content = upper.ToString();
} }
int panelIdx = panelNameToIndex[Type];
bool ShowThresholdWarning = config.ShowThresholdWarning(panelIdx);
ThresholdWarning.Visibility = ShowThresholdWarning? Visibility.Visible:Visibility.Hidden;
RefreshVisibility(); RefreshVisibility();
UpdatingUI = false; UpdatingUI = false;
} }