From 854c9e03d407e6777e36f873352a7071c3f284cd Mon Sep 17 00:00:00 2001
From: tcfshcrw <48719709+tcfshcrw@users.noreply.github.com>
Date: Fri, 9 Aug 2024 06:37:54 +0800
Subject: [PATCH] Plugin rudder function improvement
1. Add property of rudder status
2. change rudder checkbox to button
3. Add simhub-action for rudder
---
SimHubPlugin/DataPluginDemo.cs | 15 ++++++++++---
SimHubPlugin/SettingsControlDemo.xaml | 6 ++---
SimHubPlugin/SettingsControlDemo.xaml.cs | 28 ++++++++++++++++++++++++
3 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/SimHubPlugin/DataPluginDemo.cs b/SimHubPlugin/DataPluginDemo.cs
index 22c949c5..c133f2ab 100644
--- a/SimHubPlugin/DataPluginDemo.cs
+++ b/SimHubPlugin/DataPluginDemo.cs
@@ -861,7 +861,8 @@ unsafe public void DataUpdate(PluginManager pluginManager, ref GameData data)
}
Rudder_enable_flag = false;
System.Threading.Thread.Sleep(50);
- }
+ }
+ SystemSounds.Beep.Play();
}
@@ -965,7 +966,8 @@ unsafe public void DataUpdate(PluginManager pluginManager, ref GameData data)
pluginManager.SetPropertyValue("Theme_color", this.GetType(), simhub_theme_color);
pluginManager.SetPropertyValue("ProfileIndex", this.GetType(), profile_index);
pluginManager.SetPropertyValue("debugvalue", this.GetType(), debug_value);
-
+ pluginManager.SetPropertyValue("rudder_status", this.GetType(), Rudder_status);
+
@@ -1371,6 +1373,7 @@ public void Init(PluginManager pluginManager)
pluginManager.AddProperty("Overlay_display", this.GetType(), overlay_display);
pluginManager.AddProperty("Theme_color", this.GetType(), simhub_theme_color);
pluginManager.AddProperty("debugvalue", this.GetType(), debug_value);
+ pluginManager.AddProperty("rudder_status", this.GetType(), Rudder_status);
// Declare an event
//this.AddEvent("SpeedWarning");
@@ -1607,10 +1610,16 @@ public void Init(PluginManager pluginManager)
});
this.AddAction("Rudder Brake", (a, b) =>
{
-
Rudder_brake_enable_flag = true;
SimHub.Logging.Current.Info("Rudder Brake");
+ });
+ this.AddAction("Rudder", (a, b) =>
+ {
+
+ Rudder_enable_flag=true;
+ SimHub.Logging.Current.Info("Rudder action");
+
});
//Settings.selectedJsonIndexLast[0]
diff --git a/SimHubPlugin/SettingsControlDemo.xaml b/SimHubPlugin/SettingsControlDemo.xaml
index dfb099c0..57b6dcf3 100644
--- a/SimHubPlugin/SettingsControlDemo.xaml
+++ b/SimHubPlugin/SettingsControlDemo.xaml
@@ -856,14 +856,12 @@
-
-
-
-
+
+
diff --git a/SimHubPlugin/SettingsControlDemo.xaml.cs b/SimHubPlugin/SettingsControlDemo.xaml.cs
index 57a5f3a4..33179978 100644
--- a/SimHubPlugin/SettingsControlDemo.xaml.cs
+++ b/SimHubPlugin/SettingsControlDemo.xaml.cs
@@ -1068,6 +1068,18 @@ public void updateTheGuiFromConfig()
label_CV2_freq.Content = "Effect Frequency:" + dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.CV_freq_2 + "Hz";
textBox_CV1_string.Text = Plugin.Settings.CV1_bindings[indexOfSelectedPedal_u];
textBox_CV2_string.Text = Plugin.Settings.CV2_bindings[indexOfSelectedPedal_u];
+
+
+ //rudder text
+ if (Plugin.Rudder_status)
+ {
+ btn_rudder.Content = "Click for rudder:Off";
+ }
+ else
+ {
+ btn_rudder.Content = "Click for rudder:On";
+ }
+
}
@@ -5498,6 +5510,22 @@ private void Slider_CV2_freq_ValueChanged(object sender, RoutedPropertyChangedEv
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.CV_freq_2 = (Byte)e.NewValue;
label_CV2_freq.Content = "Effect Frequency:" + dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.CV_freq_2 + "Hz";
}
+
+ private void btn_rudder_Click(object sender, RoutedEventArgs e)
+ {
+ if (Plugin.Rudder_status)
+ {
+ Plugin.Rudder_enable_flag = true;
+ Plugin.Rudder_status = false;
+ btn_rudder.Content = "Click for rudder:On";
+ }
+ else
+ {
+ Plugin.Rudder_enable_flag = true;
+ Plugin.Rudder_status = true;
+ btn_rudder.Content = "Click for rudder:Off";
+ }
+ }
}
}