feat(steamframe-gaming): add --vr-only native mode, OpenXR controllers, minimalist VR menu & Gaming Mode launcher

This commit is contained in:
bleack committed 2026-11-24 19:15:22 +01:00
1 parent 0823a9e682
commit 128afc2810
12 files changed
+793 -124

No files matched your search

+5 -1
View File
@@ -38,7 +38,10 @@ Application graphique et VR native **Linux / SteamOS (ARM64 & x86_64)** en **Rus
- **`⚙️ Réglages`** : Configuration VRX/UVC, presets réseau Nomad, édition IP/Port, **Mock Manuel Pan/Tilt/Roll** (envoi unitaire ou continu 50 Hz), projection VR & optique temps réel, vitesses CRSF et DVR. - **`⚙️ Réglages`** : Configuration VRX/UVC, presets réseau Nomad, édition IP/Port, **Mock Manuel Pan/Tilt/Roll** (envoi unitaire ou continu 50 Hz), projection VR & optique temps réel, vitesses CRSF et DVR.
- **`📊 Télémétrie`** : Jauges CRSF Pan/Tilt/Roll et métriques de vol/lien radio. - **`📊 Télémétrie`** : Jauges CRSF Pan/Tilt/Roll et métriques de vol/lien radio.
- **`📜 Logs`** : Console filtrable (`Tous`, `Warn / Erreurs`, `Erreurs seules`) synchronisée sans verrou avec `steamframe_fpv.log`. - **`📜 Logs`** : Console filtrable (`Tous`, `Warn / Erreurs`, `Erreurs seules`) synchronisée sans verrou avec `steamframe_fpv.log`.
2. **Menu Rapide VR dans le casque (OpenXR)** : Ouverture via `Options`/`L3` (G29) ou `View`/`Select` (Steam Controller), navigable au `D-Pad` sans quitter l'immersion VR (Source, Tare HT, Suivi tête, OSD, Projection, Distance écran, `k1`, FOV, DVR, 3e vitesse, Vibrations). 2. **Menu Minimaliste VR dans le casque (OpenXR / Mode Gaming `--vr-only`)** :
- Lancez `./launch_vr.sh` (ou ajoutez `steamframe-fpv-vr.desktop` en jeu non-Steam en Mode Gaming) pour démarrer directement en immersion OpenXR sans fenêtre 2D.
- Ouverture via `Options`/`L3` (G29), `View`/`Select` (Steam Controller) ou `Menu`/`Y` (contrôleurs VR OpenXR natifs).
- Menu principal compact (`Source`, `Tare HT`, `Projection`, `Distance`, `OSD`, `DVR`, `Avancé >`, `Quitter l'App` avec double confirmation) + sous-menu Avancé (`Suivi tête`, `k1`, `FOV`, `Plafond 3e vitesse`, `Vibrations SC`, `Canal Radxa 5.8 GHz`).
3. **Mode Ligne de Commande (`--no-gui`)** : Exécution sans fenêtre graphique pour bancs de test ou usage embarqué. 3. **Mode Ligne de Commande (`--no-gui`)** : Exécution sans fenêtre graphique pour bancs de test ou usage embarqué.
--- ---
@@ -95,6 +98,7 @@ Le script [launch.sh](launch.sh) prépare `libxkbcommon-x11.so` si besoin, compi
| Option | Défaut | Description | | Option | Défaut | Description |
| --- | --- | --- | | --- | --- | --- |
| `--vr-only` | `false` | Mode VR natif direct sans fenêtre 2D GPUI (Mode Gaming SteamOS) |
| `--no-gui` | `false` | Lance uniquement le moteur sans IHM | | `--no-gui` | `false` | Lance uniquement le moteur sans IHM |
| `--headless` | `false` | Désactive OpenXR (mode Bureau / test) | | `--headless` | `false` | Désactive OpenXR (mode Bureau / test) |
| `--usb-video-mode` | `rndis` | Acquisition vidéo : `rndis` ou `uvc` | | `--usb-video-mode` | `rndis` | Acquisition vidéo : `rndis` ou `uvc` |
Executable
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# SteamFrame FPV — Lanceur VR Natif (Mode Gaming SteamOS / OpenXR Direct sans fenêtre 2D)
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$DIR"
# Bibliothèques locales éventuelles
if [ -d "$HOME/.local/lib" ]; then
export LD_LIBRARY_PATH="$HOME/.local/lib:${LD_LIBRARY_PATH:-}"
fi
# Compiler en Release si le binaire n'est pas encore présent
if [ ! -f "$DIR/target/release/steamframe-fpv" ]; then
echo "Compilation initiale de SteamFrame FPV en mode Release..."
cargo build --release
fi
exec "$DIR/target/release/steamframe-fpv" --vr-only "$@"
+5 -1
View File
@@ -1,4 +1,8 @@
# Règle Udev pour le récepteur Eachine Sphere Link (Radxa Zero 3W / Rockchip RV1106 / RNDIS) # Règle Udev pour le récepteur Eachine Sphere Link (Radxa Zero 3W / Rockchip RV1106 / RNDIS)
# Déclenche l'attribution de l'IP 192.168.1.10/24 dès que le câble USB-C est branché sur le Steam Frame ou PC # Déclenche l'attribution de l'IP 192.168.1.10/24 dès que le câble USB-C est branché sur le Steam Frame ou PC
ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*|enx*", ATTRS{idVendor}=="1d6b|2207|0525", RUN+="/usr/bin/ip addr add 192.168.1.10/24 dev %k", RUN+="/usr/bin/ip link set dev %k up" ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*|enx*", ATTRS{idVendor}=="1d6b|2207|0525", RUN+="/usr/bin/ip addr add 192.168.1.10/24 dev %k", RUN+="/usr/bin/ip link set dev %k up"
# Accès HIDRAW non-root (uaccess) pour le Steam Controller (Ibex 28de:1302..1305) en Mode Gaming SteamOS
# Permet la lecture directe des rapports 0x42 et les retours haptiques 0x80 sans sudo ni conflit Lizard Mode
KERNEL=="hidraw*", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="1302|1303|1304|1305", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="1302|1303|1304|1305", MODE="0660", TAG+="uaccess"
+12 -4
View File
@@ -25,12 +25,20 @@ if [ "$ARCH" = "aarch64" ]; then
export RUSTFLAGS="-C target-cpu=native -C opt-level=3" export RUSTFLAGS="-C target-cpu=native -C opt-level=3"
cargo build --release cargo build --release
echo "[3/3] Installation locale du lanceur .desktop..." echo "[3/3] Installation locale des lanceurs .desktop (Bureau GPUI + Mode VR Gaming)..."
mkdir -p ~/.local/share/applications mkdir -p ~/.local/share/applications
cp steamframe-fpv.desktop ~/.local/share/applications/ chmod +x "$DIR/launch.sh" "$DIR/launch_vr.sh"
sed -i "s|/home/deck/projects/steamframe_fpv|$DIR|g" ~/.local/share/applications/steamframe-fpv.desktop for desktop_file in steamframe-fpv.desktop steamframe-fpv-vr.desktop; do
cp "$desktop_file" ~/.local/share/applications/
sed -i -E \
-e "s|^Exec=.*/(launch(_vr)?\.sh)|Exec=$DIR/\1|g" \
-e "s|^Path=.*|Path=$DIR|g" \
-e "s|^Icon=.*/assets/|Icon=$DIR/assets/|g" \
"$HOME/.local/share/applications/$desktop_file"
done
echo "=== SUCCÈS : Binaire compilé dans $DIR/target/release/steamframe-fpv ===" echo "=== SUCCÈS : Binaire compilé dans $DIR/target/release/steamframe-fpv ==="
echo " Mode Gaming : ajoutez 'SteamFrame FPV (Mode VR)' (launch_vr.sh) en jeu non-Steam."
else else
echo "[!] Exécution sur hôte ${ARCH} (Ubuntu / PC de développement)." echo "[!] Exécution sur hôte ${ARCH} (Ubuntu / PC de développement)."
echo "[2/3] Compilation Release hôte standard..." echo "[2/3] Compilation Release hôte standard..."
@@ -39,7 +47,7 @@ else
echo "[3/3] Création de l'archive de déploiement pour le Steam Frame..." echo "[3/3] Création de l'archive de déploiement pour le Steam Frame..."
mkdir -p dist mkdir -p dist
tar --exclude="target" --exclude=".git" -czf dist/steamframe-fpv-deploy.tar.gz \ tar --exclude="target" --exclude=".git" -czf dist/steamframe-fpv-deploy.tar.gz \
Cargo.toml Cargo.lock src scripts assets README.md launch.sh steamframe-fpv.desktop Cargo.toml Cargo.lock src scripts assets README.md launch.sh launch_vr.sh steamframe-fpv.desktop steamframe-fpv-vr.desktop
echo "=== SUCCÈS : Archive de déploiement créée dans $DIR/dist/steamframe-fpv-deploy.tar.gz ===" echo "=== SUCCÈS : Archive de déploiement créée dans $DIR/dist/steamframe-fpv-deploy.tar.gz ==="
echo "Pour déployer sur le casque, lancez : ./scripts/deploy_to_steamframe.sh [ip_steamframe]" echo "Pour déployer sur le casque, lancez : ./scripts/deploy_to_steamframe.sh [ip_steamframe]"
+1 -1
View File
@@ -23,7 +23,7 @@ echo "[2/5] Préparation du paquet de déploiement..."
echo "[3/5] Transfert des fichiers du projet sur le Steam Frame..." echo "[3/5] Transfert des fichiers du projet sur le Steam Frame..."
ssh "${TARGET_HOST}" "mkdir -p ~/projects/steamframe_fpv" ssh "${TARGET_HOST}" "mkdir -p ~/projects/steamframe_fpv"
scp dist/steamframe-fpv-deploy.tar.gz "${TARGET_HOST}:~/projects/steamframe_fpv/" scp dist/steamframe-fpv-deploy.tar.gz "${TARGET_HOST}:~/projects/steamframe_fpv/"
ssh "${TARGET_HOST}" "cd ~/projects/steamframe_fpv && tar -xzf steamframe-fpv-deploy.tar.gz && chmod +x scripts/*.sh launch.sh" ssh "${TARGET_HOST}" "cd ~/projects/steamframe_fpv && tar -xzf steamframe-fpv-deploy.tar.gz && chmod +x scripts/*.sh launch.sh launch_vr.sh"
echo "[4/5] Installation de la règle udev USB RNDIS (auto-attribution 192.168.1.10/24)..." echo "[4/5] Installation de la règle udev USB RNDIS (auto-attribution 192.168.1.10/24)..."
scp scripts/99-radxa-vrx-rndis.rules "${TARGET_HOST}:/tmp/" scp scripts/99-radxa-vrx-rndis.rules "${TARGET_HOST}:/tmp/"
+4
View File
@@ -184,6 +184,10 @@ pub struct AppConfig {
#[arg(long, default_value_t = false)] #[arg(long, default_value_t = false)]
pub no_gui: bool, pub no_gui: bool,
/// Mode VR natif direct sans fenêtre 2D GPUI (idéal pour le Mode Gaming SteamOS sur Steam Frame)
#[arg(long, default_value_t = false)]
pub vr_only: bool,
/// Chemin du fichier journal d'erreurs et de diagnostic /// Chemin du fichier journal d'erreurs et de diagnostic
#[arg(long, default_value = "steamframe_fpv.log")] #[arg(long, default_value = "steamframe_fpv.log")]
pub log_file: String, pub log_file: String,
+482 -54
View File
@@ -8,7 +8,7 @@ use crate::dvr::{DvrContainer, DvrMode, DvrRecorder};
use crate::g29_bridge::{G29BridgeReceiver, G29State}; use crate::g29_bridge::{G29BridgeReceiver, G29State};
use crate::nomad_elrs::{HeadPoseSample, NomadHeadTracker, NomadProtocol}; use crate::nomad_elrs::{HeadPoseSample, NomadHeadTracker, NomadProtocol};
use crate::telemetry_osd::{ use crate::telemetry_osd::{
OsdOverlay, TelemetryReceiver, TelemetryState, VrMenuRenderData, VR_MENU_ITEM_COUNT, OsdOverlay, TelemetryReceiver, TelemetryState, VrMenuPage, VrMenuRenderData,
}; };
use crate::video_usb::{UsbVideoReceiver, VideoLinkState}; use crate::video_usb::{UsbVideoReceiver, VideoLinkState};
use crate::vulkan_xr::VulkanXrContext; use crate::vulkan_xr::VulkanXrContext;
@@ -48,13 +48,33 @@ pub struct DvrConfig {
pub mode: DvrMode, pub mode: DvrMode,
} }
#[derive(Debug, Clone, Default)] const RADXA_WIFI_CHANNELS: &[u16] = &[36, 40, 44, 48, 149, 153, 157, 161, 165];
#[derive(Debug, Clone)]
struct VrMenuState { struct VrMenuState {
open: bool, open: bool,
page: VrMenuPage,
selected_idx: usize, selected_idx: usize,
wifi_channel: u16,
radxa_vrx_ip: String,
quit_confirm_until: Option<Instant>,
feedback: Option<(&'static str, bool, Instant)>, feedback: Option<(&'static str, bool, Instant)>,
} }
impl Default for VrMenuState {
fn default() -> Self {
Self {
open: false,
page: VrMenuPage::Main,
selected_idx: 0,
wifi_channel: 161,
radxa_vrx_ip: "192.168.1.1".to_string(),
quit_confirm_until: None,
feedback: None,
}
}
}
impl VrMenuState { impl VrMenuState {
fn set_feedback(&mut self, msg: &'static str, is_err: bool) { fn set_feedback(&mut self, msg: &'static str, is_err: bool) {
self.feedback = Some((msg, is_err, Instant::now() + Duration::from_millis(2000))); self.feedback = Some((msg, is_err, Instant::now() + Duration::from_millis(2000)));
@@ -66,6 +86,12 @@ impl VrMenuState {
_ => None, _ => None,
} }
} }
fn quit_confirm_pending(&self) -> bool {
self.quit_confirm_until
.map(|u| Instant::now() < u)
.unwrap_or(false)
}
} }
pub struct RuntimeMonitor { pub struct RuntimeMonitor {
@@ -151,6 +177,7 @@ pub struct EngineControlHandle {
dvr_recording_flag: Arc<AtomicBool>, dvr_recording_flag: Arc<AtomicBool>,
head_trim_deg: Arc<Mutex<(f32, f32)>>, head_trim_deg: Arc<Mutex<(f32, f32)>>,
preview_active_flag: Arc<AtomicBool>, preview_active_flag: Arc<AtomicBool>,
exit_requested_flag: Arc<AtomicBool>,
vr_menu_state: Arc<Mutex<VrMenuState>>, vr_menu_state: Arc<Mutex<VrMenuState>>,
} }
@@ -319,6 +346,15 @@ impl EngineControlHandle {
self.preview_active_flag.load(Ordering::Relaxed) self.preview_active_flag.load(Ordering::Relaxed)
} }
pub fn is_exit_requested(&self) -> bool {
self.exit_requested_flag.load(Ordering::Acquire)
}
pub fn request_exit(&self) {
self.exit_requested_flag.store(true, Ordering::Release);
log::info!("[Menu VR] Demande de fermeture propre de l'application.");
}
pub fn is_vr_menu_open(&self) -> bool { pub fn is_vr_menu_open(&self) -> bool {
self.vr_menu_state.lock().open self.vr_menu_state.lock().open
} }
@@ -326,6 +362,9 @@ impl EngineControlHandle {
pub fn toggle_vr_menu(&self) -> bool { pub fn toggle_vr_menu(&self) -> bool {
let mut st = self.vr_menu_state.lock(); let mut st = self.vr_menu_state.lock();
st.open = !st.open; st.open = !st.open;
st.page = VrMenuPage::Main;
st.selected_idx = 0;
st.quit_confirm_until = None;
if st.open { if st.open {
st.feedback = None; st.feedback = None;
} }
@@ -338,41 +377,72 @@ impl EngineControlHandle {
open open
} }
pub fn close_vr_menu(&self) { /// Retourne au menu principal si dans le sous-menu Avancé, sinon ferme le menu VR.
/// Retourne `true` si le menu reste ouvert, `false` s'il a été fermé.
pub fn vr_menu_back(&self) -> bool {
let mut st = self.vr_menu_state.lock(); let mut st = self.vr_menu_state.lock();
if st.open { if !st.open {
return false;
}
st.quit_confirm_until = None;
if st.page == VrMenuPage::Advanced {
st.page = VrMenuPage::Main;
st.selected_idx = 6;
st.feedback = None;
true
} else {
st.open = false; st.open = false;
log::info!("[Menu VR] Fermé"); log::info!("[Menu VR] Fermé");
false
} }
} }
pub fn close_vr_menu(&self) {
let _ = self.vr_menu_back();
}
pub fn vr_menu_move(&self, delta: isize) { pub fn vr_menu_move(&self, delta: isize) {
let mut st = self.vr_menu_state.lock(); let mut st = self.vr_menu_state.lock();
if !st.open { if !st.open {
return; return;
} }
let count = VR_MENU_ITEM_COUNT as isize; st.quit_confirm_until = None;
let count = st.page.item_count() as isize;
let next = ((st.selected_idx as isize + delta).rem_euclid(count)) as usize; let next = ((st.selected_idx as isize + delta).rem_euclid(count)) as usize;
st.selected_idx = next; st.selected_idx = next;
} }
pub fn vr_menu_activate(&self) { pub fn vr_menu_activate(&self) {
self.vr_menu_adjust(1); self.vr_menu_action(1, true);
} }
pub fn vr_menu_adjust(&self, delta: i32) { pub fn vr_menu_adjust(&self, delta: i32) {
let idx = { self.vr_menu_action(delta, false);
}
fn is_vehicle_armed_now(&self) -> bool {
let current = self.active_control_source();
let mon = self.monitor_ref.lock();
match current {
ControlSource::G29 => mon.latest_g29.is_live() && mon.latest_g29.armed,
ControlSource::SteamController => mon.latest_controller.armed,
}
}
fn vr_menu_action(&self, delta: i32, is_activate: bool) {
let (page, idx) = {
let st = self.vr_menu_state.lock(); let st = self.vr_menu_state.lock();
if !st.open { if !st.open {
return; return;
} }
st.selected_idx % VR_MENU_ITEM_COUNT (st.page, st.selected_idx % st.page.item_count())
}; };
let step: i32 = if delta >= 0 { 1 } else { -1 }; let step: i32 = if delta >= 0 { 1 } else { -1 };
match idx { match (page, idx) {
// --- PAGE PRINCIPALE MINIMALISTE ---
// 0: Source pilotage (G29 <-> Steam Controller) // 0: Source pilotage (G29 <-> Steam Controller)
0 => { (VrMenuPage::Main, 0) => {
let target = match self.active_control_source() { let target = match self.active_control_source() {
ControlSource::G29 => ControlSource::SteamController, ControlSource::G29 => ControlSource::SteamController,
ControlSource::SteamController => ControlSource::G29, ControlSource::SteamController => ControlSource::G29,
@@ -383,27 +453,12 @@ impl EngineControlHandle {
} }
} }
// 1: Centrer Vue HT (Tare) // 1: Centrer Vue HT (Tare)
1 => { (VrMenuPage::Main, 1) => {
self.request_recenter(); self.request_recenter();
self.vr_menu_state.lock().set_feedback("TARE HT OK", false); self.vr_menu_state.lock().set_feedback("TARE HT OK", false);
} }
// 2: Suivi Tête ON/OFF // 2: Mode Projection VR
2 => { (VrMenuPage::Main, 2) => {
let next = !self.head_tracking_enabled_flag.load(Ordering::Acquire);
self.set_head_tracking_enabled(next);
self.vr_menu_state
.lock()
.set_feedback(if next { "SUIVI HT: ON" } else { "SUIVI HT: OFF" }, false);
}
// 3: OSD Télémétrie ON/OFF
3 => {
let next = self.toggle_telemetry();
self.vr_menu_state
.lock()
.set_feedback(if next { "OSD: ON" } else { "OSD: OFF" }, false);
}
// 4: Mode Projection VR
4 => {
let mut opt = self.optical_params.lock(); let mut opt = self.optical_params.lock();
opt.projection_mode = match (opt.projection_mode, step > 0) { opt.projection_mode = match (opt.projection_mode, step > 0) {
(ProjectionMode::Dome140, true) | (ProjectionMode::FlatQuad, false) => { (ProjectionMode::Dome140, true) | (ProjectionMode::FlatQuad, false) => {
@@ -419,44 +474,166 @@ impl EngineControlHandle {
log::info!("[Menu VR] Mode de projection VR : {}", lbl); log::info!("[Menu VR] Mode de projection VR : {}", lbl);
self.vr_menu_state.lock().set_feedback("PROJECTION MAJ", false); self.vr_menu_state.lock().set_feedback("PROJECTION MAJ", false);
} }
// 5: Distance Écran Virtuel (0.8..=4.0 m) // 3: Distance Écran Virtuel (0.8..=4.0 m)
5 => { (VrMenuPage::Main, 3) => {
let mut opt = self.optical_params.lock(); let mut opt = self.optical_params.lock();
opt.screen_distance_m = opt.screen_distance_m =
((opt.screen_distance_m + step as f32 * 0.2) * 10.0).round() / 10.0; ((opt.screen_distance_m + step as f32 * 0.2) * 10.0).round() / 10.0;
opt.screen_distance_m = opt.screen_distance_m.clamp(0.8, 4.0); opt.screen_distance_m = opt.screen_distance_m.clamp(0.8, 4.0);
} }
// 6: Correction optique k1 (-0.50..=0.50) // 4: OSD Télémétrie ON/OFF
6 => { (VrMenuPage::Main, 4) => {
let mut opt = self.optical_params.lock(); let next = self.toggle_telemetry();
opt.lens_k1 = ((opt.lens_k1 + step as f32 * 0.02) * 100.0).round() / 100.0; self.vr_menu_state
opt.lens_k1 = opt.lens_k1.clamp(-0.50, 0.50); .lock()
.set_feedback(if next { "OSD: ON" } else { "OSD: OFF" }, false);
} }
// 7: FOV Caméra (70..=180 deg) // 5: Enregistreur DVR
7 => { (VrMenuPage::Main, 5) => {
let mut opt = self.optical_params.lock();
opt.camera_fov_deg = (opt.camera_fov_deg + step as f32 * 5.0).clamp(70.0, 180.0);
}
// 8: Enregistreur DVR
8 => {
let rec = self.toggle_dvr(); let rec = self.toggle_dvr();
self.vr_menu_state self.vr_menu_state
.lock() .lock()
.set_feedback(if rec { "DVR DEMARRE" } else { "DVR ARRETE" }, false); .set_feedback(if rec { "DVR DEMARRE" } else { "DVR ARRETE" }, false);
} }
// 9: Plafond 3ème vitesse CRSF // 6: Ouvrir le sous-menu Réglages Avancés
9 => { (VrMenuPage::Main, 6) => {
let mut st = self.vr_menu_state.lock();
st.page = VrMenuPage::Advanced;
st.selected_idx = 0;
st.quit_confirm_until = None;
st.feedback = None;
}
// 7: Quitter l'application (double confirmation, refusé si armé)
(VrMenuPage::Main, _) => {
if self.is_vehicle_armed_now() {
self.vr_menu_state
.lock()
.set_feedback("DESARMER D'ABORD!", true);
return;
}
let confirmed = {
let mut st = self.vr_menu_state.lock();
if st.quit_confirm_pending() {
st.open = false;
st.quit_confirm_until = None;
true
} else {
st.quit_confirm_until = Some(Instant::now() + Duration::from_secs(3));
st.set_feedback("REAPPUYER POUR QUITTER", true);
false
}
};
if confirmed {
self.request_exit();
}
}
// --- SOUS-MENU AVANCÉ ---
// 0: Retour menu principal
(VrMenuPage::Advanced, 0) => {
let mut st = self.vr_menu_state.lock();
st.page = VrMenuPage::Main;
st.selected_idx = 6;
st.feedback = None;
}
// 1: Suivi Tête ON/OFF
(VrMenuPage::Advanced, 1) => {
let next = !self.head_tracking_enabled_flag.load(Ordering::Acquire);
self.set_head_tracking_enabled(next);
self.vr_menu_state
.lock()
.set_feedback(if next { "SUIVI HT: ON" } else { "SUIVI HT: OFF" }, false);
}
// 2: Correction optique k1 (-0.50..=0.50)
(VrMenuPage::Advanced, 2) => {
let mut opt = self.optical_params.lock();
opt.lens_k1 = ((opt.lens_k1 + step as f32 * 0.02) * 100.0).round() / 100.0;
opt.lens_k1 = opt.lens_k1.clamp(-0.50, 0.50);
}
// 3: FOV Caméra (70..=180 deg)
(VrMenuPage::Advanced, 3) => {
let mut opt = self.optical_params.lock();
opt.camera_fov_deg = (opt.camera_fov_deg + step as f32 * 5.0).clamp(70.0, 180.0);
}
// 4: Plafond 3ème vitesse CRSF
(VrMenuPage::Advanced, 4) => {
let mut limits = *self.gear_speed_limits.lock(); let mut limits = *self.gear_speed_limits.lock();
limits.forward_max[2] = limits.forward_max[2] =
limits.forward_max[2].saturating_add_signed((step * 10) as i16); limits.forward_max[2].saturating_add_signed((step * 10) as i16);
self.set_gear_speed_limits(limits); self.set_gear_speed_limits(limits);
} }
// 10: Vibrations Steam Controller (0..=100%) // 5: Vibrations Steam Controller (0..=100%)
_ => { (VrMenuPage::Advanced, 5) => {
let cur = self.controller_vibration_pct.load(Ordering::Acquire) as i32; let cur = self.controller_vibration_pct.load(Ordering::Acquire) as i32;
let next = (cur + step * 10).clamp(0, 100) as u8; let next = (cur + step * 10).clamp(0, 100) as u8;
self.set_controller_vibration_pct(next); self.set_controller_vibration_pct(next);
} }
// 6: Canal 5.8 GHz Radxa (G/D sélectionne le canal, A/Croix applique par SSH sécurisé)
(VrMenuPage::Advanced, _) => {
if is_activate {
let (ch, ip_str) = {
let st = self.vr_menu_state.lock();
(st.wifi_channel, st.radxa_vrx_ip.clone())
};
if let Ok(ip) = ip_str.trim().parse::<std::net::IpAddr>() {
self.vr_menu_state
.lock()
.set_feedback("ENVOI CANAL SSH...", false);
let remote_cmd = format!(
"sed -i 's/^wifi_channel.*/wifi_channel = {ch}/' /etc/wifibroadcast.cfg 2>/dev/null || true; \
iw dev wlan0 set channel {ch} HT20 2>/dev/null || true"
);
let menu_ref = Arc::clone(&self.vr_menu_state);
thread::spawn(move || {
let res = std::process::Command::new("ssh")
.args([
"-o",
"BatchMode=yes",
"-o",
"ConnectTimeout=2",
"-o",
"StrictHostKeyChecking=accept-new",
"--",
&format!("root@{}", ip),
&remote_cmd,
])
.output();
match res {
Ok(out) if out.status.success() => {
log::info!("[Menu VR] Canal 5.8GHz {} appliqué sur Radxa {}", ch, ip);
menu_ref.lock().set_feedback("CANAL RADXA OK", false);
}
Ok(out) => {
log::warn!(
"[Menu VR] Échec SSH canal Radxa (exit={}): {}",
out.status,
String::from_utf8_lossy(&out.stderr).trim()
);
menu_ref.lock().set_feedback("ECHEC SSH RADXA", true);
}
Err(e) => {
log::error!("[Menu VR] Erreur SSH Radxa : {}", e);
menu_ref.lock().set_feedback("ERREUR SSH", true);
}
}
});
} else {
self.vr_menu_state
.lock()
.set_feedback("IP RADXA INVALIDE", true);
}
} else {
let mut st = self.vr_menu_state.lock();
let cur_pos = RADXA_WIFI_CHANNELS
.iter()
.position(|&c| c == st.wifi_channel)
.unwrap_or(RADXA_WIFI_CHANNELS.len() - 2);
let next_pos = ((cur_pos as isize + step as isize)
.rem_euclid(RADXA_WIFI_CHANNELS.len() as isize))
as usize;
st.wifi_channel = RADXA_WIFI_CHANNELS[next_pos];
st.set_feedback("A/CROIX POUR APPLIQUER", false);
}
}
} }
} }
@@ -465,13 +642,17 @@ impl EngineControlHandle {
if !st.open { if !st.open {
return None; return None;
} }
let page = st.page;
let selected_idx = st.selected_idx; let selected_idx = st.selected_idx;
let wifi_channel = st.wifi_channel;
let quit_confirm_pending = st.quit_confirm_pending();
let feedback_msg = st.active_feedback(); let feedback_msg = st.active_feedback();
drop(st); drop(st);
let opt = self.optical_params.lock().clone(); let opt = self.optical_params.lock().clone();
let limits = *self.gear_speed_limits.lock(); let limits = *self.gear_speed_limits.lock();
Some(VrMenuRenderData { Some(VrMenuRenderData {
page,
selected_idx, selected_idx,
control_source: self.active_control_source(), control_source: self.active_control_source(),
head_tracking_on: self.head_tracking_enabled_flag.load(Ordering::Relaxed), head_tracking_on: self.head_tracking_enabled_flag.load(Ordering::Relaxed),
@@ -483,6 +664,8 @@ impl EngineControlHandle {
dvr_recording: self.dvr_recording_flag.load(Ordering::Relaxed), dvr_recording: self.dvr_recording_flag.load(Ordering::Relaxed),
gear_3_max: limits.forward_max[2], gear_3_max: limits.forward_max[2],
vibration_pct: self.controller_vibration_pct.load(Ordering::Relaxed).min(100), vibration_pct: self.controller_vibration_pct.load(Ordering::Relaxed).min(100),
wifi_channel,
quit_confirm_pending,
feedback_msg, feedback_msg,
}) })
} }
@@ -504,6 +687,7 @@ pub struct FpvEngineController {
controller_rumble_test: Arc<AtomicBool>, controller_rumble_test: Arc<AtomicBool>,
gear_speed_limits: Arc<Mutex<GearSpeedLimits>>, gear_speed_limits: Arc<Mutex<GearSpeedLimits>>,
preview_active_flag: Arc<AtomicBool>, preview_active_flag: Arc<AtomicBool>,
exit_requested_flag: Arc<AtomicBool>,
vr_menu_state: Arc<Mutex<VrMenuState>>, vr_menu_state: Arc<Mutex<VrMenuState>>,
worker_handle: Option<JoinHandle<()>>, worker_handle: Option<JoinHandle<()>>,
} }
@@ -540,6 +724,7 @@ impl FpvEngineController {
controller_rumble_test: Arc::new(AtomicBool::new(false)), controller_rumble_test: Arc::new(AtomicBool::new(false)),
gear_speed_limits: Arc::new(Mutex::new(GearSpeedLimits::default())), gear_speed_limits: Arc::new(Mutex::new(GearSpeedLimits::default())),
preview_active_flag: Arc::new(AtomicBool::new(true)), preview_active_flag: Arc::new(AtomicBool::new(true)),
exit_requested_flag: Arc::new(AtomicBool::new(false)),
vr_menu_state: Arc::new(Mutex::new(VrMenuState::default())), vr_menu_state: Arc::new(Mutex::new(VrMenuState::default())),
worker_handle: None, worker_handle: None,
} }
@@ -561,6 +746,7 @@ impl FpvEngineController {
dvr_recording_flag: Arc::clone(&self.dvr_recording_flag), dvr_recording_flag: Arc::clone(&self.dvr_recording_flag),
head_trim_deg: Arc::clone(&self.head_trim_deg), head_trim_deg: Arc::clone(&self.head_trim_deg),
preview_active_flag: Arc::clone(&self.preview_active_flag), preview_active_flag: Arc::clone(&self.preview_active_flag),
exit_requested_flag: Arc::clone(&self.exit_requested_flag),
vr_menu_state: Arc::clone(&self.vr_menu_state), vr_menu_state: Arc::clone(&self.vr_menu_state),
} }
} }
@@ -641,6 +827,13 @@ impl FpvEngineController {
container: DvrContainer::from_str(&cfg.dvr_format), container: DvrContainer::from_str(&cfg.dvr_format),
mode: DvrMode::from_str(&cfg.dvr_mode), mode: DvrMode::from_str(&cfg.dvr_mode),
}; };
{
let mut menu = self.vr_menu_state.lock();
menu.wifi_channel = cfg.wifi_channel;
menu.radxa_vrx_ip = cfg.radxa_vrx_ip.clone();
menu.quit_confirm_until = None;
}
self.exit_requested_flag.store(false, Ordering::Relaxed);
{ {
let mut mon = self.monitor.lock(); let mut mon = self.monitor.lock();
@@ -1175,10 +1368,67 @@ fn run_engine_worker(
}; };
// 4. Tentative d'initialisation OpenXR sur le Steam Frame (sauf si mode VR désactivé / headless) // 4. Tentative d'initialisation OpenXR sur le Steam Frame (sauf si mode VR désactivé / headless)
let fallback_needed = if cfg.headless { let fallback_needed = if cfg.headless && !cfg.vr_only {
log::info!("[OpenXR] Mode VR désactivé (Mode Bureau léger actif)."); log::info!("[OpenXR] Mode VR désactivé (Mode Bureau léger actif).");
monitor.lock().openxr_status = SubsystemStatus::Disabled; monitor.lock().openxr_status = SubsystemStatus::Disabled;
true true
} else if cfg.vr_only {
// Mode Gaming / VR-Only : réessayer OpenXR tant que le compositeur démarre, sans bascule bureau muette.
let mut attempt: u32 = 0;
while !stop_flag.load(Ordering::Acquire) && !control_for_loop.is_exit_requested() {
attempt = attempt.saturating_add(1);
let xr_res = try_run_openxr_session(
&cfg,
&monitor,
&optical_params,
&dvr_cmd,
&dvr_cfg,
&dvr_rec_flag,
&head_trim_deg,
&mut active_dvr,
&control_for_loop,
&stop_flag,
&recenter_flag,
&telem_enabled_flag,
&ht_enabled_flag,
&control_source_flag,
video_rx_opt.as_ref(),
&mut telem_rx_opt,
&shared_telem_state,
&mut head_tracker_opt,
g29_rx_opt.as_ref(),
ctrl_worker_opt.as_ref(),
);
if stop_flag.load(Ordering::Acquire) || control_for_loop.is_exit_requested() {
break;
}
match xr_res {
Ok(()) => {
log::info!("[OpenXR] Session VR terminée par le runtime en mode --vr-only, fermeture propre.");
control_for_loop.request_exit();
break;
}
Err(xr_err) => {
if attempt == 1 || attempt % 5 == 0 {
log::warn!(
"[OpenXR] Mode --vr-only : en attente du runtime OpenXR (tentative #{}, {})...",
attempt,
xr_err
);
}
monitor.lock().openxr_status =
SubsystemStatus::Warning(format!("Attente OpenXR : {}", xr_err));
for _ in 0..10 {
if stop_flag.load(Ordering::Acquire) || control_for_loop.is_exit_requested()
{
break;
}
thread::sleep(Duration::from_millis(100));
}
}
}
}
false
} else { } else {
let xr_res = try_run_openxr_session( let xr_res = try_run_openxr_session(
&cfg, &cfg,
@@ -1203,7 +1453,7 @@ fn run_engine_worker(
ctrl_worker_opt.as_ref(), ctrl_worker_opt.as_ref(),
); );
if !stop_flag.load(Ordering::Acquire) { if !stop_flag.load(Ordering::Acquire) && !control_for_loop.is_exit_requested() {
match xr_res { match xr_res {
Err(xr_err) => { Err(xr_err) => {
log::warn!( log::warn!(
@@ -1227,7 +1477,7 @@ fn run_engine_worker(
} }
}; };
if fallback_needed && !stop_flag.load(Ordering::Acquire) { if fallback_needed && !stop_flag.load(Ordering::Acquire) && !control_for_loop.is_exit_requested() {
run_desktop_fallback_loop( run_desktop_fallback_loop(
&cfg, &cfg,
&monitor, &monitor,
@@ -1314,7 +1564,8 @@ fn compose_and_publish_frame<'a>(
}; };
let vr_menu_data = control.vr_menu_render_data(); let vr_menu_data = control.vr_menu_render_data();
let frame_slice: &[u8] = if telem_on || vr_menu_data.is_some() { let show_standby_bar = vr_menu_data.is_none() && !has_video_stream;
let frame_slice: &[u8] = if telem_on || vr_menu_data.is_some() || show_standby_bar {
// Copier la trame vidéo dé-distordue propre avant incrustation OSD/Menu VR : zéro bavure à 90/120 Hz. // Copier la trame vidéo dé-distordue propre avant incrustation OSD/Menu VR : zéro bavure à 90/120 Hz.
composited_rgba.copy_from_slice(warped_rgba); composited_rgba.copy_from_slice(warped_rgba);
if telem_on { if telem_on {
@@ -1336,6 +1587,15 @@ fn compose_and_publish_frame<'a>(
} }
if let Some(ref menu) = vr_menu_data { if let Some(ref menu) = vr_menu_data {
OsdOverlay::render_vr_menu(composited_rgba, cfg.video_width, cfg.video_height, menu); OsdOverlay::render_vr_menu(composited_rgba, cfg.video_width, cfg.video_height, menu);
} else if show_standby_bar {
OsdOverlay::render_vr_standby_bar(
composited_rgba,
cfg.video_width,
cfg.video_height,
has_video_stream,
control.active_control_source(),
dvr_rec,
);
} }
composited_rgba.as_slice() composited_rgba.as_slice()
} else { } else {
@@ -1396,6 +1656,165 @@ fn compose_and_publish_frame<'a>(
frame_slice frame_slice
} }
/// Gestionnaire d'entrées OpenXR natives (contrôleurs VR Steam Frame / Touch / Index)
/// permettant d'ouvrir et naviguer dans le Menu Minimaliste VR sans volant ni manette externe.
struct XrVrMenuInputs {
action_set: xr::ActionSet,
menu_toggle: xr::Action<bool>,
menu_select: xr::Action<bool>,
menu_back: xr::Action<bool>,
menu_nav: xr::Action<xr::Vector2f>,
last_nav_step: Instant,
}
impl XrVrMenuInputs {
fn create_and_attach(
instance: &xr::Instance,
session: &xr::Session<xr::Vulkan>,
) -> Option<Self> {
let action_set = instance
.create_action_set("vr_menu", "SteamFrame VR Menu", 0)
.ok()?;
let menu_toggle = action_set
.create_action::<bool>("menu_toggle", "Ouvrir/Fermer Menu VR", &[])
.ok()?;
let menu_select = action_set
.create_action::<bool>("menu_select", "Valider Menu VR", &[])
.ok()?;
let menu_back = action_set
.create_action::<bool>("menu_back", "Retour Menu VR", &[])
.ok()?;
let menu_nav = action_set
.create_action::<xr::Vector2f>("menu_nav", "Navigation Menu VR", &[])
.ok()?;
// Profils standards OpenXR (mappés automatiquement aux contrôleurs du Steam Frame par SteamVR/Monado)
if let Ok(profile) = instance.string_to_path("/interaction_profiles/oculus/touch_controller")
{
if let (Ok(p_menu), Ok(p_y), Ok(p_a), Ok(p_b), Ok(p_lstick), Ok(p_rstick)) = (
instance.string_to_path("/user/hand/left/input/menu/click"),
instance.string_to_path("/user/hand/left/input/y/click"),
instance.string_to_path("/user/hand/right/input/a/click"),
instance.string_to_path("/user/hand/right/input/b/click"),
instance.string_to_path("/user/hand/left/input/thumbstick"),
instance.string_to_path("/user/hand/right/input/thumbstick"),
) {
let _ = instance.suggest_interaction_profile_bindings(
profile,
&[
xr::Binding::new(&menu_toggle, p_menu),
xr::Binding::new(&menu_toggle, p_y),
xr::Binding::new(&menu_select, p_a),
xr::Binding::new(&menu_back, p_b),
xr::Binding::new(&menu_nav, p_lstick),
xr::Binding::new(&menu_nav, p_rstick),
],
);
}
}
if let Ok(profile) = instance.string_to_path("/interaction_profiles/valve/index_controller")
{
if let (Ok(p_lb), Ok(p_ra), Ok(p_rb), Ok(p_lstick), Ok(p_rstick)) = (
instance.string_to_path("/user/hand/left/input/b/click"),
instance.string_to_path("/user/hand/right/input/a/click"),
instance.string_to_path("/user/hand/right/input/b/click"),
instance.string_to_path("/user/hand/left/input/thumbstick"),
instance.string_to_path("/user/hand/right/input/thumbstick"),
) {
let _ = instance.suggest_interaction_profile_bindings(
profile,
&[
xr::Binding::new(&menu_toggle, p_lb),
xr::Binding::new(&menu_select, p_ra),
xr::Binding::new(&menu_back, p_rb),
xr::Binding::new(&menu_nav, p_lstick),
xr::Binding::new(&menu_nav, p_rstick),
],
);
}
}
if let Ok(profile) = instance.string_to_path("/interaction_profiles/khr/simple_controller") {
if let (Ok(p_menu), Ok(p_sel), Ok(p_back)) = (
instance.string_to_path("/user/hand/left/input/menu/click"),
instance.string_to_path("/user/hand/right/input/select/click"),
instance.string_to_path("/user/hand/left/input/select/click"),
) {
let _ = instance.suggest_interaction_profile_bindings(
profile,
&[
xr::Binding::new(&menu_toggle, p_menu),
xr::Binding::new(&menu_select, p_sel),
xr::Binding::new(&menu_back, p_back),
],
);
}
}
if let Err(e) = session.attach_action_sets(&[&action_set]) {
log::warn!("[OpenXR] Impossible d'attacher les actions contrôleurs VR : {}", e);
return None;
}
log::info!("[OpenXR] Contrôleurs VR natifs activés pour le Menu Minimaliste VR.");
Some(Self {
action_set,
menu_toggle,
menu_select,
menu_back,
menu_nav,
last_nav_step: Instant::now() - Duration::from_secs(1),
})
}
fn poll(&mut self, session: &xr::Session<xr::Vulkan>, control: &EngineControlHandle) {
if session
.sync_actions(&[xr::ActiveActionSet::new(&self.action_set)])
.is_err()
{
return;
}
if let Ok(st) = self.menu_toggle.state(session, xr::Path::NULL) {
if st.is_active && st.changed_since_last_sync && st.current_state {
control.toggle_vr_menu();
return;
}
}
if !control.is_vr_menu_open() {
return;
}
if let Ok(st) = self.menu_back.state(session, xr::Path::NULL) {
if st.is_active && st.changed_since_last_sync && st.current_state {
control.vr_menu_back();
return;
}
}
if let Ok(st) = self.menu_select.state(session, xr::Path::NULL) {
if st.is_active && st.changed_since_last_sync && st.current_state {
control.vr_menu_activate();
return;
}
}
if let Ok(st) = self.menu_nav.state(session, xr::Path::NULL) {
if st.is_active && self.last_nav_step.elapsed() >= Duration::from_millis(200) {
let x = st.current_state.x;
let y = st.current_state.y;
if y > 0.55 {
control.vr_menu_move(-1);
self.last_nav_step = Instant::now();
} else if y < -0.55 {
control.vr_menu_move(1);
self.last_nav_step = Instant::now();
} else if x < -0.55 {
control.vr_menu_adjust(-1);
self.last_nav_step = Instant::now();
} else if x > 0.55 {
control.vr_menu_adjust(1);
self.last_nav_step = Instant::now();
}
}
}
}
}
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn try_run_openxr_session( fn try_run_openxr_session(
cfg: &AppConfig, cfg: &AppConfig,
@@ -1511,6 +1930,7 @@ fn try_run_openxr_session(
.session .session
.as_ref() .as_ref()
.context("Session OpenXR non initialisée")?; .context("Session OpenXR non initialisée")?;
let mut xr_inputs = XrVrMenuInputs::create_and_attach(&instance, session);
let local_space = session let local_space = session
.create_reference_space(xr::ReferenceSpaceType::LOCAL, xr::Posef::IDENTITY)?; .create_reference_space(xr::ReferenceSpaceType::LOCAL, xr::Posef::IDENTITY)?;
let view_space = session let view_space = session
@@ -1529,7 +1949,9 @@ fn try_run_openxr_session(
let mut last_frame_id: u64 = 0; let mut last_frame_id: u64 = 0;
let loop_res: Result<()> = (|| { let loop_res: Result<()> = (|| {
while !stop_flag.load(Ordering::Relaxed) || session_running { while (!stop_flag.load(Ordering::Relaxed) && !control.is_exit_requested())
|| session_running
{
let cur_opt = optical_params.lock().clone(); let cur_opt = optical_params.lock().clone();
if !dome_lut.matches_params( if !dome_lut.matches_params(
cfg.video_width, cfg.video_width,
@@ -1576,7 +1998,7 @@ fn try_run_openxr_session(
sync_head_tracker(cfg, ht_on, head_tracker_opt, monitor); sync_head_tracker(cfg, ht_on, head_tracker_opt, monitor);
// Si l'arrêt de l'application est demandé et que la session tourne encore, notifier proprement le runtime // Si l'arrêt de l'application est demandé et que la session tourne encore, notifier proprement le runtime
if stop_flag.load(Ordering::Relaxed) && !exiting { if (stop_flag.load(Ordering::Relaxed) || control.is_exit_requested()) && !exiting {
exiting = true; exiting = true;
exit_deadline = Some(Instant::now() + Duration::from_millis(1500)); exit_deadline = Some(Instant::now() + Duration::from_millis(1500));
log::info!("[OpenXR] Arrêt demandé, notification du runtime (request_exit)..."); log::info!("[OpenXR] Arrêt demandé, notification du runtime (request_exit)...");
@@ -1660,6 +2082,11 @@ fn try_run_openxr_session(
continue; continue;
} }
if let (Some(ref mut inputs), Some(ref s)) = (xr_inputs.as_mut(), vk_xr.session.as_ref())
{
inputs.poll(s, control);
}
let xr_frame_state = vk_xr let xr_frame_state = vk_xr
.frame_wait .frame_wait
.as_mut() .as_mut()
@@ -1872,7 +2299,8 @@ fn try_run_openxr_session(
} }
} }
// Libération stricte dans l'ordre hiérarchique : Espaces -> Swapchain/Session -> Vulkan // Libération stricte dans l'ordre hiérarchique : Actions -> Espaces -> Swapchain/Session -> Vulkan
drop(xr_inputs);
drop(view_space); drop(view_space);
drop(local_space); drop(local_space);
drop(vk_xr); drop(vk_xr);
@@ -1920,7 +2348,7 @@ fn run_desktop_fallback_loop(
let mut fps_counter: u32 = 0; let mut fps_counter: u32 = 0;
let mut fps_timer = Instant::now(); let mut fps_timer = Instant::now();
while !stop_flag.load(Ordering::Relaxed) { while !stop_flag.load(Ordering::Relaxed) && !control.is_exit_requested() {
let loop_start = Instant::now(); let loop_start = Instant::now();
let cur_opt = optical_params.lock().clone(); let cur_opt = optical_params.lock().clone();
+26 -3
View File
@@ -654,16 +654,39 @@ mod tests {
G29BridgeReceiver::process_line("$G29_EVT,BTN=OPTIONS", &state, Some(&ctrl), None); G29BridgeReceiver::process_line("$G29_EVT,BTN=OPTIONS", &state, Some(&ctrl), None);
assert!(ctrl.is_vr_menu_open()); assert!(ctrl.is_vr_menu_open());
// Descendre 4 fois (0 -> 4 : PROJECTION VR) puis flèche droite (DOME 140 -> CYL 140) // Descendre 2 fois (0 -> 2 : PROJECTION VR) puis flèche droite (DOME 140 -> CYL 140)
for _ in 0..4 { for _ in 0..2 {
G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_DOWN", &state, Some(&ctrl), None); G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_DOWN", &state, Some(&ctrl), None);
} }
G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_RIGHT", &state, Some(&ctrl), None); G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_RIGHT", &state, Some(&ctrl), None);
let data = ctrl.vr_menu_render_data().unwrap(); let data = ctrl.vr_menu_render_data().unwrap();
assert_eq!(data.selected_idx, 4); assert_eq!(data.page, crate::telemetry_osd::VrMenuPage::Main);
assert_eq!(data.selected_idx, 2);
assert_eq!(data.projection_label, "CYL 140"); assert_eq!(data.projection_label, "CYL 140");
// Entrer dans le sous-menu Avancé (index 6) puis revenir au menu principal avec Circle
for _ in 0..4 {
G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_DOWN", &state, Some(&ctrl), None);
}
G29BridgeReceiver::process_line("$G29_EVT,BTN=CROSS", &state, Some(&ctrl), None);
assert_eq!(
ctrl.vr_menu_render_data().unwrap().page,
crate::telemetry_osd::VrMenuPage::Advanced
);
G29BridgeReceiver::process_line("$G29_EVT,BTN=CIRCLE", &state, Some(&ctrl), None); G29BridgeReceiver::process_line("$G29_EVT,BTN=CIRCLE", &state, Some(&ctrl), None);
assert!(ctrl.is_vr_menu_open());
assert_eq!(
ctrl.vr_menu_render_data().unwrap().page,
crate::telemetry_osd::VrMenuPage::Main
);
// Double confirmation sur Quitter l'App (index 7)
G29BridgeReceiver::process_line("$G29_EVT,BTN=DPAD_DOWN", &state, Some(&ctrl), None);
G29BridgeReceiver::process_line("$G29_EVT,BTN=CROSS", &state, Some(&ctrl), None);
assert!(!ctrl.is_exit_requested());
assert!(ctrl.vr_menu_render_data().unwrap().quit_confirm_pending);
G29BridgeReceiver::process_line("$G29_EVT,BTN=CROSS", &state, Some(&ctrl), None);
assert!(ctrl.is_exit_requested());
assert!(!ctrl.is_vr_menu_open()); assert!(!ctrl.is_vr_menu_open());
} }
} }
+9
View File
@@ -3803,11 +3803,20 @@ pub fn run_gpui_app(cfg: AppConfig, log_buffer: Arc<Mutex<LogBuffer>>) -> Result
let should_continue = cx let should_continue = cx
.update(|window, cx| { .update(|window, cx| {
if let Some(view) = weak_view.upgrade() { if let Some(view) = weak_view.upgrade() {
let mut exit_now = false;
view.update(cx, |this, cx| { view.update(cx, |this, cx| {
if this.controls.is_exit_requested() {
exit_now = true;
return;
}
if this.sync_from_engine(window) { if this.sync_from_engine(window) {
cx.notify(); cx.notify();
} }
}); });
if exit_now {
window.remove_window();
return false;
}
true true
} else { } else {
false false
+24 -6
View File
@@ -39,25 +39,43 @@ fn install_signal_handlers() {
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let cfg = AppConfig::parse(); let mut cfg = AppConfig::parse();
let log_buffer = GuiLogger::init(&cfg.log_file); let log_buffer = GuiLogger::init(&cfg.log_file);
let mode_label = if cfg.vr_only {
"VR-Only Natif (Mode Gaming OpenXR)"
} else if cfg.no_gui {
"CLI (--no-gui)"
} else {
"GPUI"
};
log::info!( log::info!(
"=== Démarrage de SteamFrame FPV v{} (IHM : GPUI, Fichier journal : {}) ===", "=== Démarrage de SteamFrame FPV v{} (Mode : {}, Fichier journal : {}) ===",
env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_VERSION"),
mode_label,
cfg.log_file cfg.log_file
); );
if cfg.no_gui { if cfg.no_gui || cfg.vr_only {
install_signal_handlers(); install_signal_handlers();
log::info!("Mode ligne de commande (--no-gui) activé. Ctrl+C ou SIGTERM pour un arrêt sécurisé."); if cfg.vr_only {
cfg.headless = false;
log::info!("Mode VR natif direct (--vr-only) activé : session OpenXR plein casque sans fenêtre 2D.");
} else {
log::info!("Mode ligne de commande (--no-gui) activé. Ctrl+C ou SIGTERM pour un arrêt sécurisé.");
}
let mut engine = FpvEngineController::new(cfg.telemetry_enabled, cfg.head_tracking_enabled); let mut engine = FpvEngineController::new(cfg.telemetry_enabled, cfg.head_tracking_enabled);
let control = engine.control_handle();
control.set_preview_active(false);
engine.start(cfg); engine.start(cfg);
while !SHUTDOWN_REQUESTED.load(Ordering::Acquire) && engine.is_running() { while !SHUTDOWN_REQUESTED.load(Ordering::Acquire)
&& !control.is_exit_requested()
&& engine.is_running()
{
std::thread::sleep(Duration::from_millis(100)); std::thread::sleep(Duration::from_millis(100));
} }
log::info!("[CLI] Signal d'arrêt reçu, fermeture sécurisée du moteur FPV..."); log::info!("[FPV] Arrêt demandé, fermeture sécurisée du moteur FPV...");
engine.stop(); engine.stop();
return Ok(()); return Ok(());
} }
+193 -54
View File
@@ -397,12 +397,32 @@ impl Drop for TelemetryReceiver {
} }
} }
/// Nombre d'entrées interactives dans le Menu Rapide VR intégré à l'OSD OpenXR. /// Pages du Menu Minimaliste VR intégré à l'OSD OpenXR.
pub const VR_MENU_ITEM_COUNT: usize = 11; #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum VrMenuPage {
#[default]
Main,
Advanced,
}
/// Données d'affichage zéro-allocation (`Copy`) pour le Menu Rapide VR dans le casque. impl VrMenuPage {
pub const fn item_count(self) -> usize {
match self {
Self::Main => VR_MENU_MAIN_COUNT,
Self::Advanced => VR_MENU_ADV_COUNT,
}
}
}
/// Nombre d'entrées dans le menu principal minimaliste VR (actions essentielles).
pub const VR_MENU_MAIN_COUNT: usize = 8;
/// Nombre d'entrées dans le sous-menu Avancé VR.
pub const VR_MENU_ADV_COUNT: usize = 7;
/// Données d'affichage zéro-allocation (`Copy`) pour le Menu Minimaliste VR dans le casque.
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct VrMenuRenderData { pub struct VrMenuRenderData {
pub page: VrMenuPage,
pub selected_idx: usize, pub selected_idx: usize,
pub control_source: ControlSource, pub control_source: ControlSource,
pub head_tracking_on: bool, pub head_tracking_on: bool,
@@ -414,6 +434,8 @@ pub struct VrMenuRenderData {
pub dvr_recording: bool, pub dvr_recording: bool,
pub gear_3_max: u16, pub gear_3_max: u16,
pub vibration_pct: u8, pub vibration_pct: u8,
pub wifi_channel: u16,
pub quit_confirm_pending: bool,
pub feedback_msg: Option<(&'static str, bool)>, pub feedback_msg: Option<(&'static str, bool)>,
} }
@@ -589,7 +611,69 @@ impl OsdOverlay {
Self::draw_g29_hud(rgba, width, height, g29, scale, bottom_y); Self::draw_g29_hud(rgba, width, height, g29, scale, bottom_y);
} }
/// Dessine le Menu Rapide VR superposé (utilisable au D-Pad volant G29 ou Steam Controller sans quitter OpenXR). /// Mini-barre discrète affichée dans le casque au démarrage ou en l'absence de signal VRX.
pub fn render_vr_standby_bar(
rgba: &mut [u8],
width: u32,
height: u32,
has_video_stream: bool,
control_source: ControlSource,
dvr_recording: bool,
) {
let scale = (height / 360).max(1);
let s = scale as i32;
let char_w = 6 * s;
let mut bar_buf = StackStr::<64>::new();
let vrx_lbl = if has_video_stream { "VRX OK" } else { "VRX ATTENTE" };
let src_lbl = match control_source {
ControlSource::G29 => "G29",
ControlSource::SteamController => "STEAM",
};
let dvr_lbl = if dvr_recording { " | REC" } else { "" };
let _ = write!(
bar_buf,
"{} | CTRL: {}{} | MENU: OPT/VIEW/MENU",
vrx_lbl, src_lbl, dvr_lbl
);
let text = bar_buf.as_str();
let text_w = text.chars().count() as i32 * char_w;
let pad_x = 10 * s;
let bar_w = (text_w + pad_x * 2).min(width as i32 - 16);
let bar_h = 15 * s;
let bx = (width as i32 - bar_w) / 2;
let by = (height as i32) - bar_h - 14 * s;
Self::darken_rect(rgba, width, height, bx, by, bar_w, bar_h, [8, 14, 24]);
Self::draw_rect_outline(
rgba,
width,
height,
bx,
by,
bar_w,
bar_h,
if has_video_stream {
[0, 220, 255, 255]
} else {
[255, 180, 40, 255]
},
);
let tx = bx + (bar_w - text_w) / 2;
Self::draw_text(
rgba,
width,
height,
tx.max(bx + 4),
by + 4 * s,
text,
scale,
[225, 240, 255, 255],
);
}
/// Dessine le Menu Minimaliste VR superposé (navigable au Volant G29, Steam Controller et Contrôleurs OpenXR).
pub fn render_vr_menu( pub fn render_vr_menu(
rgba: &mut [u8], rgba: &mut [u8],
width: u32, width: u32,
@@ -599,12 +683,13 @@ impl OsdOverlay {
let scale = (height / 360).max(1); let scale = (height / 360).max(1);
let s = scale as i32; let s = scale as i32;
let char_w = 6 * s; let char_w = 6 * s;
let row_h = 11 * s; let row_h = 12 * s;
let item_count = menu.page.item_count();
let panel_w = (304 * s).min(width as i32 - 16).max(180); let panel_w = (304 * s).min(width as i32 - 16).max(180);
let header_h = 18 * s; let header_h = 18 * s;
let footer_h = 20 * s; let footer_h = 20 * s;
let panel_h = (header_h + (VR_MENU_ITEM_COUNT as i32 * row_h) + footer_h) let panel_h = (header_h + (item_count as i32 * row_h) + footer_h)
.min(height as i32 - 12); .min(height as i32 - 12);
let px0 = (width as i32 - panel_w) / 2; let px0 = (width as i32 - panel_w) / 2;
@@ -647,7 +732,10 @@ impl OsdOverlay {
[25, 75, 110, 255], [25, 75, 110, 255],
); );
let title = "[ STEAMFRAME VR QUICK MENU ]"; let title = match menu.page {
VrMenuPage::Main => "[ STEAMFRAME VR MENU ]",
VrMenuPage::Advanced => "[ MENU VR : AVANCE ]",
};
let title_x = px0 + (panel_w - (title.len() as i32 * char_w)) / 2; let title_x = px0 + (panel_w - (title.len() as i32 * char_w)) / 2;
Self::draw_text( Self::draw_text(
rgba, rgba,
@@ -660,15 +748,21 @@ impl OsdOverlay {
[0, 235, 255, 255], [0, 235, 255, 255],
); );
let selected = menu.selected_idx % VR_MENU_ITEM_COUNT; let selected = menu.selected_idx % item_count;
for idx in 0..VR_MENU_ITEM_COUNT { for idx in 0..item_count {
let ry = py0 + header_h + (idx as i32 * row_h); let ry = py0 + header_h + (idx as i32 * row_h);
if ry + row_h > py0 + panel_h - footer_h + 2 { if ry + row_h > py0 + panel_h - footer_h + 2 {
break; break;
} }
let is_sel = idx == selected; let is_sel = idx == selected;
if is_sel { if is_sel {
let is_quit_row = menu.page == VrMenuPage::Main && idx == 7;
let row_bg = if is_quit_row && menu.quit_confirm_pending {
[120, 24, 24, 255]
} else {
[20, 58, 86, 255]
};
Self::fill_rect( Self::fill_rect(
rgba, rgba,
width, width,
@@ -677,7 +771,7 @@ impl OsdOverlay {
ry, ry,
panel_w - 8, panel_w - 8,
row_h - 1, row_h - 1,
[20, 58, 86, 255], row_bg,
); );
} }
@@ -685,8 +779,9 @@ impl OsdOverlay {
let mut val_buf = StackStr::<32>::new(); let mut val_buf = StackStr::<32>::new();
let prefix = if is_sel { "> " } else { " " }; let prefix = if is_sel { "> " } else { " " };
let val_color = match idx { let val_color = match (menu.page, idx) {
0 => { // --- PAGE PRINCIPALE MINIMALISTE (8 entrées) ---
(VrMenuPage::Main, 0) => {
let _ = write!(label_buf, "{}SOURCE PILOTAGE", prefix); let _ = write!(label_buf, "{}SOURCE PILOTAGE", prefix);
let src_lbl = match menu.control_source { let src_lbl = match menu.control_source {
ControlSource::G29 => "< G29 VOLANT >", ControlSource::G29 => "< G29 VOLANT >",
@@ -695,25 +790,22 @@ impl OsdOverlay {
let _ = write!(val_buf, "{}", src_lbl); let _ = write!(val_buf, "{}", src_lbl);
[255, 190, 60, 255] [255, 190, 60, 255]
} }
1 => { (VrMenuPage::Main, 1) => {
let _ = write!(label_buf, "{}CENTRER VUE HT", prefix); let _ = write!(label_buf, "{}CENTRER VUE HT", prefix);
let _ = write!(val_buf, "[ A / CROIX ]"); let _ = write!(val_buf, "[ TARE ]");
[0, 235, 255, 255] [0, 235, 255, 255]
} }
2 => { (VrMenuPage::Main, 2) => {
let _ = write!(label_buf, "{}SUIVI TETE (HT)", prefix); let _ = write!(label_buf, "{}PROJECTION VR", prefix);
let _ = write!( let _ = write!(val_buf, "< {} >", menu.projection_label);
val_buf, [100, 225, 255, 255]
"{}",
if menu.head_tracking_on { "< ON >" } else { "< OFF >" }
);
if menu.head_tracking_on {
[90, 255, 130, 255]
} else {
[160, 175, 195, 255]
}
} }
3 => { (VrMenuPage::Main, 3) => {
let _ = write!(label_buf, "{}DISTANCE ECRAN", prefix);
let _ = write!(val_buf, "< {:.1} M >", menu.screen_distance_m);
[235, 240, 250, 255]
}
(VrMenuPage::Main, 4) => {
let _ = write!(label_buf, "{}OSD TELEMETRIE", prefix); let _ = write!(label_buf, "{}OSD TELEMETRIE", prefix);
let _ = write!( let _ = write!(
val_buf, val_buf,
@@ -726,27 +818,7 @@ impl OsdOverlay {
[160, 175, 195, 255] [160, 175, 195, 255]
} }
} }
4 => { (VrMenuPage::Main, 5) => {
let _ = write!(label_buf, "{}PROJECTION VR", prefix);
let _ = write!(val_buf, "< {} >", menu.projection_label);
[100, 225, 255, 255]
}
5 => {
let _ = write!(label_buf, "{}DISTANCE ECRAN", prefix);
let _ = write!(val_buf, "< {:.1} M >", menu.screen_distance_m);
[235, 240, 250, 255]
}
6 => {
let _ = write!(label_buf, "{}CORRECTION K1", prefix);
let _ = write!(val_buf, "< {:+.2} >", menu.lens_k1);
[235, 240, 250, 255]
}
7 => {
let _ = write!(label_buf, "{}FOV CAMERA", prefix);
let _ = write!(val_buf, "< {:.0}° >", menu.camera_fov_deg);
[235, 240, 250, 255]
}
8 => {
let _ = write!(label_buf, "{}ENREGISTREUR DVR", prefix); let _ = write!(label_buf, "{}ENREGISTREUR DVR", prefix);
let _ = write!( let _ = write!(
val_buf, val_buf,
@@ -759,16 +831,65 @@ impl OsdOverlay {
[180, 190, 205, 255] [180, 190, 205, 255]
} }
} }
9 => { (VrMenuPage::Main, 6) => {
let _ = write!(label_buf, "{}REGLAGES AVANCES", prefix);
let _ = write!(val_buf, "[ OUVRIR > ]");
[160, 215, 255, 255]
}
(VrMenuPage::Main, _) => {
let _ = write!(label_buf, "{}QUITTER L'APP", prefix);
if menu.quit_confirm_pending {
let _ = write!(val_buf, "[ CONFIRMER ! ]");
[255, 80, 80, 255]
} else {
let _ = write!(val_buf, "[ FERMER ]");
[255, 130, 120, 255]
}
}
// --- SOUS-MENU AVANCÉ (7 entrées) ---
(VrMenuPage::Advanced, 0) => {
let _ = write!(label_buf, "{}< RETOUR MENU", prefix);
let _ = write!(val_buf, "[ B / RETOUR ]");
[0, 235, 255, 255]
}
(VrMenuPage::Advanced, 1) => {
let _ = write!(label_buf, "{}SUIVI TETE (HT)", prefix);
let _ = write!(
val_buf,
"{}",
if menu.head_tracking_on { "< ON >" } else { "< OFF >" }
);
if menu.head_tracking_on {
[90, 255, 130, 255]
} else {
[160, 175, 195, 255]
}
}
(VrMenuPage::Advanced, 2) => {
let _ = write!(label_buf, "{}CORRECTION K1", prefix);
let _ = write!(val_buf, "< {:+.2} >", menu.lens_k1);
[235, 240, 250, 255]
}
(VrMenuPage::Advanced, 3) => {
let _ = write!(label_buf, "{}FOV CAMERA", prefix);
let _ = write!(val_buf, "< {:.0}° >", menu.camera_fov_deg);
[235, 240, 250, 255]
}
(VrMenuPage::Advanced, 4) => {
let _ = write!(label_buf, "{}PLAFOND 3E VIT.", prefix); let _ = write!(label_buf, "{}PLAFOND 3E VIT.", prefix);
let _ = write!(val_buf, "< {} >", menu.gear_3_max); let _ = write!(val_buf, "< {} >", menu.gear_3_max);
[255, 190, 60, 255] [255, 190, 60, 255]
} }
_ => { (VrMenuPage::Advanced, 5) => {
let _ = write!(label_buf, "{}VIBRATIONS SC", prefix); let _ = write!(label_buf, "{}VIBRATIONS SC", prefix);
let _ = write!(val_buf, "< {}% >", menu.vibration_pct); let _ = write!(val_buf, "< {}% >", menu.vibration_pct);
[100, 225, 255, 255] [100, 225, 255, 255]
} }
(VrMenuPage::Advanced, _) => {
let _ = write!(label_buf, "{}CANAL RADXA 5.8G", prefix);
let _ = write!(val_buf, "< CH {} >", menu.wifi_channel);
[255, 190, 60, 255]
}
}; };
let lbl_color = if is_sel { let lbl_color = if is_sel {
@@ -776,7 +897,7 @@ impl OsdOverlay {
} else { } else {
[195, 210, 228, 255] [195, 210, 228, 255]
}; };
let text_y = ry + 2 * s; let text_y = ry + 3 * s;
Self::draw_text( Self::draw_text(
rgba, rgba,
width, width,
@@ -821,7 +942,10 @@ impl OsdOverlay {
color, color,
); );
} else { } else {
let help = "DPAD H/B:CHOIX G/D/A:REGLER B/OPT:FERMER"; let help = match menu.page {
VrMenuPage::Main => "STICK/DPAD:CHOIX A/G/D:REGLER B:FERMER",
VrMenuPage::Advanced => "G/D:CHANGER A:APPLIQUER B:RETOUR MENU",
};
let hx = px0 + (panel_w - (help.len() as i32 * char_w)) / 2; let hx = px0 + (panel_w - (help.len() as i32 * char_w)) / 2;
Self::draw_text( Self::draw_text(
rgba, rgba,
@@ -1195,6 +1319,7 @@ impl OsdOverlay {
'>' => [0b01000, 0b00100, 0b00010, 0b00001, 0b00010, 0b00100, 0b01000], '>' => [0b01000, 0b00100, 0b00010, 0b00001, 0b00010, 0b00100, 0b01000],
'=' => [0b00000, 0b00000, 0b11111, 0b00000, 0b11111, 0b00000, 0b00000], '=' => [0b00000, 0b00000, 0b11111, 0b00000, 0b11111, 0b00000, 0b00000],
'\'' => [0b00100, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], '\'' => [0b00100, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000],
'|' => [0b00100, 0b00100, 0b00100, 0b00100, 0b00100, 0b00100, 0b00100],
_ => [0b00000; 7], _ => [0b00000; 7],
} }
@@ -1219,7 +1344,8 @@ mod tests {
#[test] #[test]
fn test_render_vr_menu_bounds_and_output() { fn test_render_vr_menu_bounds_and_output() {
let mut rgba = vec![100u8; 1280 * 720 * 4]; let mut rgba = vec![100u8; 1280 * 720 * 4];
let menu = VrMenuRenderData { let mut menu = VrMenuRenderData {
page: VrMenuPage::Main,
selected_idx: 0, selected_idx: 0,
control_source: ControlSource::SteamController, control_source: ControlSource::SteamController,
head_tracking_on: true, head_tracking_on: true,
@@ -1231,12 +1357,25 @@ mod tests {
dvr_recording: false, dvr_recording: false,
gear_3_max: 1220, gear_3_max: 1220,
vibration_pct: 100, vibration_pct: 100,
wifi_channel: 161,
quit_confirm_pending: false,
feedback_msg: Some(("TARE HT OK", false)), feedback_msg: Some(("TARE HT OK", false)),
}; };
OsdOverlay::render_vr_menu(&mut rgba, 1280, 720, &menu); OsdOverlay::render_vr_menu(&mut rgba, 1280, 720, &menu);
// Le centre de l'écran doit avoir été assombri/dessiné par le panneau VR
let center_idx = ((720 / 2) * 1280 + (1280 / 2)) * 4; let center_idx = ((720 / 2) * 1280 + (1280 / 2)) * 4;
assert_ne!(&rgba[center_idx..center_idx + 3], &[100, 100, 100]); assert_ne!(&rgba[center_idx..center_idx + 3], &[100, 100, 100]);
menu.page = VrMenuPage::Advanced;
menu.selected_idx = 6;
OsdOverlay::render_vr_menu(&mut rgba, 1280, 720, &menu);
OsdOverlay::render_vr_standby_bar(
&mut rgba,
1280,
720,
false,
ControlSource::G29,
false,
);
} }
#[test] #[test]
+13
View File
@@ -0,0 +1,13 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=SteamFrame FPV (Mode VR)
GenericName=Cockpit VR Natif Steam Frame
Comment=Lancement direct en immersion OpenXR avec Menu Minimaliste VR (Mode Gaming SteamOS)
Exec=/home/deck/projects/steamframe_fpv/launch_vr.sh
Path=/home/deck/projects/steamframe_fpv
Icon=/home/deck/projects/steamframe_fpv/assets/icon.png
Terminal=false
Categories=Game;Video;AudioVideo;
StartupNotify=false
StartupWMClass=steamframe-fpv-vr