hardware: Split out device type detection, add initial identification of Legion Go S

This commit is contained in:
Vicki Pfau 2025-02-20 03:29:00 -08:00
parent cd9558fd67
commit 7d8bd602a7
5 changed files with 147 additions and 64 deletions

View file

@ -18,7 +18,7 @@ use tokio::sync::OnceCell;
use tokio::task::spawn_blocking;
#[cfg(not(test))]
use crate::hardware::is_deck;
use crate::hardware::{device_type, DeviceType};
#[cfg(not(test))]
static CONFIG: OnceCell<Option<PlatformConfig>> = OnceCell::const_new();
@ -137,12 +137,14 @@ impl<T: Clone> RangeConfig<T> {
impl PlatformConfig {
#[cfg(not(test))]
async fn load() -> Result<Option<PlatformConfig>> {
if !is_deck().await? {
// Non-Steam Deck platforms are not yet supported
return Ok(None);
}
let config = read_to_string("/usr/share/steamos-manager/platforms/jupiter.toml").await?;
let platform = match device_type().await? {
DeviceType::SteamDeck => "jupiter",
_ => return Ok(None),
};
let config = read_to_string(format!(
"/usr/share/steamos-manager/platforms/{platform}.toml"
))
.await?;
Ok(Some(toml::from_str(config.as_ref())?))
}