Skip to content

Commit

Permalink
Plugin rudder function improvement
Browse files Browse the repository at this point in the history
1. Add property of rudder status
2. change rudder checkbox to button
3. Add simhub-action for rudder
  • Loading branch information
tcfshcrw committed Aug 8, 2024
1 parent 3c1e7c1 commit 854c9e0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
15 changes: 12 additions & 3 deletions SimHubPlugin/DataPluginDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}

Expand Down Expand Up @@ -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);




Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions SimHubPlugin/SettingsControlDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,12 @@
<styles:SHToggleButton x:Name="dump_pedal_response_to_file" Content="" Checked="dump_pedal_response_to_file_checked" Unchecked="dump_pedal_response_to_file_unchecked" IsChecked="False" FontSize="10" Width="35" Height="15" HorizontalAlignment="Left" FontFamily="Arial" ToolTip="Dump pedal realtime status to file" RenderTransformOrigin="0.5,0.5" Margin="-10,0,0,0" />
<Label Content="Dump Pedal Resonse" Height="20" Width="130" Padding="0,0,0,0" VerticalContentAlignment="Center" FontFamily="Arial" HorizontalAlignment="Left" FontSize="10" Margin="4,0,0,0"/>
</StackPanel>
<StackPanel Height="20" Width="160" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,4,0,0">
<styles:SHToggleButton x:Name="CheckBox_rudder" Content="" Checked="CheckBox_rudder_Checked" Unchecked="CheckBox_rudder_Unchecked" IsChecked="False" FontSize="10" Width="35" Height="15" HorizontalAlignment="Left" FontFamily="Arial" ToolTip="Combie Brk and Acc into 1 axis Rz, use as Rudder" RenderTransformOrigin="0.5,0.5" Margin="-10,0,0,0" />
<Label Content="Rudder" Height="20" Width="130" Padding="0,0,0,0" VerticalContentAlignment="Center" FontFamily="Arial" HorizontalAlignment="Left" FontSize="10" Margin="4,0,0,0"/>
</StackPanel>
<StackPanel Height="20" Width="160" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,4,0,0">
<styles:SHToggleButton x:Name="CheckBox_RTSDTR" Content="" Checked="CheckBox_RTSDTR_Checked" Unchecked="CheckBox_RTSDTR_Unchecked" IsChecked="False" FontSize="10" Width="35" Height="15" HorizontalAlignment="Left" FontFamily="Arial" ToolTip="The option is for S3" RenderTransformOrigin="0.5,0.5" Margin="-10,0,0,0" />
<Label Content="RTS/DTR false" Height="20" Width="130" Padding="0,0,0,0" VerticalContentAlignment="Center" FontFamily="Arial" HorizontalAlignment="Left" FontSize="10" Margin="4,0,0,0"/>
</StackPanel>
<styles:SHButtonPrimary x:Name="btn_rudder" Click="btn_rudder_Click" Width="160" Height="28" Content="Rudder" Margin="0,4,0,0" HorizontalAlignment="Center" />

<styles:SHButtonPrimary x:Name="button_pedal_position_reset" Click="ResetPedalPosition_click" Width="160" Height="28" Content="Reset pedal position" Margin="0,4,0,0" HorizontalAlignment="Center" />
<styles:SHButtonPrimary x:Name="button_pedal_restart" Click="RestartPedal_click" Width="160" Content="Restart Pedal" Height="28" Margin="0,4,0,0" HorizontalAlignment="Center" />
<styles:SHButtonPrimary x:Name="btn_system_id" Click="StartSystemIdentification_click" Width="160" RenderTransformOrigin="0.522,1.216" Height="28" Content="System identification" Margin="0,4,0,0" HorizontalAlignment="Center" />
Expand Down
28 changes: 28 additions & 0 deletions SimHubPlugin/SettingsControlDemo.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

}


Expand Down Expand Up @@ -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";
}
}
}

}

0 comments on commit 854c9e0

Please sign in to comment.