mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
59 lines
1.4 KiB
Rust
59 lines
1.4 KiB
Rust
/// Source de conduite active sur la passerelle RP2350 (`G29` ou `EXT` pour manette externe / Steam Controller).
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
#[repr(u8)]
|
|
pub enum ControlSource {
|
|
#[default]
|
|
G29 = 0,
|
|
SteamController = 1,
|
|
}
|
|
|
|
impl ControlSource {
|
|
#[allow(clippy::should_implement_trait)]
|
|
pub fn from_str(s: &str) -> Self {
|
|
let lower = s.trim().to_ascii_lowercase();
|
|
if lower == "steam"
|
|
|| lower == "steam_controller"
|
|
|| lower == "steam-controller"
|
|
|| lower == "controller"
|
|
|| lower == "gamepad"
|
|
|| lower == "ext"
|
|
{
|
|
Self::SteamController
|
|
} else {
|
|
Self::G29
|
|
}
|
|
}
|
|
|
|
pub fn from_u8(v: u8) -> Self {
|
|
match v {
|
|
1 => Self::SteamController,
|
|
_ => Self::G29,
|
|
}
|
|
}
|
|
|
|
pub fn as_u8(self) -> u8 {
|
|
self as u8
|
|
}
|
|
|
|
pub fn as_str(self) -> &'static str {
|
|
match self {
|
|
Self::G29 => "g29",
|
|
Self::SteamController => "steam",
|
|
}
|
|
}
|
|
|
|
pub fn wire_tag(self) -> &'static str {
|
|
match self {
|
|
Self::G29 => "G29",
|
|
Self::SteamController => "EXT",
|
|
}
|
|
}
|
|
|
|
pub fn label(self) -> &'static str {
|
|
match self {
|
|
Self::G29 => "Volant G29",
|
|
Self::SteamController => "Steam Controller",
|
|
}
|
|
}
|
|
}
|