feat(perf,ux): GPU compute warp, dual-layer OpenXR OSD, HW decode, profiles & modular architecture (Lots 3 & 4)

This commit is contained in:
bleack committed 2026-11-25 23:05:02 +01:00
1 parent d82a65d9e6
commit 4aa4fc06e7
27 files changed
+9678 -7045

No files matched your search

+90 -15
View File
@@ -145,19 +145,14 @@ fn eviocgabs(abs_code: u16) -> std::ffi::c_ulong {
// TYPES PUBLICS : SOURCE DE CONTRÔLE & ÉTAT STEAM CONTROLLER
// =========================================================================
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum ControlSource {
#[default]
G29 = 0,
SteamController = 1,
}
impl Default for ControlSource {
fn default() -> Self {
Self::G29
}
}
impl ControlSource {
pub fn from_str(s: &str) -> Self {
let lower = s.trim().to_ascii_lowercase();
@@ -1097,7 +1092,7 @@ impl SteamHapticsSynthesizer {
// 5. Freinage violent ABS (> 70%) : pulsation ~12.5 Hz (40 ms crête / 40 ms creux)
if brake_pct > 70 {
let abs_norm = ((brake_pct.min(100) - 70) as f32 / 30.0).clamp(0.0, 1.0);
let crest = ((now.saturating_duration_since(self.origin).as_millis() / 40) % 2) == 0;
let crest = (now.saturating_duration_since(self.origin).as_millis() / 40).is_multiple_of(2);
if crest {
let left = scale_rumble_u16((0.35 + 0.55 * abs_norm) * gain);
let right = scale_rumble_u16((0.45 + 0.50 * abs_norm) * gain);
@@ -1140,6 +1135,37 @@ impl SteamHapticsSynthesizer {
scale_rumble_u16(right_norm * gain),
)
}
/// Superpose une alerte haptique distincte en cas de batterie critique (double-battement grave 1 Hz)
/// ou de liaison radio LQ < 50% (impulsion rapide droite).
#[allow(clippy::too_many_arguments)]
pub fn apply_telemetry_alert(
&self,
base: (u16, u16),
now: Instant,
active_is_steam: bool,
connected: bool,
armed: bool,
battery_crit: bool,
link_crit: bool,
vibration_pct: u8,
) -> (u16, u16) {
if !active_is_steam || !connected || !armed || vibration_pct == 0 {
return base;
}
let scale = vibration_pct.min(100) as f32 / 100.0;
let phase_ms = now.saturating_duration_since(self.origin).as_millis() as u64 % 1000;
let (mut left, mut right) = base;
if battery_crit && (phase_ms < 90 || (160..250).contains(&phase_ms)) {
let alert_l = (46000.0 * scale) as u16;
left = left.max(alert_l);
}
if link_crit && (phase_ms % 250 < 60) {
let alert_r = (42000.0 * scale) as u16;
right = right.max(alert_r);
}
(left, right)
}
}
struct OpenIbexHidraw {
@@ -1159,7 +1185,7 @@ struct OpenIbexHidraw {
impl OpenIbexHidraw {
fn is_ibex_pid(pid: u16) -> bool {
matches!(pid, 0x1302 | 0x1303 | 0x1304 | 0x1305)
matches!(pid, 0x1302..=0x1305)
}
fn parse_hid_id(uevent: &str) -> Option<(u16, u16, String)> {
@@ -1485,8 +1511,10 @@ impl SteamControllerWorker {
let socket = UdpSocket::bind(bind_addr)?;
socket.set_nonblocking(true)?;
let mut initial_state = SteamControllerState::default();
initial_state.vibration_pct = vibration_pct.load(Ordering::Acquire).min(100);
let initial_state = SteamControllerState {
vibration_pct: vibration_pct.load(Ordering::Acquire).min(100),
..Default::default()
};
let state = Arc::new(Mutex::new(initial_state));
let state_clone = Arc::clone(&state);
let stop_flag = Arc::new(AtomicBool::new(false));
@@ -1915,10 +1943,18 @@ impl SteamControllerWorker {
{
let now_tick = Instant::now();
last_haptics_tick = Some(now_tick);
let roughness = telemetry_state_opt
let (roughness, bat_crit, link_crit) = telemetry_state_opt
.as_ref()
.map(|t| t.lock().effective_terrain_roughness())
.unwrap_or(0);
.map(|t| {
let st = t.lock();
let (cells, crit_v) = control.battery_alert_params();
(
st.effective_terrain_roughness(),
st.is_battery_critical(cells, crit_v),
st.is_link_critical(),
)
})
.unwrap_or((0, false, false));
let (connected, armed, gear, throt_pct, brk_pct) = {
let st = state.lock();
(
@@ -1929,7 +1965,7 @@ impl SteamControllerWorker {
st.brake_pct,
)
};
let (left, right) = haptics.compute(
let base_rumble = haptics.compute(
now_tick,
desired_source == ControlSource::SteamController,
connected,
@@ -1940,6 +1976,16 @@ impl SteamControllerWorker {
roughness,
vib_pct,
);
let (left, right) = haptics.apply_telemetry_alert(
base_rumble,
now_tick,
desired_source == ControlSource::SteamController,
connected,
armed,
bat_crit,
link_crit,
vib_pct,
);
if let Some(ref mut gp) = gamepad {
if left > 0 || right > 0 {
gp.set_rumble(left, right);
@@ -2386,6 +2432,35 @@ mod tests {
// 7. Contribution rugosité terrain sur les deux moteurs (même gaz à 0)
let (t_l, t_r) = h.compute(t_drv, true, true, true, 1, 0, 0, 220, 80);
assert!(t_l > 0 && t_r > 0);
// 8. Alertes haptiques télémétrie (batterie critique sur moteur gauche + LQ critique sur droit)
let (bl, br) = h.apply_telemetry_alert(
(0, 0),
t0 + Duration::from_millis(40),
true,
true,
true,
true,
false,
100,
);
assert!(bl > 40000 && br == 0);
let (ll, lr) = h.apply_telemetry_alert(
(0, 0),
t0 + Duration::from_millis(30),
true,
true,
true,
false,
true,
100,
);
assert!(ll == 0 && lr > 35000);
// Désarmé -> jamais d'alerte haptique
assert_eq!(
h.apply_telemetry_alert((0, 0), t0 + Duration::from_millis(40), true, true, false, true, true, 100),
(0, 0)
);
}
#[test]