mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
feat(gui): add live G29 / Steam Controller input & CRSF monitor in Settings
This commit is contained in:
1 parent
23e24cab5d
commit
ebe0d9889f
5 files changed
+796
-30
No files matched your search
+84
-23
@@ -197,6 +197,8 @@ pub struct SteamControllerState {
|
||||
pub clutch_crsf: u16,
|
||||
pub packets_sent: u64,
|
||||
pub send_errors: u64,
|
||||
pub last_button: String,
|
||||
pub last_button_at: Option<Instant>,
|
||||
pub toast_text: String,
|
||||
pub toast_until: Option<Instant>,
|
||||
}
|
||||
@@ -219,6 +221,8 @@ impl Default for SteamControllerState {
|
||||
clutch_crsf: CRSF_CHANNEL_MID,
|
||||
packets_sent: 0,
|
||||
send_errors: 0,
|
||||
last_button: String::new(),
|
||||
last_button_at: None,
|
||||
toast_text: String::new(),
|
||||
toast_until: None,
|
||||
}
|
||||
@@ -259,8 +263,14 @@ impl SteamControllerState {
|
||||
failsafe: !self.connected || hub_failsafe,
|
||||
armed: self.armed,
|
||||
gear: self.gear,
|
||||
steering_pct: (self.steering_norm * 100.0).round().clamp(-100.0, 100.0) as i8,
|
||||
throttle_pct: self.throttle_pct,
|
||||
brake_pct: self.brake_pct,
|
||||
clutch_pct: self.clutch_pct,
|
||||
steer_crsf: self.steer_crsf,
|
||||
throttle_crsf: self.throttle_crsf,
|
||||
brake_crsf: self.brake_crsf,
|
||||
clutch_crsf: self.clutch_crsf,
|
||||
ffb_raw: 0,
|
||||
ffb_pct: 0,
|
||||
vib_pct: 0,
|
||||
@@ -271,12 +281,37 @@ impl SteamControllerState {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
last_button: self.last_button.clone(),
|
||||
last_button_at: self.last_button_at,
|
||||
toast_text: self.toast_text.clone(),
|
||||
toast_until: self.toast_until,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn key_code_label(key: u16) -> String {
|
||||
match key {
|
||||
BTN_START => "Menu / Start (ARM)".to_string(),
|
||||
BTN_SELECT => "View / Select (DVR)".to_string(),
|
||||
BTN_MODE => "Steam (Tare HT)".to_string(),
|
||||
BTN_SOUTH => "A (Tare HT)".to_string(),
|
||||
BTN_EAST => "B (DVR)".to_string(),
|
||||
BTN_NORTH => "Y (OSD)".to_string(),
|
||||
BTN_WEST => "X (Proj VR)".to_string(),
|
||||
BTN_TR => "RB (Rapport +)".to_string(),
|
||||
BTN_TL => "LB (Rapport -)".to_string(),
|
||||
BTN_GRIPR => "R4 Grip (Rapport +)".to_string(),
|
||||
BTN_GRIPL => "L4 Grip (Rapport -)".to_string(),
|
||||
BTN_GRIPL2 => "L5 Grip (Embrayage)".to_string(),
|
||||
BTN_THUMBR => "R3 (Tare HT)".to_string(),
|
||||
BTN_DPAD_UP => "D-Pad Haut (Tilt +1)".to_string(),
|
||||
BTN_DPAD_DOWN => "D-Pad Bas (Tilt -1)".to_string(),
|
||||
BTN_DPAD_LEFT => "D-Pad Gauche (Pan -1)".to_string(),
|
||||
BTN_DPAD_RIGHT => "D-Pad Droite (Pan +1)".to_string(),
|
||||
other => format!("KEY_{}", other),
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// LOGIQUE DE CALCUL DES CANAUX CRSF & BOÎTE SÉQUENTIELLE
|
||||
// =========================================================================
|
||||
@@ -878,29 +913,29 @@ impl SteamControllerWorker {
|
||||
}
|
||||
|
||||
// 4. Traitement axes, boîte séquentielle, boutons cockpit & émission $RC à 100 Hz
|
||||
if desired_source == ControlSource::SteamController {
|
||||
if let Some(ref gp) = gamepad {
|
||||
let steer_norm = gp.steer_axis.normalized_signed();
|
||||
let throttle_norm = gp.throttle_axis.normalized_unsigned();
|
||||
let brake_norm = gp.brake_axis.normalized_unsigned();
|
||||
let clutch_pressed = gp.clutch_pressed;
|
||||
if let Some(ref gp) = gamepad {
|
||||
let steer_norm = gp.steer_axis.normalized_signed();
|
||||
let throttle_norm = gp.throttle_axis.normalized_unsigned();
|
||||
let brake_norm = gp.brake_axis.normalized_unsigned();
|
||||
let clutch_pressed = gp.clutch_pressed;
|
||||
|
||||
let steer_crsf = steering_to_crsf(
|
||||
steer_norm,
|
||||
cfg.steering_deadzone,
|
||||
cfg.steering_expo,
|
||||
cfg.invert_steering,
|
||||
);
|
||||
let (brake_pct, brake_crsf) = brake_to_crsf(brake_norm, cfg.trigger_deadzone);
|
||||
let clutch_pct = if clutch_pressed { 100 } else { 0 };
|
||||
let clutch_crsf = if clutch_pressed {
|
||||
CRSF_CHANNEL_MAX
|
||||
} else {
|
||||
CRSF_CHANNEL_MID
|
||||
};
|
||||
let steer_crsf = steering_to_crsf(
|
||||
steer_norm,
|
||||
cfg.steering_deadzone,
|
||||
cfg.steering_expo,
|
||||
cfg.invert_steering,
|
||||
);
|
||||
let (brake_pct, brake_crsf) = brake_to_crsf(brake_norm, cfg.trigger_deadzone);
|
||||
let clutch_pct = if clutch_pressed { 100 } else { 0 };
|
||||
let clutch_crsf = if clutch_pressed {
|
||||
CRSF_CHANNEL_MAX
|
||||
} else {
|
||||
CRSF_CHANNEL_MID
|
||||
};
|
||||
|
||||
// Évaluer les boutons avant le calcul final des gaz
|
||||
let (armed, gear, throttle_pct, throttle_crsf) = {
|
||||
if desired_source == ControlSource::SteamController {
|
||||
// Mode actif : armement, boîte séquentielle, raccourcis cockpit et émission $RC 100 Hz
|
||||
let (armed, gear, throttle_crsf) = {
|
||||
let mut st = state.lock();
|
||||
let (pre_throt_pct, _) = throttle_to_crsf(
|
||||
throttle_norm,
|
||||
@@ -911,8 +946,14 @@ impl SteamControllerWorker {
|
||||
let gas_released = pre_throt_pct == 0;
|
||||
|
||||
for &key in &pressed_keys {
|
||||
st.last_button = key_code_label(key);
|
||||
st.last_button_at = Some(Instant::now());
|
||||
Self::handle_key_press(key, gas_released, &mut st, &control);
|
||||
}
|
||||
if clutch_pressed && st.clutch_pct == 0 {
|
||||
st.last_button = key_code_label(BTN_GRIPL2);
|
||||
st.last_button_at = Some(Instant::now());
|
||||
}
|
||||
|
||||
let (throt_pct, throt_crsf) = throttle_to_crsf(
|
||||
throttle_norm,
|
||||
@@ -929,10 +970,9 @@ impl SteamControllerWorker {
|
||||
st.brake_crsf = brake_crsf;
|
||||
st.clutch_crsf = clutch_crsf;
|
||||
|
||||
(st.armed, st.gear, throt_pct, throt_crsf)
|
||||
(st.armed, st.gear, throt_crsf)
|
||||
};
|
||||
|
||||
let _ = throttle_pct;
|
||||
let frame = encode_rc_frame(
|
||||
steer_crsf,
|
||||
throttle_crsf,
|
||||
@@ -951,6 +991,27 @@ impl SteamControllerWorker {
|
||||
st.send_errors = st.send_errors.wrapping_add(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Mode veille (G29 actif) : mise à jour lecture seule pour le moniteur des Réglages
|
||||
// sans armer, sans déclencher les actions cockpit et sans envoyer de trame $RC.
|
||||
let (throt_pct, _) =
|
||||
throttle_to_crsf(throttle_norm, cfg.trigger_deadzone, false, 0);
|
||||
let mut st = state.lock();
|
||||
if let Some(&last_key) = pressed_keys.last() {
|
||||
st.last_button = key_code_label(last_key);
|
||||
st.last_button_at = Some(Instant::now());
|
||||
} else if clutch_pressed && st.clutch_pct == 0 {
|
||||
st.last_button = key_code_label(BTN_GRIPL2);
|
||||
st.last_button_at = Some(Instant::now());
|
||||
}
|
||||
st.steering_norm = steer_norm;
|
||||
st.throttle_pct = throt_pct;
|
||||
st.brake_pct = brake_pct;
|
||||
st.clutch_pct = clutch_pct;
|
||||
st.steer_crsf = steer_crsf;
|
||||
st.throttle_crsf = CRSF_CHANNEL_MID;
|
||||
st.brake_crsf = brake_crsf;
|
||||
st.clutch_crsf = clutch_crsf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user