From 6249359373290acb0b8f6e34c3f17575b5a514cc Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 29 Apr 2019 21:25:03 -0500 Subject: [PATCH] Add an option to enable the center panel top sensor. --- smx-config/CurrentSMXDevice.cs | 14 +++++++++++ smx-config/MainWindow.xaml | 22 ++++++++++------ smx-config/MainWindow.xaml.cs | 1 + smx-config/Widgets.cs | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 7 deletions(-) diff --git a/smx-config/CurrentSMXDevice.cs b/smx-config/CurrentSMXDevice.cs index 7399d30..3ffca59 100644 --- a/smx-config/CurrentSMXDevice.cs +++ b/smx-config/CurrentSMXDevice.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; }; diff --git a/smx-config/MainWindow.xaml b/smx-config/MainWindow.xaml index 9f89b51..381c6d9 100644 --- a/smx-config/MainWindow.xaml +++ b/smx-config/MainWindow.xaml @@ -538,22 +538,22 @@ Use if the platform is too sensitive. - - + + - + - + - + @@ -897,9 +897,17 @@ Input will be disabled from deselected panels. Show light animations on all panels instead of only panels with sensors. - + + + - + Import/export settings = 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. diff --git a/smx-config/Widgets.cs b/smx-config/Widgets.cs index bc29802..ef4b6fa 100644 --- a/smx-config/Widgets.cs +++ b/smx-config/Widgets.cs @@ -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 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); + } + } }