mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat: add Steam Controller support with hot-switchable G29/Steam selector
This commit is contained in:
1 parent
d5dc1de504
commit
95ad271232
11 files changed
+1979
-81
No files matched your search
+263
-25
@@ -1,4 +1,5 @@
|
||||
use crate::config::AppConfig;
|
||||
use crate::controller::{ControlSource, SteamControllerState};
|
||||
use crate::dome_projection::ProjectionMode;
|
||||
use crate::dvr::{DvrContainer, DvrMode};
|
||||
use crate::engine::{
|
||||
@@ -70,6 +71,8 @@ pub struct SteamFrameGpuiApp {
|
||||
nomad_status: SubsystemStatus,
|
||||
telem_status: SubsystemStatus,
|
||||
g29_status: SubsystemStatus,
|
||||
controller_status: SubsystemStatus,
|
||||
active_control_source: ControlSource,
|
||||
dvr_status: SubsystemStatus,
|
||||
dvr_recording: bool,
|
||||
dvr_elapsed_secs: u64,
|
||||
@@ -81,6 +84,8 @@ pub struct SteamFrameGpuiApp {
|
||||
latest_pose: HeadPoseSample,
|
||||
latest_telem: TelemetryState,
|
||||
latest_g29: G29State,
|
||||
latest_controller: SteamControllerState,
|
||||
control_switch_error: String,
|
||||
log_entries: Vec<LogEntry>,
|
||||
log_err_count: usize,
|
||||
log_warn_count: usize,
|
||||
@@ -111,6 +116,7 @@ impl SteamFrameGpuiApp {
|
||||
) -> Self {
|
||||
let log_revision = log_buffer.lock().revision.clone();
|
||||
let target_port_buf = cfg.nomad_port.to_string();
|
||||
let initial_control_source = ControlSource::from_str(&cfg.control_source);
|
||||
|
||||
Self {
|
||||
cfg,
|
||||
@@ -130,6 +136,8 @@ impl SteamFrameGpuiApp {
|
||||
nomad_status: SubsystemStatus::Disabled,
|
||||
telem_status: SubsystemStatus::Disabled,
|
||||
g29_status: SubsystemStatus::Disabled,
|
||||
controller_status: SubsystemStatus::Disabled,
|
||||
active_control_source: initial_control_source,
|
||||
dvr_status: SubsystemStatus::Stopped,
|
||||
dvr_recording: false,
|
||||
dvr_elapsed_secs: 0,
|
||||
@@ -141,6 +149,8 @@ impl SteamFrameGpuiApp {
|
||||
latest_pose: HeadPoseSample::default(),
|
||||
latest_telem: TelemetryState::default(),
|
||||
latest_g29: G29State::default(),
|
||||
latest_controller: SteamControllerState::default(),
|
||||
control_switch_error: String::new(),
|
||||
log_entries: Vec::new(),
|
||||
log_err_count: 0,
|
||||
log_warn_count: 0,
|
||||
@@ -188,6 +198,14 @@ impl SteamFrameGpuiApp {
|
||||
self.g29_status = mon.g29_status.clone();
|
||||
changed = true;
|
||||
}
|
||||
if self.controller_status != mon.controller_status {
|
||||
self.controller_status = mon.controller_status.clone();
|
||||
changed = true;
|
||||
}
|
||||
if self.active_control_source != mon.active_control_source {
|
||||
self.active_control_source = mon.active_control_source;
|
||||
changed = true;
|
||||
}
|
||||
if self.dvr_recording != mon.dvr_recording
|
||||
|| self.dvr_elapsed_secs != mon.dvr_elapsed_secs
|
||||
|| self.dvr_status != mon.dvr_status
|
||||
@@ -217,6 +235,18 @@ impl SteamFrameGpuiApp {
|
||||
}
|
||||
self.latest_g29 = mon.latest_g29.clone();
|
||||
|
||||
if self.latest_controller.connected != mon.latest_controller.connected
|
||||
|| self.latest_controller.armed != mon.latest_controller.armed
|
||||
|| self.latest_controller.gear != mon.latest_controller.gear
|
||||
|| self.latest_controller.throttle_pct != mon.latest_controller.throttle_pct
|
||||
|| self.latest_controller.brake_pct != mon.latest_controller.brake_pct
|
||||
|| (self.latest_controller.steering_norm - mon.latest_controller.steering_norm).abs()
|
||||
> 0.02
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
self.latest_controller = mon.latest_controller.clone();
|
||||
|
||||
// Ne cloner et décoder la trame QUE si l'onglet Cockpit est actif !
|
||||
let frame_data: Option<(u32, u32, Vec<u8>)> = if self.active_tab == ActiveTab::Cockpit
|
||||
&& mon.preview_frame_seq != self.last_frame_seq
|
||||
@@ -667,6 +697,44 @@ impl SteamFrameGpuiApp {
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.id("toggle_ctrl_source_quick")
|
||||
.px_2()
|
||||
.py_0p5()
|
||||
.bg(if self.active_control_source == ControlSource::SteamController {
|
||||
rgb(0x132738)
|
||||
} else {
|
||||
rgb(COLOR_SURFACE_ELEVATED)
|
||||
})
|
||||
.border_1()
|
||||
.border_color(if self.active_control_source == ControlSource::SteamController {
|
||||
rgb(COLOR_CYAN)
|
||||
} else {
|
||||
rgb(COLOR_ORANGE)
|
||||
})
|
||||
.rounded_md()
|
||||
.text_xs()
|
||||
.font_weight(gpui::FontWeight::SEMIBOLD)
|
||||
.text_color(if self.active_control_source == ControlSource::SteamController {
|
||||
rgb(COLOR_CYAN)
|
||||
} else {
|
||||
rgb(COLOR_ORANGE)
|
||||
})
|
||||
.cursor_pointer()
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
let next = match this.active_control_source {
|
||||
ControlSource::G29 => ControlSource::SteamController,
|
||||
ControlSource::SteamController => ControlSource::G29,
|
||||
};
|
||||
this.switch_control_source(next);
|
||||
cx.notify();
|
||||
}))
|
||||
.child(match self.active_control_source {
|
||||
ControlSource::G29 => "🏎️ G29",
|
||||
ControlSource::SteamController => "🎮 Steam",
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.id("toggle_vr_quick")
|
||||
@@ -765,6 +833,19 @@ impl SteamFrameGpuiApp {
|
||||
)
|
||||
}
|
||||
|
||||
fn switch_control_source(&mut self, target: ControlSource) {
|
||||
match self.controls.set_control_source(target) {
|
||||
Ok(()) => {
|
||||
self.active_control_source = target;
|
||||
self.cfg.control_source = target.as_str().to_string();
|
||||
self.control_switch_error.clear();
|
||||
}
|
||||
Err(msg) => {
|
||||
self.control_switch_error = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_nav_tab(&self, label: &str, tab: ActiveTab, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let is_active = self.active_tab == tab;
|
||||
let tab_id = match tab {
|
||||
@@ -1542,6 +1623,131 @@ impl SteamFrameGpuiApp {
|
||||
),
|
||||
),
|
||||
))
|
||||
// 3.2b Carte Contrôleur de Conduite (Volant G29 / Steam Controller)
|
||||
.child(self.render_settings_card(
|
||||
"🎮 2b. Contrôleur de Conduite (Volant G29 / Steam Controller)",
|
||||
COLOR_GREEN,
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_3()
|
||||
.child(self.render_setting_row(
|
||||
"Source Active (bascule à chaud)",
|
||||
div()
|
||||
.flex()
|
||||
.flex_wrap()
|
||||
.gap_2()
|
||||
.child(self.render_selectable_pill(
|
||||
"pill_ctrl_g29",
|
||||
"🏎️ Volant Logitech G29",
|
||||
self.active_control_source == ControlSource::G29,
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.switch_control_source(ControlSource::G29);
|
||||
cx.notify();
|
||||
}),
|
||||
))
|
||||
.child(self.render_selectable_pill(
|
||||
"pill_ctrl_steam",
|
||||
"🎮 Steam Controller (Boîte séq.)",
|
||||
self.active_control_source == ControlSource::SteamController,
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.switch_control_source(
|
||||
ControlSource::SteamController,
|
||||
);
|
||||
cx.notify();
|
||||
}),
|
||||
)),
|
||||
))
|
||||
.when(!self.control_switch_error.is_empty(), |d| {
|
||||
d.child(
|
||||
div()
|
||||
.px_2p5()
|
||||
.py_1()
|
||||
.rounded_md()
|
||||
.bg(rgb(0x2a1215))
|
||||
.border_1()
|
||||
.border_color(rgb(COLOR_RED))
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_RED))
|
||||
.child(format!("⚠️ {}", self.control_switch_error)),
|
||||
)
|
||||
})
|
||||
.child(self.render_setting_row(
|
||||
"État Steam Controller",
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(if self.latest_controller.connected {
|
||||
rgb(COLOR_GREEN)
|
||||
} else {
|
||||
rgb(COLOR_TEXT_MUTED)
|
||||
})
|
||||
.child(if self.latest_controller.connected {
|
||||
format!(
|
||||
"● {} ({}) — [{}] {} • Gaz {}% • Frn {}% • Dir {:+.0}%",
|
||||
self.latest_controller.device_name,
|
||||
self.latest_controller.device_path,
|
||||
self.latest_controller.gear_label(),
|
||||
if self.latest_controller.armed {
|
||||
"ARMED"
|
||||
} else {
|
||||
"SAFE"
|
||||
},
|
||||
self.latest_controller.throttle_pct,
|
||||
self.latest_controller.brake_pct,
|
||||
self.latest_controller.steering_norm * 100.0
|
||||
)
|
||||
} else {
|
||||
"○ Non détecté (branchez le dongle ou allumez la manette)"
|
||||
.to_string()
|
||||
}),
|
||||
))
|
||||
.child(self.render_setting_row(
|
||||
"Sens Direction Steam Controller",
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(self.render_selectable_pill(
|
||||
"pill_sc_steer_normal",
|
||||
"Normal (identique G29)",
|
||||
!self.cfg.controller_invert_steering,
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.cfg.controller_invert_steering = false;
|
||||
cx.notify();
|
||||
}),
|
||||
))
|
||||
.child(self.render_selectable_pill(
|
||||
"pill_sc_steer_inv",
|
||||
"Inversée",
|
||||
self.cfg.controller_invert_steering,
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.cfg.controller_invert_steering = true;
|
||||
cx.notify();
|
||||
}),
|
||||
))
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||||
.child(format!(
|
||||
"(Expo {:.2} • Deadzone {:.2})",
|
||||
self.cfg.controller_expo,
|
||||
self.cfg.controller_deadzone
|
||||
)),
|
||||
),
|
||||
))
|
||||
.child(
|
||||
div()
|
||||
.p_2()
|
||||
.rounded_md()
|
||||
.bg(rgb(COLOR_BG_DARK))
|
||||
.border_1()
|
||||
.border_color(rgb(COLOR_BORDER_SUBTLE))
|
||||
.text_xs()
|
||||
.text_color(rgb(COLOR_TEXT_MUTED))
|
||||
.child("Stick G : Direction | R2 : Gaz | L2 : Frein | RB/LB ou R4/L4 : Boîte R-N-1-2-3 | Menu : Armer (au N) | A : Tare | B : DVR | Y : OSD | X : Proj VR | D-Pad : Trim"),
|
||||
),
|
||||
))
|
||||
// 3.3 Carte Projection VR Steam Frame & Optique
|
||||
.child(self.render_settings_card(
|
||||
"🥽 3. Projection VR & Correction Optique 140°",
|
||||
@@ -2072,31 +2278,63 @@ impl SteamFrameGpuiApp {
|
||||
&format!("Cap : {:.0}°", self.latest_telem.drone_heading_deg),
|
||||
COLOR_CYAN,
|
||||
))
|
||||
.child(self.render_stat_box(
|
||||
"🎮 VOLANT G29",
|
||||
&if !self.latest_g29.is_live() {
|
||||
"HORS LIGNE".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"[{}] {}",
|
||||
self.latest_g29.gear_label(),
|
||||
if self.latest_g29.armed { "ARMED" } else { "SAFE" }
|
||||
)
|
||||
},
|
||||
&format!(
|
||||
"Gaz {}% | Frn {}% | FFB {}%",
|
||||
self.latest_g29.throttle_pct,
|
||||
self.latest_g29.brake_pct,
|
||||
self.latest_g29.ffb_pct
|
||||
),
|
||||
if !self.latest_g29.is_live() {
|
||||
COLOR_TEXT_MUTED
|
||||
} else if self.latest_g29.armed {
|
||||
COLOR_GREEN
|
||||
} else {
|
||||
COLOR_ORANGE
|
||||
},
|
||||
)),
|
||||
.child(if self.active_control_source == ControlSource::SteamController {
|
||||
self.render_stat_box(
|
||||
"🎮 STEAM CONTROLLER",
|
||||
&if !self.latest_controller.connected {
|
||||
"NON DÉTECTÉ".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"[{}] {}",
|
||||
self.latest_controller.gear_label(),
|
||||
if self.latest_controller.armed {
|
||||
"ARMED"
|
||||
} else {
|
||||
"SAFE"
|
||||
}
|
||||
)
|
||||
},
|
||||
&format!(
|
||||
"Gaz {}% | Frn {}% | Dir {:+.0}%",
|
||||
self.latest_controller.throttle_pct,
|
||||
self.latest_controller.brake_pct,
|
||||
self.latest_controller.steering_norm * 100.0
|
||||
),
|
||||
if !self.latest_controller.connected {
|
||||
COLOR_TEXT_MUTED
|
||||
} else if self.latest_controller.armed {
|
||||
COLOR_GREEN
|
||||
} else {
|
||||
COLOR_ORANGE
|
||||
},
|
||||
)
|
||||
} else {
|
||||
self.render_stat_box(
|
||||
"🏎️ VOLANT G29",
|
||||
&if !self.latest_g29.is_live() {
|
||||
"HORS LIGNE".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"[{}] {}",
|
||||
self.latest_g29.gear_label(),
|
||||
if self.latest_g29.armed { "ARMED" } else { "SAFE" }
|
||||
)
|
||||
},
|
||||
&format!(
|
||||
"Gaz {}% | Frn {}% | FFB {}%",
|
||||
self.latest_g29.throttle_pct,
|
||||
self.latest_g29.brake_pct,
|
||||
self.latest_g29.ffb_pct
|
||||
),
|
||||
if !self.latest_g29.is_live() {
|
||||
COLOR_TEXT_MUTED
|
||||
} else if self.latest_g29.armed {
|
||||
COLOR_GREEN
|
||||
} else {
|
||||
COLOR_ORANGE
|
||||
},
|
||||
)
|
||||
}),
|
||||
)
|
||||
// Double Panneau : Suivi de Tête & Radio
|
||||
.child(
|
||||
|
||||
Reference in new issue
Block a user