Add an option to enable the center panel top sensor.

master
Glenn Maynard 6 years ago
parent 27be716768
commit 6249359373
  1. 14
      smx-config/CurrentSMXDevice.cs
  2. 16
      smx-config/MainWindow.xaml
  3. 1
      smx-config/MainWindow.xaml.cs
  4. 46
      smx-config/Widgets.cs

@ -31,6 +31,20 @@ namespace smx_config
// Data for each of two controllers:
public LoadFromConfigDelegateArgsPerController[] controller;
// If we have more than one connected controller, we expect them to be the same version.
// Return the newest firmware version that's connected.
public int firmwareVersion()
{
int result = 1;
foreach(var data in controller)
{
if(data.info.connected && data.info.m_iFirmwareVersion > result)
result = data.info.m_iFirmwareVersion;
}
return result;
}
// The control that changed the configuration (passed to FireConfigurationChanged).
public object source;
};

@ -538,22 +538,22 @@ Use if the platform is too sensitive.</clr:String>
</ComboBox>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
<Image Source="Resources/sensor_left.png" Width="24" Height="24" />
<Image Source="Resources/sensor_left.png" Width="24" Height="24" Margin="0,0,6,0" />
<controls:LevelBar x:Name="SensorBar1" Margin="0,2,5,0" />
<Label x:Name="SensorBarLevel1" HorizontalAlignment="Center" Content="xxx"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
<Image Source="Resources/sensor_up.png" Width="24" Height="24" />
<Image Source="Resources/sensor_up.png" Width="24" Height="24" Margin="0,0,6,0" />
<controls:LevelBar x:Name="SensorBar3" Margin="0,2,5,0"/>
<Label x:Name="SensorBarLevel3" HorizontalAlignment="Center" Content="xxx"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
<Image Source="Resources/sensor_down.png" Width="24" Height="24" />
<Image Source="Resources/sensor_down.png" Width="24" Height="24" Margin="0,0,6,0" />
<controls:LevelBar x:Name="SensorBar4" Margin="0,2,5,0"/>
<Label x:Name="SensorBarLevel4" HorizontalAlignment="Center" Content="xxx"/>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
<Image Source="Resources/sensor_right.png" Width="24" Height="24" />
<Image Source="Resources/sensor_right.png" Width="24" Height="24" Margin="0,0,6,0" />
<controls:LevelBar x:Name="SensorBar2" Margin="0,2,0,0"/>
<Label x:Name="SensorBarLevel2" HorizontalAlignment="Center" Content="xxx"/>
</StackPanel>
@ -898,6 +898,14 @@ Input will be disabled from deselected panels.</TextBlock>
<TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,0,0,0" TextAlignment="Center">Show light animations on all panels
instead of only panels with sensors.</TextBlock>
<controls:EnableCenterTopSensorCheckbox VerticalAlignment="Center"
x:Name="EnableCenterTopSensorCheckbox"
DockPanel.Dock="Right" Content="Enable top sensor on center panel (usually off)"
HorizontalAlignment="Center"
Margin="0 10 0 0"
IsChecked="{Binding Path=EnableSensor, Mode=TwoWay, RelativeSource={RelativeSource Self}}"
/>
<Separator Margin="0,10,0,10" />
<TextBlock HorizontalAlignment="Center"

@ -153,6 +153,7 @@ namespace smx_config
ConnectedPads.Visibility = EitherControllerConnected? Visibility.Visible:Visibility.Hidden;
PanelColorP1.Visibility = args.controller[0].info.connected? Visibility.Visible:Visibility.Collapsed;
PanelColorP2.Visibility = args.controller[1].info.connected? Visibility.Visible:Visibility.Collapsed;
EnableCenterTopSensorCheckbox.Visibility = args.firmwareVersion() >= 5? Visibility.Visible:Visibility.Collapsed;
// Show the color slider or GIF UI depending on which one is set in flags.
// If both pads are turned on, just use the first one.

@ -996,4 +996,50 @@ namespace smx_config
//LoadUIFromConfig(firstConfig);
}
}
public class EnableCenterTopSensorCheckbox: CheckBox
{
public static readonly DependencyProperty EnableSensorProperty = DependencyProperty.Register("EnableSensor",
typeof(bool), typeof(EnableCenterTopSensorCheckbox), new FrameworkPropertyMetadata(false));
public bool EnableSensor {
get { return (bool) GetValue(EnableSensorProperty); }
set { SetValue(EnableSensorProperty, value); }
}
OnConfigChange onConfigChange;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
onConfigChange = new OnConfigChange(this, delegate (LoadFromConfigDelegateArgs args) {
LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
});
}
private void LoadUIFromConfig(SMX.SMXConfig config)
{
// Center panel, top sensor:
bool enabled = config.panelSettings[4].fsrHighThreshold[2] < 255;
EnableSensor = enabled;
}
protected override void OnClick()
{
foreach(Tuple<int,SMX.SMXConfig> activePad in ActivePad.ActivePads())
{
int pad = activePad.Item1;
SMX.SMXConfig config = activePad.Item2;
// Disable the sensor by setting its high threshold to 255, and enable it by syncing it up
// with the other thresholds.
if(!EnableSensor)
config.panelSettings[4].fsrHighThreshold[2] = config.panelSettings[4].fsrHighThreshold[0];
else
config.panelSettings[4].fsrHighThreshold[2] = 255;
SMX.SMX.SetConfig(pad, config);
}
CurrentSMXDevice.singleton.FireConfigurationChanged(this);
}
}
}

Loading…
Cancel
Save