From 0fd0aeff88a16274e1fc30ddd777cc1bb66c4c36 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 7 Nov 2023 17:22:17 +1300 Subject: [PATCH] Support Rog Ally LED modes (basic) --- CHANGELOG.md | 1 + Cargo.toml | 2 +- Makefile | 2 ++ asusctl/src/main.rs | 14 ++++------ asusd/src/ctrl_aura/config.rs | 4 +-- rog-aura/data/aura_support.ron | 8 ++++++ rog-aura/src/aura_detection.rs | 3 +- rog-aura/src/usb.rs | 29 ++++++++++++++++++++ rog-control-center/src/lib.rs | 2 +- rog-control-center/src/widgets/aura_power.rs | 14 ++++------ rog-platform/src/lib.rs | 3 +- 11 files changed, 58 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b68b628a..9ac5f8ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Support for G733PZ LED modes - Support for G713RC LED modes +- Support Rog Ally LED modes (basic) ### Changed - Fix loading of fan curves from stored settings diff --git a/Cargo.toml b/Cargo.toml index df7ef46a..01459b64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ notify-rust = { git = "https://github.com/flukejones/notify-rust.git", default-f [profile.release] # thin = 57s, asusd = 9.0M # fat = 72s, asusd = 6.4M -lto = "fat" +#lto = "fat" debug = false opt-level = 3 panic = "abort" diff --git a/Makefile b/Makefile index 90607abc..1ab0dd4b 100644 --- a/Makefile +++ b/Makefile @@ -134,6 +134,8 @@ introspect: build: ifeq ($(VENDORED),1) + cargo vendor-filterer --platform x86_64-unknown-linux-gnu vendor + #cargo vendor @echo "version = $(VERSION)" tar pxf vendor_asusctl_$(VERSION).tar.xz endif diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 0c92e41d..947426ac 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -131,17 +131,13 @@ fn do_parsed( if let Some(cmdlist) = CliStart::command_list() { let commands: Vec = cmdlist.lines().map(|s| s.to_owned()).collect(); for command in commands.iter().filter(|command| { - if !matches!( - supported.keyboard_led.dev_id, - AuraDevice::X1854 - | AuraDevice::X1869 - | AuraDevice::X1866 - | AuraDevice::Tuf - ) && command.trim().starts_with("led-pow-1") + if !supported.keyboard_led.dev_id.is_old_style() + && !supported.keyboard_led.dev_id.is_tuf_style() + && command.trim().starts_with("led-pow-1") { return false; } - if supported.keyboard_led.dev_id != AuraDevice::X19b6 + if !supported.keyboard_led.dev_id.is_new_style() && command.trim().starts_with("led-pow-2") { return false; @@ -584,7 +580,7 @@ fn handle_led_power2( return Ok(()); } - if supported.dev_id != AuraDevice::X19b6 { + if !supported.dev_id.is_new_style() { println!("This option applies only to keyboards with product ID 0x19b6"); } diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index a198145c..ab70319a 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -143,9 +143,9 @@ impl StdConfigLoad for AuraConfig {} impl AuraConfig { pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self { // create a default config here - let enabled = if prod_id == AuraDevice::X19b6 { + let enabled = if prod_id.is_new_style() { AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on()) - } else if prod_id == AuraDevice::Tuf { + } else if prod_id.is_tuf_style() { AuraPowerConfig::AuraDevTuf(HashSet::from([ AuraDevTuf::Awake, AuraDevTuf::Boot, diff --git a/rog-aura/data/aura_support.ron b/rog-aura/data/aura_support.ron index 0b224ac8..d3b789f5 100644 --- a/rog-aura/data/aura_support.ron +++ b/rog-aura/data/aura_support.ron @@ -679,4 +679,12 @@ advanced_type: None, power_zones: [Keyboard], ), + ( + board_name: "RC71L", + layout_name: "ga401q", + basic_modes: [Static, Breathe, Pulse], + basic_zones: [], + advanced_type: None, + power_zones: [Keyboard], + ) ]) diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index 2d03c553..b2561a82 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -8,7 +8,7 @@ use crate::{AdvancedAuraType, AuraModeNum, AuraZone}; pub const ASUS_LED_MODE_CONF: &str = "/usr/share/asusd/aura_support.ron"; pub const ASUS_LED_MODE_USER_CONF: &str = "/etc/asusd/asusd_user_ledmodes.ron"; -pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 7] = [ +pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 8] = [ AuraDevice::Tuf, AuraDevice::X1854, AuraDevice::X1869, @@ -16,6 +16,7 @@ pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 7] = [ AuraDevice::X18c6, AuraDevice::X19b6, AuraDevice::X1a30, + AuraDevice::X1abe, ]; #[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] diff --git a/rog-aura/src/usb.rs b/rog-aura/src/usb.rs index e5e5df22..bd3408d9 100644 --- a/rog-aura/src/usb.rs +++ b/rog-aura/src/usb.rs @@ -37,9 +37,35 @@ pub enum AuraDevice { #[default] X19b6, X1a30, + X1abe, Unknown, } +impl AuraDevice { + pub fn is_tuf_style(&self) -> bool { + matches!(self, AuraDevice::Tuf) + } + + pub fn is_old_style(&self) -> bool { + !matches!( + self, + AuraDevice::Unknown + | AuraDevice::Tuf + | AuraDevice::X19b6 + | AuraDevice::X18c6 + | AuraDevice::X1a30 + | AuraDevice::X1abe + ) + } + + pub fn is_new_style(&self) -> bool { + matches!( + self, + AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 | AuraDevice::X1abe + ) + } +} + impl From for &str { fn from(a: AuraDevice) -> Self { match a { @@ -50,6 +76,7 @@ impl From for &str { AuraDevice::X18c6 => "18c6", AuraDevice::X19b6 => "19b6", AuraDevice::X1a30 => "1a30", + AuraDevice::X1abe => "1abe", AuraDevice::Unknown => "unknown", } } @@ -65,6 +92,7 @@ impl From<&str> for AuraDevice { "1854" | "0x1854" => AuraDevice::X1854, "19b6" | "0x19b6" => AuraDevice::X19b6, "1a30" | "0x1a30" => AuraDevice::X1a30, + "1abe" | "0x1abe" => AuraDevice::X1abe, _ => AuraDevice::Unknown, } } @@ -80,6 +108,7 @@ impl Debug for AuraDevice { Self::X18c6 => write!(f, "0x18c6"), Self::X19b6 => write!(f, "0x19B6"), Self::X1a30 => write!(f, "0x1A30"), + Self::X1abe => write!(f, "0x1ABE"), Self::Unknown => write!(f, "Unknown"), } } diff --git a/rog-control-center/src/lib.rs b/rog-control-center/src/lib.rs index 421b0305..7b91ddbc 100644 --- a/rog-control-center/src/lib.rs +++ b/rog-control-center/src/lib.rs @@ -100,7 +100,7 @@ pub fn get_ipc_file() -> Result { let fifo_path = tmp_dir.join("ipc.pipe"); if let Err(e) = unistd::mkfifo(&fifo_path, stat::Mode::S_IRWXU) { if !matches!(e, nix::errno::Errno::EEXIST) { - return Err(e)?; + Err(e)? } } Ok(OpenOptions::new() diff --git a/rog-control-center/src/widgets/aura_power.rs b/rog-control-center/src/widgets/aura_power.rs index e1f0bfd2..a7120632 100644 --- a/rog-control-center/src/widgets/aura_power.rs +++ b/rog-control-center/src/widgets/aura_power.rs @@ -8,15 +8,11 @@ use crate::system_state::SystemState; pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) { ui.heading("Keyboard LED power settings"); - match supported.keyboard_led.dev_id { - AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => { - aura_power1(supported, states, ui); - } - AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 => { - aura_power2(supported, states, ui) - } - AuraDevice::Tuf => aura_power1(supported, states, ui), - AuraDevice::Unknown => {} + if supported.keyboard_led.dev_id.is_old_style() || supported.keyboard_led.dev_id.is_tuf_style() + { + aura_power1(supported, states, ui); + } else if supported.keyboard_led.dev_id.is_new_style() { + aura_power2(supported, states, ui); } } diff --git a/rog-platform/src/lib.rs b/rog-platform/src/lib.rs index e4bfbccb..a214e8c6 100644 --- a/rog-platform/src/lib.rs +++ b/rog-platform/src/lib.rs @@ -75,6 +75,7 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result> { } pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> { + #[allow(clippy::format_collect)] let tmp: String = values.iter().map(|v| format!("{} ", v)).collect(); let tmp = tmp.trim(); device @@ -102,7 +103,7 @@ mod tests { #[test] fn check() { let data = [1, 2, 3, 4, 5]; - + #[allow(clippy::format_collect)] let tmp: String = data.iter().map(|v| format!("{} ", v)).collect(); let tmp = tmp.trim(); assert_eq!(tmp, "1 2 3 4 5");