diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 0f7e280f..0b161aaa 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -12,9 +12,8 @@ use fan_curve_cli::FanCurveCommand; use gumdrop::{Opt, Options}; use rog_anime::usb::get_anime_type; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2}; -use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; -use rog_aura::{self, AuraDeviceType, AuraEffect}; +use rog_aura::{self, AuraDeviceType, AuraEffect, PowerZones}; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; diff --git a/asusd-user/src/daemon.rs b/asusd-user/src/daemon.rs index 34bc3263..8146c3a9 100644 --- a/asusd-user/src/daemon.rs +++ b/asusd-user/src/daemon.rs @@ -7,7 +7,7 @@ use asusd_user::config::*; use asusd_user::ctrl_anime::{CtrlAnime, CtrlAnimeInner}; use config_traits::{StdConfig, StdConfigLoad}; use rog_anime::usb::get_anime_type; -use rog_aura::aura_detection::LaptopLedData; +use rog_aura::aura_detection::LedSupportData; use rog_aura::keyboard::KeyLayout; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; @@ -94,7 +94,7 @@ fn main() -> Result<(), Box> { let mut aura_config = ConfigAura::new().set_name(cfg).load(); // let baord_name = std::fs::read_to_string(BOARD_NAME)?; - let led_support = LaptopLedData::get_data(); + let led_support = LedSupportData::get_data(""); let layout = KeyLayout::find_layout(led_support, PathBuf::from(DATA_DIR)) .map_err(|e| { diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index fb86f0a4..4de61425 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use config_traits::{StdConfig, StdConfigLoad}; use log::{debug, info, warn}; -use rog_aura::aura_detection::LaptopLedData; +use rog_aura::aura_detection::LedSupportData; use rog_aura::keyboard::LaptopAuraPower; use rog_aura::{ AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT, @@ -46,11 +46,11 @@ impl AuraConfig { pub fn new(prod_id: &str) -> Self { info!("Setting up AuraConfig for {prod_id:?}"); // create a default config here - let device_type = AuraDeviceType::from(&*prod_id); + let device_type = AuraDeviceType::from(prod_id); if device_type == AuraDeviceType::Unknown { warn!("idProduct:{prod_id:?} is unknown"); } - let support_data = LaptopLedData::get_data(); + let support_data = LedSupportData::get_data(prod_id); let enabled = LaptopAuraPower::new(device_type, &support_data); let mut config = AuraConfig { config_name: format!("aura_{prod_id}.ron"), diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index 96b956d6..6539669d 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, HashSet}; use config_traits::{StdConfig, StdConfigLoad}; use inotify::Inotify; use log::{debug, info, warn}; -use rog_aura::aura_detection::LaptopLedData; +use rog_aura::aura_detection::LedSupportData; use rog_aura::keyboard::{LedUsbPackets, UsbPackets}; use rog_aura::usb::{LED_APPLY, LED_SET}; use rog_aura::{ @@ -54,14 +54,14 @@ impl LEDNode { pub struct CtrlKbdLed { pub led_type: AuraDeviceType, pub led_node: LEDNode, - pub supported_data: LaptopLedData, // TODO: is storing this really required? + pub supported_data: LedSupportData, // TODO: is storing this really required? pub per_key_mode_active: bool, pub config: AuraConfig, pub dbus_path: OwnedObjectPath, } impl CtrlKbdLed { - pub fn find_all(data: &LaptopLedData) -> Result, RogError> { + pub fn find_all() -> Result, RogError> { info!("Searching for all Aura devices"); let mut devices = Vec::new(); let mut found = HashSet::new(); // track and ensure we use only one hidraw per prod_id @@ -114,8 +114,8 @@ impl CtrlKbdLed { info!("AuraControl found device at: {:?}", dev_node); let dbus_path = dbus_path_for_dev(&usb_device).unwrap_or_default(); let dev = HidRaw::from_device(end_point)?; - let mut dev = Self::from_hidraw(dev, dbus_path, data)?; - dev.config = Self::init_config(&prod_id, data); + let mut dev = Self::from_hidraw(dev, dbus_path)?; + dev.config = Self::init_config(&prod_id); devices.push(dev); } } @@ -127,11 +127,7 @@ impl CtrlKbdLed { /// The generated data from this function has a default config. This config /// should be overwritten. The reason for the default config is because /// of async issues between this and udev/hidraw - pub fn from_hidraw( - device: HidRaw, - dbus_path: OwnedObjectPath, - data: &LaptopLedData, - ) -> Result { + pub fn from_hidraw(device: HidRaw, dbus_path: OwnedObjectPath) -> Result { let rgb_led = KeyboardLed::new()?; let prod_id = AuraDeviceType::from(device.prod_id()); if prod_id == AuraDeviceType::Unknown { @@ -142,6 +138,7 @@ impl CtrlKbdLed { // New loads data from the DB also // let config = Self::init_config(prod_id, data); + let data = LedSupportData::get_data(device.prod_id()); let ctrl = CtrlKbdLed { led_type: prod_id, led_node: LEDNode::Rog(rgb_led, device), @@ -153,7 +150,7 @@ impl CtrlKbdLed { Ok(ctrl) } - pub fn init_config(prod_id: &str, supported_basic_modes: &LaptopLedData) -> AuraConfig { + pub fn init_config(prod_id: &str) -> AuraConfig { // New loads data from the DB also let mut config_init = AuraConfig::new(prod_id); // config_init.set_filename(prod_id); @@ -175,9 +172,10 @@ impl CtrlKbdLed { // update init values from loaded values if they exist if let Some(loaded) = multizone_loaded.get(mode.0) { let mut new_set = Vec::new(); + let data = LedSupportData::get_data(prod_id); // only reuse a zone mode if the mode is supported for mode in loaded { - if supported_basic_modes.basic_modes.contains(&mode.mode) { + if data.basic_modes.contains(&mode.mode) { new_set.push(mode.clone()); } } @@ -201,7 +199,7 @@ impl CtrlKbdLed { // pwr[4] as u8]; platform.set_kbd_rgb_state(&buf)?; // } } else if let LEDNode::Rog(_, hid_raw) = &self.led_node { - let bytes = self.config.enabled.to_bytes(self.led_type.into()); + let bytes = self.config.enabled.to_bytes(self.led_type); let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]]; hid_raw.write_bytes(&message)?; @@ -346,8 +344,8 @@ impl CtrlKbdLed { #[cfg(test)] mod tests { - use rog_aura::aura_detection::{LaptopLedData, PowerZones}; - use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone}; + use rog_aura::aura_detection::LedSupportData; + use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone, PowerZones}; use rog_platform::hid_raw::HidRaw; use rog_platform::keyboard_led::KeyboardLed; use zbus::zvariant::OwnedObjectPath; @@ -361,8 +359,8 @@ mod tests { fn create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried let config = AuraConfig::new("19b6"); - let supported_basic_modes = LaptopLedData { - board_name: String::new(), + let supported_basic_modes = LedSupportData { + device_name: String::new(), layout_name: "ga401".to_owned(), basic_modes: vec![AuraModeNum::Static], basic_zones: vec![], @@ -401,8 +399,8 @@ mod tests { fn next_mode_create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried let config = AuraConfig::new("19b6"); - let supported_basic_modes = LaptopLedData { - board_name: String::new(), + let supported_basic_modes = LedSupportData { + device_name: String::new(), layout_name: "ga401".to_owned(), basic_modes: vec![AuraModeNum::Static], basic_zones: vec![AuraZone::Key1, AuraZone::Key2], diff --git a/asusd/src/ctrl_aura/manager.rs b/asusd/src/ctrl_aura/manager.rs index 6b9b0840..c5a793a5 100644 --- a/asusd/src/ctrl_aura/manager.rs +++ b/asusd/src/ctrl_aura/manager.rs @@ -8,7 +8,6 @@ use std::collections::HashSet; use log::{debug, error, info, warn}; use mio::{Events, Interest, Poll, Token}; -use rog_aura::aura_detection::LaptopLedData; use rog_aura::AuraDeviceType; use rog_platform::hid_raw::HidRaw; use tokio::task::spawn_blocking; @@ -29,11 +28,10 @@ pub struct AuraManager { impl AuraManager { pub async fn new(connection: Connection) -> Result { let conn_copy = connection.clone(); - let data = LaptopLedData::get_data(); let mut interfaces = HashSet::new(); // Do the initial keyboard detection: - let all = CtrlKbdLed::find_all(&data)?; + let all = CtrlKbdLed::find_all()?; for ctrl in all { let path = ctrl.dbus_path.clone(); interfaces.insert(path.clone()); // ensure we record the initial stuff @@ -132,10 +130,8 @@ impl AuraManager { if let Ok(raw) = HidRaw::from_device(event.device()) .map_err(|e| error!("device path error: {e:?}")) { - if let Ok(mut ctrl) = - CtrlKbdLed::from_hidraw(raw, path.clone(), &data) - { - ctrl.config = CtrlKbdLed::init_config(&id_product, &data); + if let Ok(mut ctrl) = CtrlKbdLed::from_hidraw(raw, path.clone()) { + ctrl.config = CtrlKbdLed::init_config(&id_product); interfaces.insert(path.clone()); info!("AuraManager starting device at: {dev_node:?}, {path:?}"); let sig_ctx = CtrlAuraZbus::signal_context(&conn_copy)?; diff --git a/asusd/src/ctrl_aura/trait_impls.rs b/asusd/src/ctrl_aura/trait_impls.rs index 30b7535f..274f8e69 100644 --- a/asusd/src/ctrl_aura/trait_impls.rs +++ b/asusd/src/ctrl_aura/trait_impls.rs @@ -3,9 +3,8 @@ use std::sync::Arc; use config_traits::StdConfig; use log::{debug, error, info, warn}; -use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{LaptopAuraPower, UsbPackets}; -use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness}; +use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness, PowerZones}; use zbus::export::futures_util::lock::{Mutex, MutexGuard}; use zbus::export::futures_util::StreamExt; use zbus::fdo::Error as ZbErr; diff --git a/rog-aura/data/aura_support.ron b/rog-aura/data/aura_support.ron index a5022d17..b6bd5bb8 100644 --- a/rog-aura/data/aura_support.ron +++ b/rog-aura/data/aura_support.ron @@ -1,6 +1,6 @@ ([ ( - board_name: "FA506I", + device_name: "FA506I", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -8,7 +8,7 @@ power_zones: [Keyboard], ), ( - board_name: "FA506Q", + device_name: "FA506Q", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [], @@ -16,7 +16,7 @@ power_zones: [Keyboard], ), ( - board_name: "FA507", + device_name: "FA507", layout_name: "fa507", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -24,7 +24,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX505D", + device_name: "FX505D", layout_name: "fx505d", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -32,7 +32,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX505G", + device_name: "FX505G", layout_name: "fx505d", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -40,7 +40,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX506H", + device_name: "FX506H", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -48,7 +48,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX506L", + device_name: "FX506L", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -56,7 +56,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX507Z", + device_name: "FX507Z", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -64,7 +64,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX516P", + device_name: "FX516P", layout_name: "fa506i", basic_modes: [Static, Breathe, Strobe], basic_zones: [], @@ -72,7 +72,7 @@ power_zones: [Keyboard], ), ( - board_name: "FX705D", + device_name: "FX705D", layout_name: "fx505d", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -80,7 +80,7 @@ power_zones: [Keyboard], ), ( - board_name: "G512", + device_name: "G512", layout_name: "g512", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -88,7 +88,7 @@ power_zones: [Keyboard], ), ( - board_name: "G512LV", + device_name: "G512LV", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -96,7 +96,7 @@ power_zones: [Keyboard], ), ( - board_name: "G513I", + device_name: "G513I", layout_name: "g513i", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -104,7 +104,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G513QE", + device_name: "G513QE", layout_name: "g513i", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -112,7 +112,7 @@ power_zones: [Keyboard], ), ( - board_name: "G513QM", + device_name: "G513QM", layout_name: "g513i", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -120,7 +120,7 @@ power_zones: [Keyboard], ), ( - board_name: "G513QR", + device_name: "G513QR", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -128,7 +128,7 @@ power_zones: [Keyboard], ), ( - board_name: "G513QY", + device_name: "G513QY", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -136,7 +136,7 @@ power_zones: [Keyboard], ), ( - board_name: "G513RC", + device_name: "G513RC", layout_name: "g513i", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -144,7 +144,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G513RM", + device_name: "G513RM", layout_name: "g513i", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -152,7 +152,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G513RW", + device_name: "G513RW", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -160,7 +160,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531", + device_name: "G531", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -168,7 +168,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531", + device_name: "G531", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [Key1, Key2, Key3, Key4], @@ -176,7 +176,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531GD", + device_name: "G531GD", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -184,7 +184,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531GT", + device_name: "G531GT", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [], @@ -192,7 +192,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531GU", + device_name: "G531GU", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [Key1, Key2, Key3, Key4], @@ -200,7 +200,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531GV", + device_name: "G531GV", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [Key1, Key2, Key3, Key4], @@ -208,7 +208,7 @@ power_zones: [Keyboard], ), ( - board_name: "G531GW", + device_name: "G531GW", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [Key1, Key2, Key3, Key4], @@ -216,7 +216,7 @@ power_zones: [Keyboard], ), ( - board_name: "G532", + device_name: "G532", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -224,7 +224,7 @@ power_zones: [Keyboard], ), ( - board_name: "G533Q", + device_name: "G533Q", layout_name: "g533q-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -232,7 +232,7 @@ power_zones: [Keyboard], ), ( - board_name: "G533Z", + device_name: "G533Z", layout_name: "g533q-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -240,7 +240,7 @@ power_zones: [Keyboard], ), ( - board_name: "G614J", + device_name: "G614J", layout_name: "g634j-per-key", basic_modes: [Static, Breathe, Pulse, Strobe, Rainbow], basic_zones: [], @@ -248,7 +248,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G634J", + device_name: "G634J", layout_name: "g634j-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -256,7 +256,7 @@ power_zones: [Keyboard, Lightbar, Logo, RearGlow], ), ( - board_name: "G712LI", + device_name: "G712LI", layout_name: "gl503", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -264,7 +264,7 @@ power_zones: [Keyboard], ), ( - board_name: "G712LV", + device_name: "G712LV", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -272,7 +272,7 @@ power_zones: [Keyboard], ), ( - board_name: "G712LW", + device_name: "G712LW", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -280,7 +280,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713IC", + device_name: "G713IC", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -288,7 +288,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713QM", + device_name: "G713QM", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -296,7 +296,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713QR", + device_name: "G713QR", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -304,7 +304,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713RC", + device_name: "G713RC", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -312,7 +312,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G713RM", + device_name: "G713RM", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -320,7 +320,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713RS", + device_name: "G713RS", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -328,7 +328,7 @@ power_zones: [Keyboard], ), ( - board_name: "G713RW", + device_name: "G713RW", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -336,7 +336,7 @@ power_zones: [Keyboard], ), ( - board_name: "G731", + device_name: "G731", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [Key1, Key2, Key3, Key4], @@ -344,7 +344,7 @@ power_zones: [Keyboard], ), ( - board_name: "G731GT", + device_name: "G731GT", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [], @@ -352,7 +352,7 @@ power_zones: [Keyboard], ), ( - board_name: "G731GU", + device_name: "G731GU", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [], @@ -360,7 +360,7 @@ power_zones: [Keyboard], ), ( - board_name: "G731GV", + device_name: "G731GV", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [Key1, Key2, Key3, Key4], @@ -368,7 +368,7 @@ power_zones: [Keyboard], ), ( - board_name: "G731GW", + device_name: "G731GW", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [Key1, Key2, Key3, Key4], @@ -376,7 +376,7 @@ power_zones: [Keyboard], ), ( - board_name: "G733C", + device_name: "G733C", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [Logo, BarLeft, BarRight], @@ -384,7 +384,7 @@ power_zones: [Keyboard], ), ( - board_name: "G733PZ", + device_name: "G733PZ", layout_name: "g733pz-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -392,7 +392,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G733Q", + device_name: "G733Q", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -400,7 +400,7 @@ power_zones: [Keyboard], ), ( - board_name: "G733Z", + device_name: "G733Z", layout_name: "g513i-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -408,7 +408,7 @@ power_zones: [Keyboard], ), ( - board_name: "G814JI", + device_name: "G814JI", layout_name: "g814ji-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -416,7 +416,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G814JZ", + device_name: "G814JZ", layout_name: "g814ji-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -424,7 +424,7 @@ power_zones: [Keyboard, Lightbar], ), ( - board_name: "G834JZ", + device_name: "G834JZ", layout_name: "g814ji-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -432,7 +432,7 @@ power_zones: [Keyboard, Lightbar, Logo, RearGlow], ), ( - board_name: "GA401Q", + device_name: "GA401Q", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -440,7 +440,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA402N", + device_name: "GA402N", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe], basic_zones: [], @@ -448,7 +448,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA402R", + device_name: "GA402R", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse, Rainbow], basic_zones: [], @@ -456,7 +456,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA402X", + device_name: "GA402X", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse, Rainbow], basic_zones: [], @@ -464,7 +464,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA503Q", + device_name: "GA503Q", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe], basic_zones: [], @@ -472,7 +472,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA503QE", + device_name: "GA503QE", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -480,7 +480,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA503R", + device_name: "GA503R", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse, Rainbow, Strobe], basic_zones: [], @@ -488,7 +488,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL503", + device_name: "GL503", layout_name: "gl503", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -496,7 +496,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL503V", + device_name: "GL503V", layout_name: "gl503", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -504,7 +504,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL504G", + device_name: "GL504G", layout_name: "gl503", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4, Logo, BarLeft, BarRight], @@ -512,7 +512,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL531", + device_name: "GL531", layout_name: "g512", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -520,7 +520,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL553VE", + device_name: "GL553VE", layout_name: "g533q", basic_modes: [Static, Breathe, Strobe], basic_zones: [Key1, Key2, Key3, Key4], @@ -528,7 +528,7 @@ power_zones: [Keyboard], ), ( - board_name: "GL703G", + device_name: "GL703G", layout_name: "gl503", basic_modes: [Static, Breathe, Strobe, Rainbow], basic_zones: [], @@ -536,7 +536,7 @@ power_zones: [Keyboard], ), ( - board_name: "GM501G", + device_name: "GM501G", layout_name: "fa507", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -544,7 +544,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU502", + device_name: "GU502", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -552,7 +552,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU502G", + device_name: "GU502G", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -560,7 +560,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU502L", + device_name: "GU502L", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -568,7 +568,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU502LU", + device_name: "GU502LU", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -576,7 +576,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU603H", + device_name: "GU603H", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -584,7 +584,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU603VV", + device_name: "GU603VV", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -592,7 +592,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU603Z", + device_name: "GU603Z", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -600,7 +600,7 @@ power_zones: [Keyboard], ), ( - board_name: "GU604V", + device_name: "GU604V", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -608,7 +608,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV301Q", + device_name: "GV301Q", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -616,7 +616,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV301V", + device_name: "GV301V", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -624,7 +624,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV301VIC", + device_name: "GV301VIC", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -632,7 +632,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV601R", + device_name: "GV601R", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -640,7 +640,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV601V", + device_name: "GV601V", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -648,7 +648,7 @@ power_zones: [Keyboard], ), ( - board_name: "GV604V", + device_name: "GV604V", layout_name: "ga401q", basic_modes: [Static, Breathe, Strobe, Pulse], basic_zones: [], @@ -656,7 +656,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX502", + device_name: "GX502", layout_name: "gx502", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -664,7 +664,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX531", + device_name: "GX531", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [Key1, Key2, Key3, Key4], @@ -672,7 +672,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX550L", + device_name: "GX550L", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -680,7 +680,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX551Q", + device_name: "GX551Q", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Pulse], basic_zones: [], @@ -688,7 +688,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX650P", + device_name: "GX650P", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -696,7 +696,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX701", + device_name: "GX701", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -704,7 +704,7 @@ power_zones: [Keyboard], ), ( - board_name: "GX703H", + device_name: "GX703H", layout_name: "gx531-per-key", basic_modes: [Static, Breathe, Strobe, Rainbow, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash], basic_zones: [], @@ -712,7 +712,7 @@ power_zones: [Keyboard], ), ( - board_name: "GZ301V", + device_name: "GZ301V", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -720,7 +720,7 @@ power_zones: [Keyboard], ), ( - board_name: "GZ301VIC", + device_name: "GZ301VIC", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -728,7 +728,7 @@ power_zones: [Keyboard], ), ( - board_name: "GZ301Z", + device_name: "GZ301Z", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -736,7 +736,7 @@ power_zones: [Keyboard], ), ( - board_name: "RC71L", + device_name: "RC71L", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], @@ -744,7 +744,7 @@ power_zones: [Keyboard], ), ( - board_name: "GA403UI", + device_name: "GA403UI", layout_name: "ga401q", basic_modes: [Static, Breathe, Pulse], basic_zones: [], diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index d37fc672..f9763915 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -1,86 +1,89 @@ use dmi_id::DMIID; use log::{error, info, warn}; use serde_derive::{Deserialize, Serialize}; -use typeshare::typeshare; -use zbus::zvariant::{OwnedValue, Type, Value}; use crate::keyboard::AdvancedAuraType; -use crate::{AuraModeNum, AuraZone}; +use crate::{AuraModeNum, AuraZone, PowerZones}; 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"; -#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] -pub struct LedSupportFile(Vec); - -/// The powerr zones this laptop supports -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "u") -)] -#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default, Copy, Clone)] -pub enum PowerZones { - /// The logo on some laptop lids - #[default] - Logo = 0, - /// The full keyboard (not zones) - Keyboard = 1, - /// The lightbar, typically on the front of the laptop - Lightbar = 2, - /// The leds that may be placed around the edge of the laptop lid - Lid = 3, - /// The led strip on the rear of some laptops - RearGlow = 4, - /// On pre-2021 laptops there is either 1 or 2 zones used - KeyboardAndLightbar = 5, -} - #[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)] -pub struct LaptopLedData { - /// Found via `cat /sys/class/dmi/id/board_name`, e.g `GU603ZW`. - /// The match doesn't have to be the complete model number as it is - /// typically broken down such: +pub struct LedSupportData { + /// This can be many different types of name: + /// - `/sys/class/dmi/id/board_name` (must use for laptops) + /// - The device name from `lsusb` + /// - The product ID (usb only) + /// + /// The laptop board_name is found via `cat /sys/class/dmi/id/board_name`, + /// e.g `GU603ZW`. The match doesn't have to be the complete model + /// number as it is typically broken down such: /// - GU = product /// - 603 = model/platform /// - Z = variant/year or perhaps dGPU model (such as RTX 3xxx) /// - W = possibly dGPU model (such as RTX 3060Ti) - pub board_name: String, + /// + /// If using a device name the match is similar to the above where it can be + /// partial, so `ASUSTek Computer, Inc. ROG STRIX Arion` can be `STRIX + /// Arion` for short. Case insensitive. + /// + /// Example of using a product ID is: + /// ``` + /// $ lsusb + /// $ Bus 003 Device 003: ID 0b05:19b6 ASUSTek Computer, Inc. N-KEY Device + /// ``` + /// here `19b6` is all that is required. Case insensitive. + pub device_name: String, + /// Keyboard or device LED layout, this is the name of the externally + /// defined layout file. Optional, can be an empty string pub layout_name: String, + /// If empty will default to `Static` mode pub basic_modes: Vec, + /// Available on some laptops. This is where the keyboard may be split in to + /// 4 zones and may have a logo and lightbar. + /// + /// Ignored if empty. pub basic_zones: Vec, + /// `Zoned` or `PerKey`. + // TODO: remove and use layouts only pub advanced_type: AdvancedAuraType, + /// If empty will default to `Keyboard` power zone pub power_zones: Vec, } -impl LaptopLedData { - pub fn get_data() -> Self { +impl LedSupportData { + /// Find the data for the device. This function will check DMI info for + /// matches against laptops first, then will proceed with matching the + /// `device_name` if there are no DMI matches. + pub fn get_data(_device_name: &str) -> Self { let dmi = DMIID::new().unwrap_or_default(); // let prod_family = dmi.product_family().expect("Could not get // product_family"); - if let Some(modes) = LedSupportFile::load_from_supoprt_db() { - if let Some(data) = modes.matcher(&dmi.board_name) { + if let Some(data) = LedSupportFile::load_from_supoprt_db() { + if let Some(data) = data.match_device(&dmi.board_name) { return data; } } info!("Using generic LED control for keyboard brightness only"); - LaptopLedData::default() + LedSupportData::default() } } +#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub struct LedSupportFile(Vec); + impl LedSupportFile { - pub fn get(&self) -> &[LaptopLedData] { + pub fn get(&self) -> &[LedSupportData] { &self.0 } /// The list is stored in ordered format, so the iterator must be reversed /// to ensure we match to *whole names* first before doing a glob match - pub fn matcher(self, board_name: &str) -> Option { + fn match_device(&self, device_name: &str) -> Option { for config in self.0.iter().rev() { - if board_name.contains(&config.board_name) { - info!("LedSupport: Matched to {}", config.board_name); + if device_name.contains(&config.device_name) { + info!("LedSupport: Matched to {}", config.device_name); return Some(config.clone()); } } @@ -125,7 +128,7 @@ impl LedSupportFile { ); } } - data.0.sort_by(|a, b| a.board_name.cmp(&b.board_name)); + data.0.sort_by(|a, b| a.device_name.cmp(&b.device_name)); if loaded { return Some(data); @@ -144,7 +147,7 @@ mod tests { use ron::ser::PrettyConfig; - use super::LaptopLedData; + use super::LedSupportData; use crate::aura_detection::{LedSupportFile, PowerZones}; use crate::keyboard::{AdvancedAuraType, LedCode}; // use crate::zoned::Zone; @@ -152,8 +155,8 @@ mod tests { #[test] fn check_data_parse() { - let led = LaptopLedData { - board_name: "Test".to_owned(), + let led = LedSupportData { + device_name: "Test".to_owned(), layout_name: "ga401".to_owned(), basic_modes: vec![AuraModeNum::Static], basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft], @@ -176,7 +179,7 @@ mod tests { // Ensure the data is sorted let mut tmp_sort = tmp.clone(); - tmp_sort.0.sort_by(|a, b| a.board_name.cmp(&b.board_name)); + tmp_sort.0.sort_by(|a, b| a.device_name.cmp(&b.device_name)); if tmp != tmp_sort { let sorted = ron::ser::to_string_pretty(&tmp_sort, PrettyConfig::new().depth_limit(2)).unwrap(); diff --git a/rog-aura/src/keyboard/layouts.rs b/rog-aura/src/keyboard/layouts.rs index 2e978af6..6a0f91fd 100644 --- a/rog-aura/src/keyboard/layouts.rs +++ b/rog-aura/src/keyboard/layouts.rs @@ -8,7 +8,7 @@ use std::slice::Iter; use log::warn; use serde::{Deserialize, Serialize}; -use crate::aura_detection::LaptopLedData; +use crate::aura_detection::LedSupportData; use crate::error::Error; use crate::keyboard::{AdvancedAuraType, LedCode}; use crate::{AuraModeNum, AuraZone}; @@ -278,7 +278,7 @@ impl KeyLayout { } /// Find a layout matching the name in `LaptopLedData` in the provided dir - pub fn find_layout(led_data: LaptopLedData, mut data_path: PathBuf) -> Result { + pub fn find_layout(led_data: LedSupportData, mut data_path: PathBuf) -> Result { // TODO: locales let layout_name = if led_data.layout_name.is_empty() { "ga401q".to_owned() // Need some sort of default here due to ROGCC @@ -543,7 +543,7 @@ mod tests { .map_err(|e| { panic!( "Error checking {data_path:?} for {} : {e:?}", - config.board_name + config.device_name ) }) .unwrap(); @@ -551,7 +551,7 @@ mod tests { if let Err(e) = file.read_to_string(&mut buf) { panic!( "Error checking {data_path:?} for {} : {e:?}", - config.board_name + config.device_name ) } if let Err(e) = ron::from_str::(&buf) { diff --git a/rog-aura/src/keyboard/power.rs b/rog-aura/src/keyboard/power.rs index f1f48d76..f12b1c5d 100644 --- a/rog-aura/src/keyboard/power.rs +++ b/rog-aura/src/keyboard/power.rs @@ -9,8 +9,8 @@ use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::{OwnedValue, Type, Value}; -use crate::aura_detection::{LaptopLedData, PowerZones}; -use crate::AuraDeviceType; +use crate::aura_detection::LedSupportData; +use crate::{AuraDeviceType, PowerZones}; /// Meaning of this struct depends on the laptop generation. /// - 2021+, the struct is a single zone with 4 states @@ -133,7 +133,7 @@ impl AuraPowerState { | (self.sleep as u32) << (23 + 3) | (self.shutdown as u32) << (23 + 4) } - PowerZones::KeyboardAndLightbar => 0, + PowerZones::KeyboardAndLightbar | PowerZones::None => 0, } } } @@ -184,7 +184,7 @@ impl LaptopAuraPower { } // TODO: use support data to setup correct zones - pub fn new(aura_type: AuraDeviceType, support_data: &LaptopLedData) -> Self { + pub fn new(aura_type: AuraDeviceType, support_data: &LedSupportData) -> Self { match aura_type { AuraDeviceType::Unknown | AuraDeviceType::LaptopPost2021 => { let mut states = Vec::new(); @@ -276,9 +276,9 @@ impl From for u32 { #[cfg(test)] mod test { - use crate::aura_detection::{LaptopLedData, PowerZones}; + use crate::aura_detection::LedSupportData; use crate::keyboard::{AuraPowerState, LaptopAuraPower}; - use crate::AuraDeviceType; + use crate::{AuraDeviceType, PowerZones}; #[test] fn check_0x1866_control_bytes() { @@ -515,7 +515,8 @@ mod test { assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); // All on - let byte1 = LaptopAuraPower::new(AuraDeviceType::LaptopPost2021, &LaptopLedData::default()); + let byte1 = + LaptopAuraPower::new(AuraDeviceType::LaptopPost2021, &LedSupportData::default()); let out = to_binary_string(&byte1); assert_eq!(out, "11111111, 00011110, 00001111, 00001111"); } diff --git a/rog-aura/src/lib.rs b/rog-aura/src/lib.rs index 7b75d618..e841e742 100644 --- a/rog-aura/src/lib.rs +++ b/rog-aura/src/lib.rs @@ -105,3 +105,28 @@ impl From<&str> for AuraDeviceType { } } } + +/// The powerr zones this laptop supports +#[typeshare] +#[cfg_attr( + feature = "dbus", + derive(Type, Value, OwnedValue), + zvariant(signature = "u") +)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default, Copy, Clone)] +pub enum PowerZones { + /// The logo on some laptop lids + Logo = 0, + /// The full keyboard (not zones) + #[default] + Keyboard = 1, + /// The lightbar, typically on the front of the laptop + Lightbar = 2, + /// The leds that may be placed around the edge of the laptop lid + Lid = 3, + /// The led strip on the rear of some laptops + RearGlow = 4, + /// On pre-2021 laptops there is either 1 or 2 zones used + KeyboardAndLightbar = 5, + None = 255, +} diff --git a/rog-control-center/src/types/aura_types.rs b/rog-control-center/src/types/aura_types.rs index 33a82384..5ba48b42 100644 --- a/rog-control-center/src/types/aura_types.rs +++ b/rog-control-center/src/types/aura_types.rs @@ -50,13 +50,13 @@ impl From for rog_aura::AuraEffect } } -use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; +use rog_aura::PowerZones; use slint::{Model, ModelRc, RgbaColor}; use crate::slint_generatedMainWindow::PowerZones as SlintPowerZones; -impl From for SlintPowerZones { - fn from(value: rog_aura::aura_detection::PowerZones) -> Self { +impl From for SlintPowerZones { + fn from(value: PowerZones) -> Self { match value { PowerZones::Logo => SlintPowerZones::Logo, PowerZones::Keyboard => SlintPowerZones::Keyboard, @@ -64,21 +64,20 @@ impl From for SlintPowerZones { PowerZones::Lid => SlintPowerZones::Lid, PowerZones::RearGlow => SlintPowerZones::RearGlow, PowerZones::KeyboardAndLightbar => todo!(), + PowerZones::None => todo!(), } } } -impl From for rog_aura::aura_detection::PowerZones { +impl From for PowerZones { fn from(value: SlintPowerZones) -> Self { match value { - SlintPowerZones::Logo => rog_aura::aura_detection::PowerZones::Logo, - SlintPowerZones::Keyboard => rog_aura::aura_detection::PowerZones::Keyboard, - SlintPowerZones::Lightbar => rog_aura::aura_detection::PowerZones::Lightbar, - SlintPowerZones::Lid => rog_aura::aura_detection::PowerZones::Lid, - SlintPowerZones::RearGlow => rog_aura::aura_detection::PowerZones::RearGlow, - SlintPowerZones::KeyboardAndLightbar => { - rog_aura::aura_detection::PowerZones::KeyboardAndLightbar - } + SlintPowerZones::Logo => PowerZones::Logo, + SlintPowerZones::Keyboard => PowerZones::Keyboard, + SlintPowerZones::Lightbar => PowerZones::Lightbar, + SlintPowerZones::Lid => PowerZones::Lid, + SlintPowerZones::RearGlow => PowerZones::RearGlow, + SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar, } } } diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 85c91146..e059f1d4 100644 --- a/rog-control-center/translations/en/rog-control-center.po +++ b/rog-control-center/translations/en/rog-control-center.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2024-04-10 05:04+0000\n" +"POT-Creation-Date: 2024-04-10 09:14+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index a203b542..27809c71 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -22,9 +22,8 @@ use std::collections::BTreeMap; -use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{LaptopAuraPower, UsbPackets}; -use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness}; +use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness, PowerZones}; use zbus::blocking::Connection; use zbus::{proxy, Result}; diff --git a/rog-slash/src/data.rs b/rog-slash/src/data.rs index 0757e742..cfad6752 100644 --- a/rog-slash/src/data.rs +++ b/rog-slash/src/data.rs @@ -28,13 +28,14 @@ impl FromStr for SlashType { #[typeshare] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] pub enum SlashMode { Bounce = 0x10, Slash = 0x12, Loading = 0x13, BitStream = 0x1d, Transmission = 0x1a, + #[default] Flow = 0x19, Flux = 0x25, Phantom = 0x24, @@ -47,12 +48,6 @@ pub enum SlashMode { Buzzer = 0x44, } -impl Default for SlashMode { - fn default() -> Self { - SlashMode::Flow - } -} - impl FromStr for SlashMode { type Err = SlashError;