Minor prep

This commit is contained in:
Luke D. Jones
2024-12-18 11:21:40 +13:00
parent c05c8ba648
commit 0ddfe76c31
11 changed files with 79 additions and 308 deletions

307
Cargo.lock generated
View File

@@ -199,7 +199,6 @@ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
"config-traits", "config-traits",
"console-subscriber 0.2.0",
"dmi_id", "dmi_id",
"env_logger", "env_logger",
"futures-lite", "futures-lite",
@@ -459,34 +458,6 @@ dependencies = [
"arrayvec", "arrayvec",
] ]
[[package]]
name = "axum"
version = "0.6.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [
"async-trait",
"axum-core 0.3.4",
"bitflags 1.3.2",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.32",
"itoa",
"matchit",
"memchr",
"mime",
"percent-encoding",
"pin-project-lite",
"rustversion",
"serde",
"sync_wrapper 0.1.2",
"tower 0.4.13",
"tower-layer",
"tower-service",
]
[[package]] [[package]]
name = "axum" name = "axum"
version = "0.7.9" version = "0.7.9"
@@ -494,11 +465,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core 0.4.5", "axum-core",
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"itoa", "itoa",
"matchit", "matchit",
@@ -508,29 +479,12 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"rustversion", "rustversion",
"serde", "serde",
"sync_wrapper 1.0.2", "sync_wrapper",
"tower 0.5.2", "tower 0.5.2",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
] ]
[[package]]
name = "axum-core"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"
dependencies = [
"async-trait",
"bytes",
"futures-util",
"http 0.2.12",
"http-body 0.4.6",
"mime",
"rustversion",
"tower-layer",
"tower-service",
]
[[package]] [[package]]
name = "axum-core" name = "axum-core"
version = "0.4.5" version = "0.4.5"
@@ -540,13 +494,13 @@ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"mime", "mime",
"pin-project-lite", "pin-project-lite",
"rustversion", "rustversion",
"sync_wrapper 1.0.2", "sync_wrapper",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
] ]
@@ -934,19 +888,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "console-api"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787"
dependencies = [
"futures-core",
"prost 0.12.6",
"prost-types 0.12.6",
"tonic 0.10.2",
"tracing-core",
]
[[package]] [[package]]
name = "console-api" name = "console-api"
version = "0.8.1" version = "0.8.1"
@@ -954,57 +895,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8030735ecb0d128428b64cd379809817e620a40e5001c54465b99ec5feec2857" checksum = "8030735ecb0d128428b64cd379809817e620a40e5001c54465b99ec5feec2857"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"prost 0.13.4", "prost",
"prost-types 0.13.4", "prost-types",
"tonic 0.12.3", "tonic",
"tracing-core", "tracing-core",
] ]
[[package]]
name = "console-subscriber"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e"
dependencies = [
"console-api 0.6.0",
"crossbeam-channel",
"crossbeam-utils",
"futures-task",
"hdrhistogram",
"humantime",
"prost-types 0.12.6",
"serde",
"serde_json",
"thread_local",
"tokio",
"tokio-stream",
"tonic 0.10.2",
"tracing",
"tracing-core",
"tracing-subscriber",
]
[[package]] [[package]]
name = "console-subscriber" name = "console-subscriber"
version = "0.4.1" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6539aa9c6a4cd31f4b1c040f860a1eac9aa80e7df6b05d506a6e7179936d6a01" checksum = "6539aa9c6a4cd31f4b1c040f860a1eac9aa80e7df6b05d506a6e7179936d6a01"
dependencies = [ dependencies = [
"console-api 0.8.1", "console-api",
"crossbeam-channel", "crossbeam-channel",
"crossbeam-utils", "crossbeam-utils",
"futures-task", "futures-task",
"hdrhistogram", "hdrhistogram",
"humantime", "humantime",
"hyper-util", "hyper-util",
"prost 0.13.4", "prost",
"prost-types 0.13.4", "prost-types",
"serde", "serde",
"serde_json", "serde_json",
"thread_local", "thread_local",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tonic 0.12.3", "tonic",
"tracing", "tracing",
"tracing-core", "tracing-core",
"tracing-subscriber", "tracing-subscriber",
@@ -2028,25 +1945,6 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "h2"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap 2.7.0",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.7" version = "0.4.7"
@@ -2058,7 +1956,7 @@ dependencies = [
"fnv", "fnv",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"http 1.2.0", "http",
"indexmap 2.7.0", "indexmap 2.7.0",
"slab", "slab",
"tokio", "tokio",
@@ -2145,17 +2043,6 @@ dependencies = [
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
[[package]]
name = "http"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]] [[package]]
name = "http" name = "http"
version = "1.2.0" version = "1.2.0"
@@ -2167,17 +2054,6 @@ dependencies = [
"itoa", "itoa",
] ]
[[package]]
name = "http-body"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
dependencies = [
"bytes",
"http 0.2.12",
"pin-project-lite",
]
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "1.0.1" version = "1.0.1"
@@ -2185,7 +2061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [ dependencies = [
"bytes", "bytes",
"http 1.2.0", "http",
] ]
[[package]] [[package]]
@@ -2196,8 +2072,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"pin-project-lite", "pin-project-lite",
] ]
@@ -2219,30 +2095,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
version = "0.14.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
dependencies = [
"bytes",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
"tower-service",
"tracing",
"want",
]
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "1.5.2" version = "1.5.2"
@@ -2252,9 +2104,9 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"h2 0.4.7", "h2",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@@ -2264,25 +2116,13 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper-timeout"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
dependencies = [
"hyper 0.14.32",
"pin-project-lite",
"tokio",
"tokio-io-timeout",
]
[[package]] [[package]]
name = "hyper-timeout" name = "hyper-timeout"
version = "0.5.2" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0"
dependencies = [ dependencies = [
"hyper 1.5.2", "hyper",
"hyper-util", "hyper-util",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
@@ -2298,9 +2138,9 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"hyper 1.5.2", "hyper",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
@@ -3945,16 +3785,6 @@ dependencies = [
"syn 2.0.90", "syn 2.0.90",
] ]
[[package]]
name = "prost"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29"
dependencies = [
"bytes",
"prost-derive 0.12.6",
]
[[package]] [[package]]
name = "prost" name = "prost"
version = "0.13.4" version = "0.13.4"
@@ -3962,20 +3792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec"
dependencies = [ dependencies = [
"bytes", "bytes",
"prost-derive 0.13.4", "prost-derive",
]
[[package]]
name = "prost-derive"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1"
dependencies = [
"anyhow",
"itertools 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.90",
] ]
[[package]] [[package]]
@@ -3991,22 +3808,13 @@ dependencies = [
"syn 2.0.90", "syn 2.0.90",
] ]
[[package]]
name = "prost-types"
version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0"
dependencies = [
"prost 0.12.6",
]
[[package]] [[package]]
name = "prost-types" name = "prost-types"
version = "0.13.4" version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc"
dependencies = [ dependencies = [
"prost 0.13.4", "prost",
] ]
[[package]] [[package]]
@@ -4272,7 +4080,7 @@ dependencies = [
"cargo-husky", "cargo-husky",
"concat-idents", "concat-idents",
"config-traits", "config-traits",
"console-subscriber 0.4.1", "console-subscriber",
"dirs", "dirs",
"dmi_id", "dmi_id",
"env_logger", "env_logger",
@@ -5002,12 +4810,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]] [[package]]
name = "sync_wrapper" name = "sync_wrapper"
version = "1.0.2" version = "1.0.2"
@@ -5250,16 +5052,6 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "tokio-io-timeout"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
dependencies = [
"pin-project-lite",
"tokio",
]
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.4.0" version = "2.4.0"
@@ -5329,33 +5121,6 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "tonic"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e"
dependencies = [
"async-stream",
"async-trait",
"axum 0.6.20",
"base64 0.21.7",
"bytes",
"h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.32",
"hyper-timeout 0.4.1",
"percent-encoding",
"pin-project",
"prost 0.12.6",
"tokio",
"tokio-stream",
"tower 0.4.13",
"tower-layer",
"tower-service",
"tracing",
]
[[package]] [[package]]
name = "tonic" name = "tonic"
version = "0.12.3" version = "0.12.3"
@@ -5364,19 +5129,19 @@ checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"axum 0.7.9", "axum",
"base64 0.22.1", "base64 0.22.1",
"bytes", "bytes",
"h2 0.4.7", "h2",
"http 1.2.0", "http",
"http-body 1.0.1", "http-body",
"http-body-util", "http-body-util",
"hyper 1.5.2", "hyper",
"hyper-timeout 0.5.2", "hyper-timeout",
"hyper-util", "hyper-util",
"percent-encoding", "percent-encoding",
"pin-project", "pin-project",
"prost 0.13.4", "prost",
"socket2", "socket2",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
@@ -5415,7 +5180,7 @@ dependencies = [
"futures-core", "futures-core",
"futures-util", "futures-util",
"pin-project-lite", "pin-project-lite",
"sync_wrapper 1.0.2", "sync_wrapper",
"tower-layer", "tower-layer",
"tower-service", "tower-service",
] ]

View File

@@ -13,9 +13,6 @@ edition.workspace = true
name = "asusd" name = "asusd"
path = "src/daemon.rs" path = "src/daemon.rs"
[features]
tokio_debug = []
[dependencies] [dependencies]
config-traits = { path = "../config-traits" } config-traits = { path = "../config-traits" }
rog_anime = { path = "../rog-anime", features = ["dbus"] } rog_anime = { path = "../rog-anime", features = ["dbus"] }
@@ -30,7 +27,7 @@ inotify.workspace = true
mio.workspace = true mio.workspace = true
tokio.workspace = true tokio.workspace = true
console-subscriber = "0.2.0" # console-subscriber = "0.2.0"
# cli and logging # cli and logging
log.workspace = true log.workspace = true

View File

@@ -219,7 +219,7 @@ impl CtrlKbdLed {
if dmi.product_family.contains("TUF") { if dmi.product_family.contains("TUF") {
info!("AuraControl found a TUF laptop keyboard"); info!("AuraControl found a TUF laptop keyboard");
let ctrl = CtrlKbdLed { let ctrl = CtrlKbdLed {
led_type: AuraDeviceType::LaptopTuf, led_type: AuraDeviceType::LaptopKeyboardTuf,
led_node: LEDNode::KbdLed(kbd_backlight), led_node: LEDNode::KbdLed(kbd_backlight),
supported_data: LedSupportData::get_data("tuf"), supported_data: LedSupportData::get_data("tuf"),
per_key_mode_active: false, per_key_mode_active: false,
@@ -442,7 +442,7 @@ mod tests {
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
}; };
let mut controller = CtrlKbdLed { let mut controller = CtrlKbdLed {
led_type: AuraDeviceType::LaptopPost2021, led_type: AuraDeviceType::LaptopKeyboard2021,
led_node: LEDNode::Rog( led_node: LEDNode::Rog(
Some(KeyboardBacklight::default()), Some(KeyboardBacklight::default()),
HidRaw::new("19b6").unwrap(), HidRaw::new("19b6").unwrap(),
@@ -492,7 +492,7 @@ mod tests {
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
}; };
let mut controller = CtrlKbdLed { let mut controller = CtrlKbdLed {
led_type: AuraDeviceType::LaptopPost2021, led_type: AuraDeviceType::LaptopKeyboard2021,
led_node: LEDNode::Rog( led_node: LEDNode::Rog(
Some(KeyboardBacklight::default()), Some(KeyboardBacklight::default()),
HidRaw::new("19b6").unwrap(), HidRaw::new("19b6").unwrap(),

View File

@@ -49,8 +49,10 @@ impl CtrlSlash {
let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok(); let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok();
let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok(); let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok();
let node = if usb.is_some() { let node = if usb.is_some() {
info!("Slash is using raw USB");
unsafe { Node::Usb(usb.unwrap_unchecked()) } unsafe { Node::Usb(usb.unwrap_unchecked()) }
} else if hid.is_some() { } else if hid.is_some() {
info!("Slash is using HIDRAW");
unsafe { Node::Hid(hid.unwrap_unchecked()) } unsafe { Node::Hid(hid.unwrap_unchecked()) }
} else { } else {
return Err(RogError::Slash(SlashError::NoDevice)); return Err(RogError::Slash(SlashError::NoDevice));

View File

@@ -19,7 +19,7 @@ use zbus::fdo::ObjectManager;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
console_subscriber::init(); // console_subscriber::init();
let mut logger = env_logger::Builder::new(); let mut logger = env_logger::Builder::new();
logger logger
.parse_default_env() .parse_default_env()
@@ -108,6 +108,8 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
} }
let _ = AuraManager::new(connection.clone()).await?;
match CtrlSlash::new() { match CtrlSlash::new() {
Ok(ctrl) => { Ok(ctrl) => {
let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl))); let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl)));
@@ -123,8 +125,6 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
} }
let _ = AuraManager::new(connection.clone()).await?;
// Request dbus name after finishing initalizing all functions // Request dbus name after finishing initalizing all functions
connection.request_name(DBUS_NAME).await?; connection.request_name(DBUS_NAME).await?;

View File

@@ -193,14 +193,14 @@ impl LaptopAuraPower {
// TODO: use support data to setup correct zones // TODO: use support data to setup correct zones
pub fn new(aura_type: AuraDeviceType, support_data: &LedSupportData) -> Self { pub fn new(aura_type: AuraDeviceType, support_data: &LedSupportData) -> Self {
match aura_type { match aura_type {
AuraDeviceType::Unknown | AuraDeviceType::Ally | AuraDeviceType::LaptopPost2021 => { AuraDeviceType::Unknown | AuraDeviceType::Ally | AuraDeviceType::LaptopKeyboard2021 => {
let mut states = Vec::new(); let mut states = Vec::new();
for zone in support_data.power_zones.iter() { for zone in support_data.power_zones.iter() {
states.push(AuraPowerState::default_for(*zone)) states.push(AuraPowerState::default_for(*zone))
} }
Self { states } Self { states }
} }
AuraDeviceType::LaptopPre2021 => { AuraDeviceType::LaptopKeyboardPre2021 => {
// The older devices are tri-state if have lightbar: // The older devices are tri-state if have lightbar:
// 1. Keyboard // 1. Keyboard
// 2. Lightbar // 2. Lightbar
@@ -215,10 +215,11 @@ impl LaptopAuraPower {
} }
} }
} }
AuraDeviceType::LaptopTuf => Self { AuraDeviceType::LaptopKeyboardTuf => Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
}, },
AuraDeviceType::ScsiExtDisk => todo!(), AuraDeviceType::ScsiExtDisk => todo!(),
AuraDeviceType::AnimeOrSlash => todo!(),
} }
} }
@@ -229,8 +230,8 @@ impl LaptopAuraPower {
} }
} }
match aura_type { match aura_type {
AuraDeviceType::LaptopPost2021 | AuraDeviceType::Ally => self.new_to_bytes(), AuraDeviceType::LaptopKeyboard2021 | AuraDeviceType::Ally => self.new_to_bytes(),
AuraDeviceType::LaptopPre2021 => { AuraDeviceType::LaptopKeyboardPre2021 => {
if self.states.len() == 1 { if self.states.len() == 1 {
self.states self.states
.first() .first()
@@ -249,7 +250,7 @@ impl LaptopAuraPower {
b b
} }
} }
AuraDeviceType::LaptopTuf => self AuraDeviceType::LaptopKeyboardTuf => self
.states .states
.first() .first()
.cloned() .cloned()
@@ -260,6 +261,7 @@ impl LaptopAuraPower {
self.new_to_bytes() self.new_to_bytes()
} }
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"), AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"),
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet"),
} }
} }
} }
@@ -309,7 +311,7 @@ mod test {
use crate::{AuraDeviceType, PowerZones}; use crate::{AuraDeviceType, PowerZones};
fn to_binary_string_post2021(power: &LaptopAuraPower) -> String { fn to_binary_string_post2021(power: &LaptopAuraPower) -> String {
let bytes = power.to_bytes(AuraDeviceType::LaptopPost2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboard2021);
format!( format!(
"{:08b}, {:08b}, {:08b}, {:08b}", "{:08b}, {:08b}, {:08b}, {:08b}",
bytes[0], bytes[1], bytes[2], bytes[3] bytes[0], bytes[1], bytes[2], bytes[3]
@@ -327,7 +329,7 @@ mod test {
shutdown: false, shutdown: false,
}], }],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
@@ -340,7 +342,7 @@ mod test {
shutdown: false, shutdown: false,
}], }],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]); assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
@@ -369,7 +371,7 @@ mod test {
}, },
], ],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
} }

View File

@@ -70,25 +70,26 @@ pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANG
pub enum AuraDeviceType { pub enum AuraDeviceType {
/// Most new laptops /// Most new laptops
#[default] #[default]
LaptopPost2021 = 0, LaptopKeyboard2021 = 0,
LaptopPre2021 = 1, LaptopKeyboardPre2021 = 1,
LaptopTuf = 2, LaptopKeyboardTuf = 2,
ScsiExtDisk = 3, ScsiExtDisk = 3,
Ally = 4, Ally = 4,
AnimeOrSlash = 5,
Unknown = 255, Unknown = 255,
} }
impl AuraDeviceType { impl AuraDeviceType {
pub fn is_old_laptop(&self) -> bool { pub fn is_old_laptop(&self) -> bool {
*self == Self::LaptopPre2021 *self == Self::LaptopKeyboardPre2021
} }
pub fn is_tuf_laptop(&self) -> bool { pub fn is_tuf_laptop(&self) -> bool {
*self == Self::LaptopTuf *self == Self::LaptopKeyboardTuf
} }
pub fn is_new_laptop(&self) -> bool { pub fn is_new_laptop(&self) -> bool {
*self == Self::LaptopPost2021 *self == Self::LaptopKeyboard2021
} }
pub fn is_ally(&self) -> bool { pub fn is_ally(&self) -> bool {
@@ -103,11 +104,12 @@ impl AuraDeviceType {
impl From<&str> for AuraDeviceType { impl From<&str> for AuraDeviceType {
fn from(s: &str) -> Self { fn from(s: &str) -> Self {
match s.to_lowercase().trim_start_matches("0x") { match s.to_lowercase().trim_start_matches("0x") {
"tuf" => AuraDeviceType::LaptopTuf, "tuf" => AuraDeviceType::LaptopKeyboardTuf,
"1932" => AuraDeviceType::ScsiExtDisk, "1932" => AuraDeviceType::ScsiExtDisk,
"1866" | "18c6" | "1869" | "1854" => Self::LaptopPre2021, "1866" | "18c6" | "1869" | "1854" => Self::LaptopKeyboardPre2021,
"1abe" | "1b4c" => Self::Ally, "1abe" | "1b4c" => Self::Ally,
_ => Self::LaptopPost2021, "19b3" => Self::AnimeOrSlash,
_ => Self::LaptopKeyboard2021,
} }
} }
} }

View File

@@ -148,12 +148,13 @@ impl From<LaptopAuraPower> for SlintLaptopAuraPower {
impl From<SlintDeviceType> for AuraDeviceType { impl From<SlintDeviceType> for AuraDeviceType {
fn from(value: SlintDeviceType) -> Self { fn from(value: SlintDeviceType) -> Self {
match value { match value {
SlintDeviceType::New => Self::LaptopPost2021, SlintDeviceType::New => Self::LaptopKeyboard2021,
SlintDeviceType::Old => Self::LaptopPre2021, SlintDeviceType::Old => Self::LaptopKeyboardPre2021,
SlintDeviceType::Tuf => Self::LaptopTuf, SlintDeviceType::Tuf => Self::LaptopKeyboardTuf,
SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk, SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk,
SlintDeviceType::Unknown => Self::Unknown, SlintDeviceType::Unknown => Self::Unknown,
SlintDeviceType::Ally => Self::Ally, SlintDeviceType::Ally => Self::Ally,
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash,
} }
} }
} }
@@ -161,12 +162,13 @@ impl From<SlintDeviceType> for AuraDeviceType {
impl From<AuraDeviceType> for SlintDeviceType { impl From<AuraDeviceType> for SlintDeviceType {
fn from(value: AuraDeviceType) -> Self { fn from(value: AuraDeviceType) -> Self {
match value { match value {
AuraDeviceType::LaptopPost2021 => SlintDeviceType::New, AuraDeviceType::LaptopKeyboard2021 => SlintDeviceType::New,
AuraDeviceType::LaptopPre2021 => SlintDeviceType::Old, AuraDeviceType::LaptopKeyboardPre2021 => SlintDeviceType::Old,
AuraDeviceType::LaptopTuf => SlintDeviceType::Tuf, AuraDeviceType::LaptopKeyboardTuf => SlintDeviceType::Tuf,
AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk, AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
AuraDeviceType::Unknown => SlintDeviceType::Unknown, AuraDeviceType::Unknown => SlintDeviceType::Unknown,
AuraDeviceType::Ally => SlintDeviceType::Ally, AuraDeviceType::Ally => SlintDeviceType::Ally,
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash,
} }
} }
} }

View File

@@ -89,7 +89,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
let dev_type = aura let dev_type = aura
.device_type() .device_type()
.await .await
.unwrap_or(AuraDeviceType::LaptopPost2021); .unwrap_or(AuraDeviceType::LaptopKeyboard2021);
log::debug!("Available LED power modes {pow3r:?}"); log::debug!("Available LED power modes {pow3r:?}");
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-12-17 09:05+0000\n" "POT-Creation-Date: 2024-12-17 21:33+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -5,6 +5,7 @@ export enum AuraDevType {
ScsiExtDisk, ScsiExtDisk,
Unknown, Unknown,
Ally, Ally,
AnimeOrSlash,
} }
export struct AuraEffect { export struct AuraEffect {