mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Refactor: Make all Aura type devices use "device_manager"
Open the door to adding many other types of "aura" devices later.
This commit is contained in:
@@ -3,6 +3,7 @@ use std::str::FromStr;
|
||||
use std::thread::sleep;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use dmi_id::DMIID;
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
@@ -57,11 +58,12 @@ pub struct DeviceState {
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
|
||||
pub enum AnimeType {
|
||||
GA401,
|
||||
GA402,
|
||||
GU604,
|
||||
#[default]
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
@@ -79,6 +81,19 @@ impl FromStr for AnimeType {
|
||||
}
|
||||
|
||||
impl AnimeType {
|
||||
pub fn from_dmi() -> Self {
|
||||
let board_name = DMIID::new().unwrap_or_default().board_name.to_uppercase();
|
||||
if board_name.contains("GA401I") || board_name.contains("GA401Q") {
|
||||
AnimeType::GA401
|
||||
} else if board_name.contains("GA402R") || board_name.contains("GA402X") {
|
||||
AnimeType::GA402
|
||||
} else if board_name.contains("GU604V") {
|
||||
AnimeType::GU604
|
||||
} else {
|
||||
AnimeType::Unsupported
|
||||
}
|
||||
}
|
||||
|
||||
/// The width of diagonal images
|
||||
pub fn width(&self) -> usize {
|
||||
match self {
|
||||
|
||||
@@ -247,19 +247,19 @@ impl From<AnimShutdown> for i32 {
|
||||
///
|
||||
/// The currently known USB device is `19b6`.
|
||||
#[inline]
|
||||
pub fn get_maybe_anime_type() -> Result<AnimeType, AnimeError> {
|
||||
let dmi = DMIID::new().map_err(|_| AnimeError::NoDevice)?; // TODO: better error
|
||||
pub fn get_anime_type() -> AnimeType {
|
||||
let dmi = DMIID::new().unwrap_or_default();
|
||||
let board_name = dmi.board_name;
|
||||
|
||||
if board_name.contains("GA401I") || board_name.contains("GA401Q") {
|
||||
return Ok(AnimeType::GA401);
|
||||
AnimeType::GA401
|
||||
} else if board_name.contains("GA402R") || board_name.contains("GA402X") {
|
||||
return Ok(AnimeType::GA402);
|
||||
AnimeType::GA402
|
||||
} else if board_name.contains("GU604V") {
|
||||
return Ok(AnimeType::GU604);
|
||||
AnimeType::GU604
|
||||
} else {
|
||||
AnimeType::Unsupported
|
||||
}
|
||||
log::warn!("AniMe Matrix device found but could be a slash");
|
||||
Ok(AnimeType::Unsupported)
|
||||
}
|
||||
|
||||
/// Get the two device initialization packets. These are required for device
|
||||
|
||||
Reference in New Issue
Block a user