feat: add Steam Controller support with hot-switchable G29/Steam selector

This commit is contained in:
bleack committed 2026-11-21 02:18:22 +01:00
1 parent d5dc1de504
commit 95ad271232
11 files changed
+1979 -81

No files matched your search

+120
View File
@@ -1,4 +1,5 @@
use crate::config::AppConfig;
use crate::controller::ControlSource;
use crate::dome_projection::ProjectionMode;
use crate::dvr::{DvrContainer, DvrMode};
use crate::engine::{EngineControlHandle, FpvEngineController, LiveOpticalParams, RuntimeMonitor, SubsystemStatus};
@@ -24,6 +25,7 @@ pub struct SteamFrameGuiApp {
auto_scroll_logs: bool,
video_texture: Option<TextureHandle>,
last_displayed_frame_seq: u64,
control_switch_error: String,
}
impl SteamFrameGuiApp {
@@ -51,6 +53,7 @@ impl SteamFrameGuiApp {
auto_scroll_logs: true,
video_texture: None,
last_displayed_frame_seq: 0,
control_switch_error: String::new(),
}
}
@@ -283,6 +286,10 @@ impl eframe::App for SteamFrameGuiApp {
xr_status,
nomad_status,
telem_status,
g29_status,
controller_status,
active_ctrl_source,
latest_ctrl,
dvr_status,
dvr_recording,
dvr_secs,
@@ -318,6 +325,10 @@ impl eframe::App for SteamFrameGuiApp {
mon.openxr_status.clone(),
mon.nomad_wifi_status.clone(),
mon.telemetry_status.clone(),
mon.g29_status.clone(),
mon.controller_status.clone(),
mon.active_control_source,
mon.latest_controller.clone(),
mon.dvr_status.clone(),
mon.dvr_recording,
mon.dvr_elapsed_secs,
@@ -488,6 +499,11 @@ impl eframe::App for SteamFrameGuiApp {
Self::status_badge(ui, "VRX Radxa Zero 3W", &usb_status);
Self::status_badge(ui, "Casque OpenXR", &xr_status);
Self::status_badge(ui, "Wi-Fi Nomad ELRS", &nomad_status);
if active_ctrl_source == ControlSource::SteamController {
Self::status_badge(ui, "Steam Controller", &controller_status);
} else {
Self::status_badge(ui, "Volant G29", &g29_status);
}
Self::status_badge(ui, "Télémétrie OSD", &telem_status);
Self::status_badge(ui, "DVR Vidéo", &dvr_status);
});
@@ -854,6 +870,11 @@ impl eframe::App for SteamFrameGuiApp {
egui::ComboBox::from_id_salt("ht_proto_combo")
.selected_text(NomadProtocol::from_str(&self.cfg.ht_protocol).label())
.show_ui(ui, |ui| {
ui.selectable_value(
&mut self.cfg.ht_protocol,
"g29".to_string(),
"G29 Hub unifié ($HT - UDP 14552)",
);
ui.selectable_value(
&mut self.cfg.ht_protocol,
"msp".to_string(),
@@ -902,6 +923,105 @@ impl eframe::App for SteamFrameGuiApp {
ui.add_space(8.0);
// --- Section 2b : Contrôleur de Conduite (Volant G29 / Steam Controller) ---
egui::CollapsingHeader::new(
RichText::new("🎮 2b. Contrôleur de Conduite (Volant G29 / Steam Controller)")
.strong(),
)
.default_open(true)
.show(ui, |ui| {
ui.horizontal(|ui| {
ui.label(RichText::new("Source active :").strong());
if ui
.selectable_label(
active_ctrl_source == ControlSource::G29,
"🏎️ Volant G29",
)
.clicked()
{
match self.controls.set_control_source(ControlSource::G29) {
Ok(()) => {
self.cfg.control_source = "g29".to_string();
self.control_switch_error.clear();
}
Err(msg) => self.control_switch_error = msg,
}
}
if ui
.selectable_label(
active_ctrl_source == ControlSource::SteamController,
"🎮 Steam Controller",
)
.clicked()
{
match self
.controls
.set_control_source(ControlSource::SteamController)
{
Ok(()) => {
self.cfg.control_source = "steam".to_string();
self.control_switch_error.clear();
}
Err(msg) => self.control_switch_error = msg,
}
}
});
if !self.control_switch_error.is_empty() {
ui.colored_label(
Color32::from_rgb(255, 85, 85),
format!("⚠ {}", self.control_switch_error),
);
}
ui.add_space(4.0);
if latest_ctrl.connected {
ui.colored_label(
Color32::from_rgb(80, 235, 130),
format!(
"● {} ({}) — [{}] {} | Gaz {}% | Frn {}% | Dir {:+.0}%",
latest_ctrl.device_name,
latest_ctrl.device_path,
latest_ctrl.gear_label(),
if latest_ctrl.armed { "ARMED" } else { "SAFE" },
latest_ctrl.throttle_pct,
latest_ctrl.brake_pct,
latest_ctrl.steering_norm * 100.0
),
);
} else {
ui.colored_label(
Color32::GRAY,
"○ Steam Controller non détecté (dongle / USB)",
);
}
ui.add_space(4.0);
egui::Grid::new("ctrl_cfg_grid")
.num_columns(2)
.spacing([8.0, 6.0])
.show(ui, |ui| {
ui.label("Expo direction SC :");
ui.add(egui::Slider::new(&mut self.cfg.controller_expo, 0.0..=0.8));
ui.end_row();
ui.label("Zone morte stick :");
ui.add(egui::Slider::new(
&mut self.cfg.controller_deadzone,
0.0..=0.4,
));
ui.end_row();
ui.label("Inverser direction :");
ui.checkbox(&mut self.cfg.controller_invert_steering, "Inversée");
ui.end_row();
});
ui.small("Stick G: Dir | R2: Gaz | L2: Frein | RB/LB ou R4/L4: Boîte R/N/1/2/3 | Menu: Armer (au N)");
});
ui.add_space(8.0);
// --- Section 3 : Télémétrie (Optionnelle ON/OFF) & Projection VR ---
egui::CollapsingHeader::new(
RichText::new("🥽 3. Projection VR 140° & Télémétrie (Optionnelle)")