From 8d30282edfc018911b197f1e1d7649096473ea00 Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Thu, 28 Mar 2024 01:03:30 +0000 Subject: [PATCH 01/12] Update default.md --- .gitlab/issue_templates/default.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/issue_templates/default.md b/.gitlab/issue_templates/default.md index 70ddcf78..3f876755 100644 --- a/.gitlab/issue_templates/default.md +++ b/.gitlab/issue_templates/default.md @@ -16,7 +16,7 @@ ## Relevant logs and/or screenshots -(run `journalctl -b -u supergfxd > ~/supergfxd.log` and attach `~/supergfxd.log`) +(run `journalctl -b -u asusd > ~/asusd.log` and attach `~/asusd.log`) (Paste any relevant logs - use code blocks (```) to format console output, logs, and code, as it's very hard to read otherwise.) From 5178bf1d1ac192d9581d4e0a9469aa34471fb91a Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 3 Apr 2024 16:08:51 +1300 Subject: [PATCH 02/12] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2a797a0..abab36b6 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ A gui is now in the repo - ROG Control Center. At this time it is still a WIP, b # BUILDING -Requirements are rust >= 1.75 installed from rustup.io if the distro provided version is too old, and `make`. +Rust and cargo are required, they can be installed from [rustup.rs](https://rustup.rs/) or from the distro repos if newer than 1.75. **Ubuntu (unsuported):** From 2f844ac1514402d41cb1b61a0bdfaf8f819588c4 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 3 Apr 2024 16:14:18 +1300 Subject: [PATCH 03/12] Cleanup --- asusd/src/ctrl_aura/manager.rs | 2 -- config-traits/src/lib.rs | 1 + rog-control-center/src/lib.rs | 2 +- rog-control-center/translations/en/rog-control-center.po | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/asusd/src/ctrl_aura/manager.rs b/asusd/src/ctrl_aura/manager.rs index 54130edf..feeea021 100644 --- a/asusd/src/ctrl_aura/manager.rs +++ b/asusd/src/ctrl_aura/manager.rs @@ -5,7 +5,6 @@ // - If udev sees device removed then remove the zbus path use std::collections::HashSet; -use std::time::Duration; use log::{debug, error, info, warn}; use mio::{Events, Interest, Poll, Token}; @@ -14,7 +13,6 @@ use rog_aura::usb::AuraDevice; use rog_platform::hid_raw::HidRaw; use tokio::task::spawn_blocking; use udev::{Device, MonitorBuilder}; -// use zbus::fdo::ObjectManager; use zbus::object_server::SignalContext; use zbus::zvariant::{ObjectPath, OwnedObjectPath}; use zbus::Connection; diff --git a/config-traits/src/lib.rs b/config-traits/src/lib.rs index f34d1ab9..ff2d44a3 100644 --- a/config-traits/src/lib.rs +++ b/config-traits/src/lib.rs @@ -92,6 +92,7 @@ where .read(true) .write(true) .create(true) + .truncate(false) .open(self.file_path()) .unwrap_or_else(|e| panic!("Could not open {:?} {e}", self.file_path())) } diff --git a/rog-control-center/src/lib.rs b/rog-control-center/src/lib.rs index 2ecce54f..5217d7c0 100644 --- a/rog-control-center/src/lib.rs +++ b/rog-control-center/src/lib.rs @@ -89,7 +89,7 @@ pub fn on_tmp_dir_exists() -> Result { ipc_file.write_all(&[SHOW_GUI, 0])?; // tiny sleep to give the app a chance to respond sleep(Duration::from_millis(10)); - ipc_file.read(&mut buf).ok(); + ipc_file.read_exact(&mut buf).ok(); // First entry is the actual state if buf[0] == SHOWING_GUI { diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 588c7c76..9ba481ec 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-03-23 01:29+0000\n" +"POT-Creation-Date: 2024-04-03 03:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From 00babaf9497e2eed737c7c37013088afce2acd75 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 3 Apr 2024 16:15:02 +1300 Subject: [PATCH 04/12] Update translations --- rog-control-center/translations/en/rog-control-center.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 9ba481ec..c61cc146 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-03 03:12+0000\n" +"POT-Creation-Date: 2024-04-03 03:14+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From a271ffbb109a680d9c7b46f70e36335b332e99b0 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Thu, 4 Apr 2024 09:58:40 +1300 Subject: [PATCH 05/12] rcc: run as app only on Ally --- asusd/src/ctrl_aura/controller.rs | 13 +- rog-control-center/src/main.rs | 11 +- .../translations/en/rog-control-center.po | 276 +++++++++--------- 3 files changed, 157 insertions(+), 143 deletions(-) diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index 463ff9ad..0a906640 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -353,6 +353,7 @@ mod tests { use crate::ctrl_aura::controller::LEDNode; #[test] + #[ignore = "Unable to run in CI as the HIDRAW device is required"] fn create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); @@ -366,7 +367,10 @@ mod tests { }; let mut controller = CtrlKbdLed { led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap()), + led_node: LEDNode::Rog( + KeyboardLed::default(), + HidRaw::new(AuraDevice::X19b6.into()).unwrap(), + ), supported_data: supported_basic_modes, per_key_mode_active: false, config, @@ -391,6 +395,8 @@ mod tests { } #[test] + #[ignore = "Unable to run in CI as the HIDRAW device is required"] + // TODO: use sim device fn next_mode_create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); @@ -404,7 +410,10 @@ mod tests { }; let mut controller = CtrlKbdLed { led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap()), + led_node: LEDNode::Rog( + KeyboardLed::default(), + HidRaw::new(AuraDevice::X19b6.into()).unwrap(), + ), supported_data: supported_basic_modes, per_key_mode_active: false, config, diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index fbda2320..e754a3f8 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -94,18 +94,23 @@ fn main() -> Result<()> { if cli_parsed.height_fullscreen != 0 { config.fullscreen_height = cli_parsed.height_fullscreen; } - config.write(); } else if cli_parsed.windowed { config.start_fullscreen = false; - config.write(); + } + + if is_rog_ally { + config.enable_notifications = false; + config.enable_tray_icon = false; + config.run_in_background = false; + config.startup_in_background = false; } if config.startup_in_background { config.run_in_background = true; - config.write(); } else { get_ipc_file().unwrap().write_all(&[SHOW_GUI, 0]).unwrap(); } + config.write(); let enabled_notifications = EnabledNotifications::tokio_mutex(&config); let aura_creation = AuraCreation::new(cli_parsed.board_name, cli_parsed.layout_viewing)?; diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index c61cc146..394fb28a 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-03 03:14+0000\n" +"POT-Creation-Date: 2024-04-03 20:51+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -12,46 +12,6 @@ msgstr "" "Language: \n" "Plural-Forms: nplurals=1; plural=0;\n" -#: rog-control-center/ui/main_window.slint:50 -msgctxt "MainWindow" -msgid "ROG" -msgstr "" - -#: rog-control-center/ui/main_window.slint:52 -msgctxt "Menu1" -msgid "System Control" -msgstr "" - -#: rog-control-center/ui/main_window.slint:53 -msgctxt "Menu2" -msgid "Keyboard Aura" -msgstr "" - -#: rog-control-center/ui/main_window.slint:54 -msgctxt "Menu3" -msgid "AniMe Matrix" -msgstr "" - -#: rog-control-center/ui/main_window.slint:55 -msgctxt "Menu4" -msgid "Fan Curves" -msgstr "" - -#: rog-control-center/ui/main_window.slint:56 -msgctxt "Menu5" -msgid "App Settings" -msgstr "" - -#: rog-control-center/ui/main_window.slint:57 -msgctxt "Menu6" -msgid "About" -msgstr "" - -#: rog-control-center/ui/main_window.slint:69 -msgctxt "MainWindow" -msgid "Quit" -msgstr "" - #: rog-control-center/ui/pages/anime.slint:6 msgctxt "Anime Brightness" msgid "Off" @@ -197,91 +157,6 @@ msgctxt "PageAppSettings" msgid "Enable change notifications" msgstr "" -#: rog-control-center/ui/pages/aura.slint:27 -msgctxt "PageAura" -msgid "Brightness" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:38 -msgctxt "PageAura" -msgid "Aura mode" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:56 -msgctxt "PageAura" -msgid "Colour 1" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:82 -msgctxt "PageAura" -msgid "Colour 2" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:114 -msgctxt "PageAura" -msgid "Zone" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:137 -msgctxt "PageAura" -msgid "Direction" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:159 -msgctxt "PageAura" -msgid "Speed" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:180 -msgctxt "PageAura" -msgid "Power Settings" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:211 rog-control-center/ui/pages/aura.slint:369 rog-control-center/ui/pages/aura.slint:434 -msgctxt "PageAura" -msgid "Keyboard" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:235 -msgctxt "PageAura" -msgid "Lid Logo" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:259 -msgctxt "PageAura" -msgid "Lightbar" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:283 -msgctxt "PageAura" -msgid "Lid Zone" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:307 -msgctxt "PageAura" -msgid "Rear Glow" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:375 rog-control-center/ui/pages/aura.slint:440 -msgctxt "PageAura" -msgid "Boot" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:380 rog-control-center/ui/pages/aura.slint:445 -msgctxt "PageAura" -msgid "Awake" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:385 rog-control-center/ui/pages/aura.slint:450 -msgctxt "PageAura" -msgid "Sleep" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:390 rog-control-center/ui/pages/aura.slint:455 -msgctxt "PageAura" -msgid "Shutdown" -msgstr "" - #: rog-control-center/ui/pages/fans.slint:27 msgctxt "FanTab" msgid "This fan is not avilable on this machine" @@ -487,6 +362,111 @@ msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" +#: rog-control-center/ui/pages/aura.slint:27 +msgctxt "PageAura" +msgid "Brightness" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:38 +msgctxt "PageAura" +msgid "Aura mode" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:56 +msgctxt "PageAura" +msgid "Colour 1" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:82 +msgctxt "PageAura" +msgid "Colour 2" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:114 +msgctxt "PageAura" +msgid "Zone" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:137 +msgctxt "PageAura" +msgid "Direction" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:159 +msgctxt "PageAura" +msgid "Speed" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:180 +msgctxt "PageAura" +msgid "Power Settings" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:211 rog-control-center/ui/pages/aura.slint:369 rog-control-center/ui/pages/aura.slint:434 +msgctxt "PageAura" +msgid "Keyboard" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:235 +msgctxt "PageAura" +msgid "Lid Logo" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:259 +msgctxt "PageAura" +msgid "Lightbar" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:283 +msgctxt "PageAura" +msgid "Lid Zone" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:307 +msgctxt "PageAura" +msgid "Rear Glow" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:375 rog-control-center/ui/pages/aura.slint:440 +msgctxt "PageAura" +msgid "Boot" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:380 rog-control-center/ui/pages/aura.slint:445 +msgctxt "PageAura" +msgid "Awake" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:385 rog-control-center/ui/pages/aura.slint:450 +msgctxt "PageAura" +msgid "Sleep" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:390 rog-control-center/ui/pages/aura.slint:455 +msgctxt "PageAura" +msgid "Shutdown" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:32 +msgctxt "AuraPowerGroup" +msgid "Boot" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:42 +msgctxt "AuraPowerGroup" +msgid "Awake" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:52 +msgctxt "AuraPowerGroup" +msgid "Sleep" +msgstr "" + +#: rog-control-center/ui/widgets/aura_power.slint:62 +msgctxt "AuraPowerGroup" +msgid "Shutdown" +msgstr "" + #: rog-control-center/ui/types/aura_types.slint:69 msgctxt "Aura brightness" msgid "Off" @@ -647,23 +627,43 @@ msgctxt "Aura speed" msgid "High" msgstr "" -#: rog-control-center/ui/widgets/aura_power.slint:32 -msgctxt "AuraPowerGroup" -msgid "Boot" +#: rog-control-center/ui/main_window.slint:50 +msgctxt "MainWindow" +msgid "ROG" msgstr "" -#: rog-control-center/ui/widgets/aura_power.slint:42 -msgctxt "AuraPowerGroup" -msgid "Awake" +#: rog-control-center/ui/main_window.slint:52 +msgctxt "Menu1" +msgid "System Control" msgstr "" -#: rog-control-center/ui/widgets/aura_power.slint:52 -msgctxt "AuraPowerGroup" -msgid "Sleep" +#: rog-control-center/ui/main_window.slint:53 +msgctxt "Menu2" +msgid "Keyboard Aura" msgstr "" -#: rog-control-center/ui/widgets/aura_power.slint:62 -msgctxt "AuraPowerGroup" -msgid "Shutdown" +#: rog-control-center/ui/main_window.slint:54 +msgctxt "Menu3" +msgid "AniMe Matrix" +msgstr "" + +#: rog-control-center/ui/main_window.slint:55 +msgctxt "Menu4" +msgid "Fan Curves" +msgstr "" + +#: rog-control-center/ui/main_window.slint:56 +msgctxt "Menu5" +msgid "App Settings" +msgstr "" + +#: rog-control-center/ui/main_window.slint:57 +msgctxt "Menu6" +msgid "About" +msgstr "" + +#: rog-control-center/ui/main_window.slint:69 +msgctxt "MainWindow" +msgid "Quit" msgstr "" From ca0d8bda4be299a99fb4c50fd64f2053f47826c7 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 5 Apr 2024 16:00:20 +1300 Subject: [PATCH 06/12] Update readme. Fix tray startup --- Cargo.lock | 207 +++++++++--------- Cargo.toml | 4 +- Makefile | 3 + README.md | 35 ++- rog-control-center/src/tray.rs | 88 ++++---- .../translations/en/rog-control-center.po | 2 +- 6 files changed, 168 insertions(+), 171 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 847228f6..9627694b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" [[package]] name = "asusctl" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "asusd", "cargo-husky", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "asusd" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "concat-idents", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "asusd-user" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "config-traits", @@ -205,7 +205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258b52a1aa741b9f09783b2d86cf0aeeb617bbf847f6933340a39644227acbdb" dependencies = [ "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] @@ -229,16 +229,16 @@ checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", "event-listener 5.2.0", - "event-listener-strategy 0.5.0", + "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316" dependencies = [ "async-lock 3.3.0", "async-task", @@ -360,19 +360,21 @@ dependencies = [ [[package]] name = "async-process" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451e3cf68011bd56771c79db04a9e333095ab6349f7e47592b788e9b98720cc8" +checksum = "d999d925640d51b662b7b4e404224dd81de70f4aa4a199383c2c5e5b86885fa3" dependencies = [ "async-channel 2.2.0", "async-io 2.3.2", "async-lock 3.3.0", "async-signal", + "async-task", "blocking", "cfg-if", "event-listener 5.2.0", "futures-lite 2.3.0", "rustix 0.38.32", + "tracing", "windows-sys 0.52.0", ] @@ -384,7 +386,7 @@ checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -419,7 +421,7 @@ checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -437,7 +439,7 @@ dependencies = [ "derive_utils", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -511,7 +513,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.55", + "syn 2.0.58", "which", ] @@ -594,9 +596,9 @@ checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "by_address" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9330396d4065c0788ac665e5ba4857c4744f5ff4239b6f06493aca55e0e08" +checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06" [[package]] name = "bytemuck" @@ -615,7 +617,7 @@ checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -716,9 +718,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", @@ -824,7 +826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -838,7 +840,7 @@ dependencies = [ [[package]] name = "config-traits" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "log", @@ -852,7 +854,7 @@ dependencies = [ [[package]] name = "const-field-offset" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "const-field-offset-macro", "field-offset", @@ -861,11 +863,11 @@ dependencies = [ [[package]] name = "const-field-offset-macro" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -906,9 +908,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-graphics" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -948,7 +950,7 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpuctl" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" [[package]] name = "cpufeatures" @@ -1031,7 +1033,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1087,7 +1089,7 @@ checksum = "61bb5a1014ce6dfc2a378578509abe775a5aa06bff584a547555d9efdb81b926" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1158,7 +1160,7 @@ dependencies = [ [[package]] name = "dmi_id" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "log", "udev 0.8.0", @@ -1275,7 +1277,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1367,9 +1369,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ "event-listener 5.2.0", "pin-project-lite", @@ -1553,7 +1555,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -1928,8 +1930,8 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "i-slint-backend-linuxkms" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "calloop", "drm", @@ -1948,8 +1950,8 @@ dependencies = [ [[package]] name = "i-slint-backend-qt" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "const-field-offset", "i-slint-common", @@ -1960,8 +1962,8 @@ dependencies = [ [[package]] name = "i-slint-backend-selector" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "cfg-if", "i-slint-backend-linuxkms", @@ -1973,8 +1975,8 @@ dependencies = [ [[package]] name = "i-slint-backend-winit" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "bytemuck", "cfg-if", @@ -2006,8 +2008,8 @@ dependencies = [ [[package]] name = "i-slint-common" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "cfg-if", "derive_more", @@ -2017,8 +2019,8 @@ dependencies = [ [[package]] name = "i-slint-compiler" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "by_address", "codemap", @@ -2046,8 +2048,8 @@ dependencies = [ [[package]] name = "i-slint-core" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "auto_enums", "bytemuck", @@ -2091,17 +2093,17 @@ dependencies = [ [[package]] name = "i-slint-core-macros" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "i-slint-renderer-femtovg" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "cfg-if", "const-field-offset", @@ -2131,8 +2133,8 @@ dependencies = [ [[package]] name = "i-slint-renderer-skia" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "bytemuck", "cfg-if", @@ -2484,9 +2486,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libredox" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ "bitflags 2.5.0", "libc", @@ -2495,13 +2497,12 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.5.0", "libc", - "redox_syscall 0.4.1", ] [[package]] @@ -2682,9 +2683,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" @@ -2911,7 +2912,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3086,14 +3087,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -3212,7 +3213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3361,12 +3362,12 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", - "libredox 0.0.1", + "libredox 0.1.3", "thiserror", ] @@ -3424,7 +3425,7 @@ dependencies = [ [[package]] name = "rog-control-center" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "asusd", "betrayer", @@ -3463,7 +3464,7 @@ dependencies = [ [[package]] name = "rog_anime" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "dmi_id", @@ -3480,7 +3481,7 @@ dependencies = [ [[package]] name = "rog_aura" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "dmi_id", @@ -3494,7 +3495,7 @@ dependencies = [ [[package]] name = "rog_dbus" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "asusd", "cargo-husky", @@ -3507,7 +3508,7 @@ dependencies = [ [[package]] name = "rog_platform" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "concat-idents", @@ -3524,7 +3525,7 @@ dependencies = [ [[package]] name = "rog_profiles" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "cargo-husky", "log", @@ -3538,7 +3539,7 @@ dependencies = [ [[package]] name = "rog_simulators" -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" dependencies = [ "glam", "log", @@ -3766,7 +3767,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3788,7 +3789,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -3887,8 +3888,8 @@ dependencies = [ [[package]] name = "slint" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "const-field-offset", "i-slint-backend-selector", @@ -3903,8 +3904,8 @@ dependencies = [ [[package]] name = "slint-build" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "i-slint-compiler", "spin_on", @@ -3914,8 +3915,8 @@ dependencies = [ [[package]] name = "slint-macros" -version = "1.5.1" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +version = "1.6.0" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "i-slint-compiler", "proc-macro2", @@ -4108,13 +4109,13 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] name = "supergfxctl" version = "5.2.2" -source = "git+https://gitlab.com/asus-linux/supergfxctl.git#68c12374d2cc20e5503b7694168afa2bf52af705" +source = "git+https://gitlab.com/asus-linux/supergfxctl.git#a645c15fdb2eee6b16c8213eebcd90df2c950cdb" dependencies = [ "log", "logind-zbus", @@ -4149,9 +4150,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -4239,7 +4240,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4336,9 +4337,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "libc", @@ -4358,7 +4359,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4445,7 +4446,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4488,7 +4489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ecce25dea8aeaadc44909f4c1226d22d84512fccd07d22447ecbad176bc09545" dependencies = [ "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4690,7 +4691,7 @@ dependencies = [ [[package]] name = "vtable" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "const-field-offset", "portable-atomic", @@ -4701,11 +4702,11 @@ dependencies = [ [[package]] name = "vtable-macro" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#d73de5db8ac10b0b46a1c28c85722902dcf70d30" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] @@ -4751,7 +4752,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -4785,7 +4786,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5461,9 +5462,9 @@ checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" [[package]] name = "xml-rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "xmlwriter" @@ -5523,7 +5524,7 @@ dependencies = [ "async-fs 2.1.1", "async-io 2.3.2", "async-lock 3.3.0", - "async-process 2.1.0", + "async-process 2.2.0", "async-recursion", "async-task", "async-trait", @@ -5618,7 +5619,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.58", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3d7509a1..3cbeb525 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default-members = [ resolver = "2" [workspace.package] -version = "6.0.0-alpha1" +version = "6.0.0-alpha2" rust-version = "1.76" [workspace.dependencies] @@ -76,7 +76,7 @@ lto = "fat" debug = false opt-level = 3 panic = "abort" -#codegen-units = 1 +codegen-units = 1 [profile.dev] debug = true diff --git a/Makefile b/Makefile index 8acce3b6..1c74f4c8 100644 --- a/Makefile +++ b/Makefile @@ -132,6 +132,9 @@ introspect: xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Properties"]' bindings/dbus-xml/org-asuslinux-* xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Peer"]' bindings/dbus-xml/org-asuslinux-* +translate: + find -name \*.slint | xargs slint-tr-extractor -o rog-control-center/translations/en/rog-control-center.po + build: ifeq ($(VENDORED),1) cargo vendor diff --git a/README.md b/README.md index abab36b6..e2d263dd 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ and AniMe parts should work regardless of your latop make. ## Implemented +The list is a bit outdated as many features have been enabled in the Linux kernel with upstream patches and then supported in asusctl suite. + - [X] System daemon - [X] GUI app (includes tray and notifications) - [X] Setting/modifying built-in LED modes @@ -70,26 +72,10 @@ A gui is now in the repo - ROG Control Center. At this time it is still a WIP, b Rust and cargo are required, they can be installed from [rustup.rs](https://rustup.rs/) or from the distro repos if newer than 1.75. -**Ubuntu (unsuported):** - - apt install libinput-dev libseat-dev libpango1.0-dev libgdk-pixbuf-2.0-dev libglib2.0-dev cmake libclang-dev libudev-dev libayatana-appindicator3-1 - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - source "$HOME/.cargo/env" - make - sudo make install - -**popos (unsuported):** - - sudo apt install cmake libinput-dev libseat-dev libclang-dev libudev-dev libclang-dev libglib2.0-dev libatkmm-1.6-dev libpangomm-1.4-dev librust-gdk-pixbuf-dev - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - source "$HOME/.cargo/env" - make - sudo make install - - **fedora:** - dnf install cmake clang-devel libinput-devel libseat-devel systemd-devel glib2-devel cairo-devel atkmm-devel pangomm-devel gdk-pixbuf2-devel libappindicator-gtk3 + dnf install cmake clang-devel libinput-devel libseat-devel libgbm-devel libxkbcommon-devel systemd-devel \ + libdrm-devel expat-devel pcre2-devel libzstd-devellibappindicator-gtk3 make sudo make install @@ -98,28 +84,33 @@ Rust and cargo are required, they can be installed from [rustup.rs](https://rust Works with KDE Plasma (without GTK packages) zypper in -t pattern devel_basis - zypper in rustup make cmake libinput-devel libseat-devel systemd-devel clang-devel llvm-devel gdk-pixbuf-devel cairo-devel pango-devel freetype-devel libexpat-devel libayatana-indicator3-7 + zypper in rustup make cmake libinput-devel libseat-devel libgbm-devel systemd-devel clang-devel llvm-devel gdk-pixbuf-devel cairo-devel pango-devel freetype-devel libexpat-devel libayatana-indicator3-7 make sudo make install +**Ubuntu, Popos (unsuported):** + +instructions removed as outdated + ## Installing - Fedora copr = https://copr.fedorainfracloud.org/coprs/lukenukem/asus-linux/ - openSUSE = https://download.opensuse.org/repositories/home:/luke_nukem:/asus/ -- Ubuntu = not supported due to packaging woes, but you can build and install on your own. ======= The default init method is to use the udev rule, this ensures that the service is started when the device is initialised and ready. +You may also need to activate the service for debian install. If running Pop!_OS, I suggest disabling `system76-power` gnome-shell extension and systemd service. + +## Upgrading + If you are upgrading from a previous installed version, you will need to restart the service or reboot. ``` $ systemctl daemon-reload && systemctl restart asusd ``` -You may also need to activate the service for debian install. If running Pop!_OS, I suggest disabling `system76-power` gnome-shell extension and systemd service. - ## Uninstalling Run `sudo make uninstall` in the source repo, and remove `/etc/asusd/`. diff --git a/rog-control-center/src/tray.rs b/rog-control-center/src/tray.rs index c3138cc5..4fa4ed61 100644 --- a/rog-control-center/src/tray.rs +++ b/rog-control-center/src/tray.rs @@ -137,59 +137,61 @@ pub fn init_tray( config: Arc>, ) { std::thread::spawn(move || { - debug!("init_tray"); - let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png")); let rog_red = read_icon(&PathBuf::from("asus_notif_red.png")); - let rog_green = read_icon(&PathBuf::from("asus_notif_green.png")); - let rog_white = read_icon(&PathBuf::from("asus_notif_white.png")); - let gpu_integrated = read_icon(&PathBuf::from("rog-control-center.png")); - ICONS.get_or_init(|| Icons { - rog_blue, - rog_red: rog_red.clone(), - rog_green, - rog_white, - gpu_integrated, - }); - let conn = zbus::blocking::Connection::system().unwrap(); - let gfx_proxy = GfxProxy::new(&conn).unwrap(); - let mut supergfx_active = false; - if gfx_proxy.mode().is_ok() { - supergfx_active = true; - if let Ok(version) = gfx_proxy.version() { - if let Some(version) = Versioning::new(&version) { - let curr_gfx = Versioning::new("5.0.3-RC4").unwrap(); - warn!("supergfxd version = {version}"); - if version < curr_gfx { - // Don't allow mode changing if too old a version - warn!("supergfxd found but is too old to use"); - // tray.gfx_proxy_is_active = false; - } - } - } - }; - - let tray = TrayIconBuilder::::new() + if let Ok(tray) = TrayIconBuilder::::new() .with_icon(rog_red.clone()) .with_tooltip(TRAY_LABEL) .with_menu(build_menu()) .build(do_action) - .unwrap(); - info!("Started ROGTray"); - loop { - // let states = states.clone(); - if let Ok(mut lock) = states.lock() { - if lock.tray_should_update { - set_tray_icon_and_tip(&lock, &tray, supergfx_active); - lock.tray_should_update = false; - if let Ok(lock) = config.try_lock() { - if !lock.enable_tray_icon { - return; + .map_err(|e| log::error!("Tray unable to be initialised: {e:?}")) + { + info!("Tray started"); + let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png")); + let rog_green = read_icon(&PathBuf::from("asus_notif_green.png")); + let rog_white = read_icon(&PathBuf::from("asus_notif_white.png")); + let gpu_integrated = read_icon(&PathBuf::from("rog-control-center.png")); + ICONS.get_or_init(|| Icons { + rog_blue, + rog_red: rog_red.clone(), + rog_green, + rog_white, + gpu_integrated, + }); + + let conn = zbus::blocking::Connection::system().unwrap(); + let gfx_proxy = GfxProxy::new(&conn).unwrap(); + let mut supergfx_active = false; + if gfx_proxy.mode().is_ok() { + supergfx_active = true; + if let Ok(version) = gfx_proxy.version() { + if let Some(version) = Versioning::new(&version) { + let curr_gfx = Versioning::new("5.0.3-RC4").unwrap(); + warn!("supergfxd version = {version}"); + if version < curr_gfx { + // Don't allow mode changing if too old a version + warn!("supergfxd found but is too old to use"); + // tray.gfx_proxy_is_active = false; } } } + }; + + info!("Started ROGTray"); + loop { + if let Ok(mut lock) = states.lock() { + if lock.tray_should_update { + set_tray_icon_and_tip(&lock, &tray, supergfx_active); + lock.tray_should_update = false; + if let Ok(lock) = config.try_lock() { + if !lock.enable_tray_icon { + return; + } + } + } + } + sleep(Duration::from_millis(50)); } - sleep(Duration::from_millis(50)); } }); } diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 394fb28a..a5ac5b60 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-03 20:51+0000\n" +"POT-Creation-Date: 2024-04-03 20:58+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From 4701c019a8346c7e319569445f285e2b2bbd3a73 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 5 Apr 2024 20:19:07 +1300 Subject: [PATCH 07/12] Major cleanup of older gui state code --- asusctl/examples/anime-diag-png.rs | 12 +- asusctl/examples/anime-diag.rs | 10 +- asusctl/examples/anime-gif.rs | 12 +- asusctl/examples/anime-grid.rs | 9 +- asusctl/examples/anime-outline.rs | 8 +- asusctl/examples/anime-png.rs | 12 +- asusctl/examples/anime-spinning.rs | 12 +- asusctl/examples/aura-zoned-breathe.rs | 8 +- asusctl/src/main.rs | 142 +++---- asusd-user/src/ctrl_anime.rs | 22 +- asusd-user/src/daemon.rs | 43 +- asusd/src/ctrl_fancurves.rs | 16 +- asusd/src/ctrl_platform.rs | 3 +- rog-aura/src/lib.rs | 4 + rog-control-center/src/lib.rs | 10 - rog-control-center/src/main.rs | 51 +-- rog-control-center/src/system_state.rs | 373 +----------------- rog-control-center/src/tray.rs | 13 +- rog-control-center/src/update_and_notify.rs | 262 +----------- .../translations/en/rog-control-center.po | 2 +- rog-dbus/src/lib.rs | 120 ------ rog-dbus/src/zbus_platform.rs | 3 + rog-platform/src/platform.rs | 33 +- rog-profiles/src/lib.rs | 6 +- 24 files changed, 238 insertions(+), 948 deletions(-) diff --git a/asusctl/examples/anime-diag-png.rs b/asusctl/examples/anime-diag-png.rs index 456d62bf..b4285601 100644 --- a/asusctl/examples/anime-diag-png.rs +++ b/asusctl/examples/anime-diag-png.rs @@ -5,10 +5,12 @@ use std::process::exit; use rog_anime::usb::get_anime_type; use rog_anime::{AnimeDiagonal, AnimeType}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; fn main() -> Result<(), Box> { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); let args: Vec = env::args().collect(); if args.len() != 3 { @@ -26,11 +28,7 @@ fn main() -> Result<(), Box> { let anime_type = get_anime_type()?; - client - .proxies() - .anime() - .write(matrix.into_data_buffer(anime_type)?) - .unwrap(); + proxy.write(matrix.into_data_buffer(anime_type)?).unwrap(); Ok(()) } diff --git a/asusctl/examples/anime-diag.rs b/asusctl/examples/anime-diag.rs index 874689d8..21cc1722 100644 --- a/asusctl/examples/anime-diag.rs +++ b/asusctl/examples/anime-diag.rs @@ -3,7 +3,8 @@ use std::time::Duration; use rog_anime::usb::get_anime_type; use rog_anime::{AnimeDiagonal, AnimeType}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; // In usable data: // Top row start at 1, ends at 32 @@ -11,7 +12,8 @@ use rog_dbus::RogDbusClientBlocking; // 74w x 36h diagonal used by the windows app fn main() { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); for step in (2..50).rev() { let mut matrix = AnimeDiagonal::new(AnimeType::GA401, None); @@ -28,9 +30,7 @@ fn main() { } let anime_type = get_anime_type().unwrap(); - client - .proxies() - .anime() + proxy .write(matrix.into_data_buffer(anime_type).unwrap()) .unwrap(); sleep(Duration::from_millis(300)); diff --git a/asusctl/examples/anime-gif.rs b/asusctl/examples/anime-gif.rs index 994ef70b..044b35ba 100644 --- a/asusctl/examples/anime-gif.rs +++ b/asusctl/examples/anime-gif.rs @@ -4,10 +4,12 @@ use std::thread::sleep; use rog_anime::usb::get_anime_type; use rog_anime::{ActionData, ActionLoader, Sequences}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; fn main() { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); let args: Vec = env::args().collect(); if args.len() != 3 { @@ -33,11 +35,7 @@ fn main() { for action in seq.iter() { if let ActionData::Animation(frames) = action { for frame in frames.frames() { - client - .proxies() - .anime() - .write(frame.frame().clone()) - .unwrap(); + proxy.write(frame.frame().clone()).unwrap(); sleep(frame.delay()); } } diff --git a/asusctl/examples/anime-grid.rs b/asusctl/examples/anime-grid.rs index b66f8529..83def5ea 100644 --- a/asusctl/examples/anime-grid.rs +++ b/asusctl/examples/anime-grid.rs @@ -2,7 +2,8 @@ use std::convert::TryFrom; use rog_anime::usb::get_anime_type; use rog_anime::{AnimeDataBuffer, AnimeGrid}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; // In usable data: // Top row start at 1, ends at 32 @@ -10,7 +11,9 @@ use rog_dbus::RogDbusClientBlocking; // 74w x 36h diagonal used by the windows app fn main() { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); + let anime_type = get_anime_type().unwrap(); let mut matrix = AnimeGrid::new(anime_type); let tmp = matrix.get_mut(); @@ -43,5 +46,5 @@ fn main() { let matrix = ::try_from(matrix).unwrap(); - client.proxies().anime().write(matrix).unwrap(); + proxy.write(matrix).unwrap(); } diff --git a/asusctl/examples/anime-outline.rs b/asusctl/examples/anime-outline.rs index 981a736d..140427a6 100644 --- a/asusctl/examples/anime-outline.rs +++ b/asusctl/examples/anime-outline.rs @@ -1,12 +1,14 @@ use rog_anime::usb::get_anime_type; use rog_anime::AnimeDataBuffer; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; // In usable data: // Top row start at 1, ends at 32 fn main() { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); let anime_type = get_anime_type().unwrap(); let mut matrix = AnimeDataBuffer::new(anime_type); matrix.data_mut()[1] = 100; // start = 1 @@ -127,5 +129,5 @@ fn main() { matrix.data_mut()[1244] = 100; // end println!("{:?}", &matrix); - client.proxies().anime().write(matrix).unwrap(); + proxy.write(matrix).unwrap(); } diff --git a/asusctl/examples/anime-png.rs b/asusctl/examples/anime-png.rs index aa874631..add92456 100644 --- a/asusctl/examples/anime-png.rs +++ b/asusctl/examples/anime-png.rs @@ -6,10 +6,12 @@ use std::process::exit; use rog_anime::usb::get_anime_type; use rog_anime::{AnimeDataBuffer, AnimeImage, Vec2}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; fn main() -> Result<(), Box> { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); let args: Vec = env::args().collect(); if args.len() != 7 { @@ -31,11 +33,7 @@ fn main() -> Result<(), Box> { anime_type, )?; - client - .proxies() - .anime() - .write(::try_from(&matrix)?) - .unwrap(); + proxy.write(::try_from(&matrix)?).unwrap(); Ok(()) } diff --git a/asusctl/examples/anime-spinning.rs b/asusctl/examples/anime-spinning.rs index b40a61db..611e7db2 100644 --- a/asusctl/examples/anime-spinning.rs +++ b/asusctl/examples/anime-spinning.rs @@ -9,10 +9,12 @@ use std::time::Duration; use rog_anime::usb::get_anime_type; use rog_anime::{AnimeDataBuffer, AnimeImage, Vec2}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use zbus::blocking::Connection; fn main() -> Result<(), Box> { - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AnimeProxyBlocking::new(&conn).unwrap(); let args: Vec = env::args().collect(); if args.len() != 7 { @@ -41,11 +43,7 @@ fn main() -> Result<(), Box> { } matrix.update(); - client - .proxies() - .anime() - .write(::try_from(&matrix)?) - .unwrap(); + proxy.write(::try_from(&matrix)?).unwrap(); sleep(Duration::from_micros(500)); } } diff --git a/asusctl/examples/aura-zoned-breathe.rs b/asusctl/examples/aura-zoned-breathe.rs index c0c27907..dbbf1f25 100644 --- a/asusctl/examples/aura-zoned-breathe.rs +++ b/asusctl/examples/aura-zoned-breathe.rs @@ -5,12 +5,14 @@ use rog_aura::advanced::LedCode; use rog_aura::effects::{AdvancedEffects, Effect}; use rog_aura::layouts::KeyLayout; use rog_aura::Colour; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_aura::AuraProxyBlocking; +use zbus::blocking::Connection; fn main() -> Result<(), Box> { let layout = KeyLayout::default_layout(); - let (client, _) = RogDbusClientBlocking::new().unwrap(); + let conn = Connection::system().unwrap(); + let proxy = AuraProxyBlocking::new(&conn).unwrap(); let mut seq = AdvancedEffects::new(true); @@ -62,7 +64,7 @@ fn main() -> Result<(), Box> { seq.next_state(&layout); let packets = seq.create_packets(); - client.proxies().aura().direct_addressing_raw(packets)?; + proxy.direct_addressing_raw(packets)?; std::thread::sleep(std::time::Duration::from_millis(33)); } } diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 3d72cb51..596a650a 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -15,10 +15,13 @@ use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, use rog_aura::power::KbAuraPowerState; use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev}; use rog_aura::{self, AuraEffect}; +use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; +use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_profiles::error::ProfileError; +use zbus::blocking::Connection; use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::cli_opts::*; @@ -44,13 +47,21 @@ fn main() { } }; - if let Ok((dbus, _)) = RogDbusClientBlocking::new().map_err(|e| { + let conn = Connection::system().unwrap(); + if let Ok(platform_proxy) = PlatformProxyBlocking::new(&conn).map_err(|e| { check_service("asusd"); println!("\nError: {e}\n"); print_info(); }) { - let supported_properties = dbus.proxies().platform().supported_properties().unwrap(); - let supported_interfaces = dbus.proxies().platform().supported_interfaces().unwrap(); + let self_version = env!("CARGO_PKG_VERSION"); + let asusd_version = platform_proxy.version().unwrap(); + if asusd_version != self_version { + println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); + return; + } + + let supported_properties = platform_proxy.supported_properties().unwrap(); + let supported_interfaces = platform_proxy.supported_interfaces().unwrap(); if parsed.version { println!("asusctl v{}", env!("CARGO_PKG_VERSION")); @@ -58,7 +69,7 @@ fn main() { print_info(); } - if let Err(err) = do_parsed(&parsed, &supported_interfaces, &supported_properties, &dbus) { + if let Err(err) = do_parsed(&parsed, &supported_interfaces, &supported_properties, conn) { print_error_help(&*err, &supported_interfaces, &supported_properties); } } @@ -143,19 +154,23 @@ fn do_parsed( parsed: &CliStart, supported_interfaces: &[String], supported_properties: &[Properties], - dbus: &RogDbusClientBlocking<'_>, + conn: Connection, ) -> Result<(), Box> { match &parsed.command { Some(CliCommand::LedMode(mode)) => handle_led_mode(&find_aura_iface()?, mode)?, Some(CliCommand::LedPow1(pow)) => handle_led_power1(&find_aura_iface()?, pow)?, Some(CliCommand::LedPow2(pow)) => handle_led_power2(&find_aura_iface()?, pow)?, - Some(CliCommand::Profile(cmd)) => handle_throttle_profile(dbus, supported_properties, cmd)?, + Some(CliCommand::Profile(cmd)) => { + handle_throttle_profile(&conn, supported_properties, cmd)? + } Some(CliCommand::FanCurve(cmd)) => { - handle_fan_curve(dbus, supported_interfaces, cmd)?; + handle_fan_curve(&conn, supported_interfaces, cmd)?; } Some(CliCommand::Graphics(_)) => do_gfx(), - Some(CliCommand::Anime(cmd)) => handle_anime(dbus, cmd)?, - Some(CliCommand::Bios(cmd)) => handle_platform_properties(dbus, supported_properties, cmd)?, + Some(CliCommand::Anime(cmd)) => handle_anime(&conn, cmd)?, + Some(CliCommand::Bios(cmd)) => { + handle_platform_properties(&conn, supported_properties, cmd)? + } None => { if (!parsed.show_supported && parsed.kbd_bright.is_none() @@ -261,9 +276,8 @@ fn do_parsed( } if let Some(chg_limit) = parsed.chg_limit { - dbus.proxies() - .platform() - .set_charge_control_end_threshold(chg_limit)?; + let proxy = PlatformProxyBlocking::new(&conn)?; + proxy.set_charge_control_end_threshold(chg_limit)?; } Ok(()) @@ -277,10 +291,7 @@ fn do_gfx() { println!("This command will be removed in future"); } -fn handle_anime( - dbus: &RogDbusClientBlocking<'_>, - cmd: &AnimeCommand, -) -> Result<(), Box> { +fn handle_anime(conn: &Connection, cmd: &AnimeCommand) -> Result<(), Box> { if (cmd.command.is_none() && cmd.enable_display.is_none() && cmd.enable_powersave_anim.is_none() @@ -297,23 +308,24 @@ fn handle_anime( println!("\n{}", lst); } } + let proxy = AnimeProxyBlocking::new(conn)?; if let Some(enable) = cmd.enable_display { - dbus.proxies().anime().set_enable_display(enable)?; + proxy.set_enable_display(enable)?; } if let Some(enable) = cmd.enable_powersave_anim { - dbus.proxies().anime().set_builtins_enabled(enable)?; + proxy.set_builtins_enabled(enable)?; } if let Some(bright) = cmd.brightness { - dbus.proxies().anime().set_brightness(bright)?; + proxy.set_brightness(bright)?; } if let Some(enable) = cmd.off_when_lid_closed { - dbus.proxies().anime().set_off_when_lid_closed(enable)?; + proxy.set_off_when_lid_closed(enable)?; } if let Some(enable) = cmd.off_when_suspended { - dbus.proxies().anime().set_off_when_suspended(enable)?; + proxy.set_off_when_suspended(enable)?; } if let Some(enable) = cmd.off_when_unplugged { - dbus.proxies().anime().set_off_when_unplugged(enable)?; + proxy.set_off_when_unplugged(enable)?; } if cmd.off_with_his_head.is_some() { println!("Did Alice _really_ make it back from Wonderland?"); @@ -329,7 +341,7 @@ fn handle_anime( if cmd.clear { let data = vec![255u8; anime_type.data_length()]; let tmp = AnimeDataBuffer::from_vec(anime_type, data)?; - dbus.proxies().anime().write(tmp)?; + proxy.write(tmp)?; } if let Some(action) = cmd.command.as_ref() { @@ -353,9 +365,7 @@ fn handle_anime( anime_type, )?; - dbus.proxies() - .anime() - .write(::try_from(&matrix)?)?; + proxy.write(::try_from(&matrix)?)?; } AnimeActions::PixelImage(image) => { if image.help_requested() || image.path.is_empty() { @@ -374,9 +384,7 @@ fn handle_anime( anime_type, )?; - dbus.proxies() - .anime() - .write(matrix.into_data_buffer(anime_type)?)?; + proxy.write(matrix.into_data_buffer(anime_type)?)?; } AnimeActions::Gif(gif) => { if gif.help_requested() || gif.path.is_empty() { @@ -401,7 +409,7 @@ fn handle_anime( let mut loops = gif.loops as i32; loop { for frame in matrix.frames() { - dbus.proxies().anime().write(frame.frame().clone())?; + proxy.write(frame.frame().clone())?; sleep(frame.delay()); } if loops >= 0 { @@ -432,7 +440,7 @@ fn handle_anime( let mut loops = gif.loops as i32; loop { for frame in matrix.frames() { - dbus.proxies().anime().write(frame.frame().clone())?; + proxy.write(frame.frame().clone())?; sleep(frame.delay()); } if loops >= 0 { @@ -453,14 +461,12 @@ fn handle_anime( return Ok(()); } - dbus.proxies() - .anime() - .set_builtin_animations(rog_anime::Animations { - boot: builtins.boot, - awake: builtins.awake, - sleep: builtins.sleep, - shutdown: builtins.shutdown, - })?; + proxy.set_builtin_animations(rog_anime::Animations { + boot: builtins.boot, + awake: builtins.awake, + sleep: builtins.sleep, + shutdown: builtins.shutdown, + })?; } } } @@ -716,7 +722,7 @@ fn handle_led_power2( } fn handle_throttle_profile( - dbus: &RogDbusClientBlocking<'_>, + conn: &Connection, supported: &[Properties], cmd: &ProfileCommand, ) -> Result<(), Box> { @@ -736,16 +742,14 @@ fn handle_throttle_profile( } return Ok(()); } - let current = dbus.proxies().platform().throttle_thermal_policy()?; + + let proxy = PlatformProxyBlocking::new(conn)?; + let current = proxy.throttle_thermal_policy()?; if cmd.next { - dbus.proxies() - .platform() - .set_throttle_thermal_policy(current.next())?; + proxy.set_throttle_thermal_policy(current.next())?; } else if let Some(profile) = cmd.profile_set { - dbus.proxies() - .platform() - .set_throttle_thermal_policy(profile)?; + proxy.set_throttle_thermal_policy(profile)?; } if cmd.list { @@ -763,7 +767,7 @@ fn handle_throttle_profile( } fn handle_fan_curve( - dbus: &RogDbusClientBlocking<'_>, + conn: &Connection, supported: &[String], cmd: &FanCurveCommand, ) -> Result<(), Box> { @@ -794,37 +798,35 @@ fn handle_fan_curve( return Ok(()); } + let plat_proxy = PlatformProxyBlocking::new(conn)?; + let fan_proxy = FanCurvesProxyBlocking::new(conn)?; if cmd.get_enabled { - let profile = dbus.proxies().platform().throttle_thermal_policy()?; - let curves = dbus.proxies().fan_curves().fan_curve_data(profile)?; + let profile = plat_proxy.throttle_thermal_policy()?; + let curves = fan_proxy.fan_curve_data(profile)?; for curve in curves.iter() { println!("{}", String::from(curve)); } } if cmd.default { - let active = dbus.proxies().platform().throttle_thermal_policy()?; - dbus.proxies().fan_curves().set_curves_to_defaults(active)?; + let active = plat_proxy.throttle_thermal_policy()?; + fan_proxy.set_curves_to_defaults(active)?; } if let Some(profile) = cmd.mod_profile { if cmd.enable_fan_curves.is_none() && cmd.data.is_none() { - let data = dbus.proxies().fan_curves().fan_curve_data(profile)?; + let data = fan_proxy.fan_curve_data(profile)?; let data = toml::to_string(&data)?; println!("\nFan curves for {:?}\n\n{}", profile, data); } if let Some(enabled) = cmd.enable_fan_curves { - dbus.proxies() - .fan_curves() - .set_fan_curves_enabled(profile, enabled)?; + fan_proxy.set_fan_curves_enabled(profile, enabled)?; } if let Some(enabled) = cmd.enable_fan_curve { if let Some(fan) = cmd.fan { - dbus.proxies() - .fan_curves() - .set_profile_fan_curve_enabled(profile, fan, enabled)?; + fan_proxy.set_profile_fan_curve_enabled(profile, fan, enabled)?; } else { println!( "--enable-fan-curves, --enable-fan-curve, --fan, and --data options require \ @@ -836,7 +838,7 @@ fn handle_fan_curve( if let Some(mut curve) = cmd.data.clone() { let fan = cmd.fan.unwrap_or_default(); curve.set_fan(fan); - dbus.proxies().fan_curves().set_fan_curve(profile, curve)?; + fan_proxy.set_fan_curve(profile, curve)?; } } @@ -844,7 +846,7 @@ fn handle_fan_curve( } fn handle_platform_properties( - dbus: &RogDbusClientBlocking<'_>, + conn: &Connection, supported: &[Properties], cmd: &BiosCommand, ) -> Result<(), Box> { @@ -870,34 +872,34 @@ fn handle_platform_properties( } } + let proxy = PlatformProxyBlocking::new(conn)?; + if let Some(opt) = cmd.post_sound_set { - dbus.proxies().platform().set_boot_sound(opt)?; + proxy.set_boot_sound(opt)?; } if cmd.post_sound_get { - let res = dbus.proxies().platform().boot_sound()?; + let res = proxy.boot_sound()?; println!("Bios POST sound on: {}", res); } if let Some(opt) = cmd.gpu_mux_mode_set { println!("Rebuilding initrd to include drivers"); - dbus.proxies() - .platform() - .set_gpu_mux_mode(GpuMode::from_mux(opt))?; + proxy.set_gpu_mux_mode(GpuMode::from_mux(opt))?; println!( "The mode change is not active until you reboot, on boot the bios will make the \ required change" ); } if cmd.gpu_mux_mode_get { - let res = dbus.proxies().platform().gpu_mux_mode()?; + let res = proxy.gpu_mux_mode()?; println!("Bios GPU MUX: {:?}", res); } if let Some(opt) = cmd.panel_overdrive_set { - dbus.proxies().platform().set_panel_od(opt)?; + proxy.set_panel_od(opt)?; } if cmd.panel_overdrive_get { - let res = dbus.proxies().platform().panel_od()?; + let res = proxy.panel_od()?; println!("Panel overdrive on: {}", res); } } diff --git a/asusd-user/src/ctrl_anime.rs b/asusd-user/src/ctrl_anime.rs index 7966b396..c5097a43 100644 --- a/asusd-user/src/ctrl_anime.rs +++ b/asusd-user/src/ctrl_anime.rs @@ -7,7 +7,7 @@ use std::time::{Duration, Instant}; use config_traits::StdConfig; use rog_anime::error::AnimeError; use rog_anime::{ActionData, ActionLoader, AnimTime, Fade, Sequences, Vec2}; -use rog_dbus::RogDbusClientBlocking; +use rog_dbus::zbus_anime::AnimeProxyBlocking; use serde_derive::{Deserialize, Serialize}; use zbus::interface; use zbus::zvariant::{ObjectPath, Type}; @@ -61,14 +61,14 @@ pub enum TimeType { /// thread and a zbus server behind `Arc>` pub struct CtrlAnimeInner<'a> { sequences: Sequences, - client: RogDbusClientBlocking<'a>, + client: AnimeProxyBlocking<'a>, do_early_return: Arc, } impl<'a> CtrlAnimeInner<'static> { pub fn new( sequences: Sequences, - client: RogDbusClientBlocking<'static>, + client: AnimeProxyBlocking<'static>, do_early_return: Arc, ) -> Result { Ok(Self { @@ -93,19 +93,13 @@ impl<'a> CtrlAnimeInner<'static> { return Ok(true); // Do safe exit } self.client - .proxies() - .anime() .write(output) .map_err(|e| AnimeError::Dbus(format!("{}", e))) .map(|_| false) }); } ActionData::Image(image) => { - self.client - .proxies() - .anime() - .write(image.as_ref().clone()) - .ok(); + self.client.write(image.as_ref().clone()).ok(); } ActionData::Pause(duration) => { let start = Instant::now(); @@ -132,7 +126,7 @@ impl<'a> CtrlAnimeInner<'static> { pub struct CtrlAnime<'a> { config: Arc>, - client: RogDbusClientBlocking<'a>, + client: AnimeProxyBlocking<'a>, inner: Arc>>, /// Must be the same Atomic as in CtrlAnimeInner inner_early_return: Arc, @@ -142,7 +136,7 @@ impl CtrlAnime<'static> { pub fn new( config: Arc>, inner: Arc>>, - client: RogDbusClientBlocking<'static>, + client: AnimeProxyBlocking<'static>, inner_early_return: Arc, ) -> Result { Ok(CtrlAnime { @@ -356,13 +350,13 @@ impl CtrlAnime<'static> { pub fn set_state(&mut self, on: bool) -> zbus::fdo::Result<()> { // Operations here need to be in specific order if on { - self.client.proxies().anime().set_enable_display(on).ok(); + self.client.set_enable_display(on).ok(); // Let the inner loop run self.inner_early_return.store(false, Ordering::SeqCst); } else { // Must make the inner run loop return early self.inner_early_return.store(true, Ordering::SeqCst); - self.client.proxies().anime().set_enable_display(on).ok(); + self.client.set_enable_display(on).ok(); } Ok(()) } diff --git a/asusd-user/src/daemon.rs b/asusd-user/src/daemon.rs index fae00c73..87622b14 100644 --- a/asusd-user/src/daemon.rs +++ b/asusd-user/src/daemon.rs @@ -9,7 +9,10 @@ use config_traits::{StdConfig, StdConfigLoad}; use rog_anime::usb::get_anime_type; use rog_aura::aura_detection::LaptopLedData; use rog_aura::layouts::KeyLayout; -use rog_dbus::{RogDbusClientBlocking, DBUS_NAME}; +use rog_dbus::zbus_anime::AnimeProxyBlocking; +use rog_dbus::zbus_aura::AuraProxyBlocking; +use rog_dbus::zbus_platform::PlatformProxyBlocking; +use rog_dbus::DBUS_NAME; use smol::Executor; use zbus::Connection; @@ -32,10 +35,10 @@ fn main() -> Result<(), Box> { println!(" rog-dbus v{}", rog_dbus::VERSION); println!("rog-platform v{}", rog_platform::VERSION); - let (client, _) = RogDbusClientBlocking::new()?; - let supported = client - .proxies() - .platform() + let conn = zbus::blocking::Connection::system().unwrap(); + let platform_proxy = PlatformProxyBlocking::new(&conn).unwrap(); + + let supported = platform_proxy .supported_interfaces() .unwrap_or_default() .contains(&"Anime".to_string()); @@ -51,6 +54,7 @@ fn main() -> Result<(), Box> { let anime = anime_config.create(anime_type)?; let anime_config = Arc::new(Mutex::new(anime_config)); + let anime_proxy_blocking = AnimeProxyBlocking::new(&conn).unwrap(); executor .spawn(async move { // Create server @@ -59,12 +63,21 @@ fn main() -> Result<(), Box> { // Inner behind mutex required for thread safety let inner = Arc::new(Mutex::new( - CtrlAnimeInner::new(anime, client, early_return.clone()).unwrap(), + CtrlAnimeInner::new( + anime, + anime_proxy_blocking.clone(), + early_return.clone(), + ) + .unwrap(), )); // Need new client object for dbus control part - let (client, _) = RogDbusClientBlocking::new().unwrap(); - let anime_control = - CtrlAnime::new(anime_config, inner.clone(), client, early_return).unwrap(); + let anime_control = CtrlAnime::new( + anime_config, + inner.clone(), + anime_proxy_blocking, + early_return, + ) + .unwrap(); anime_control.add_to_server(&mut connection).await; loop { if let Ok(inner) = inner.clone().try_lock() { @@ -89,22 +102,14 @@ fn main() -> Result<(), Box> { }) .unwrap_or_else(|_| KeyLayout::default_layout()); + let aura_proxy_blocking = AuraProxyBlocking::new(&conn).unwrap(); executor .spawn(async move { - // Create server - let (client, _) = RogDbusClientBlocking::new().unwrap(); - // let connection = Connection::session().await.unwrap(); - // connection.request_name(DBUS_NAME).await.unwrap(); - loop { aura_config.aura.next_state(&layout); let packets = aura_config.aura.create_packets(); - client - .proxies() - .aura() - .direct_addressing_raw(packets) - .unwrap(); + aura_proxy_blocking.direct_addressing_raw(packets).unwrap(); std::thread::sleep(std::time::Duration::from_millis(33)); } }) diff --git a/asusd/src/ctrl_fancurves.rs b/asusd/src/ctrl_fancurves.rs index 4bb3b571..21ceb335 100644 --- a/asusd/src/ctrl_fancurves.rs +++ b/asusd/src/ctrl_fancurves.rs @@ -274,19 +274,13 @@ impl crate::Reloadable for CtrlFanCurveZbus { /// Fetch the active profile and use that to set all related components up async fn reload(&mut self) -> Result<(), RogError> { let active = self.platform.get_throttle_thermal_policy()?.into(); + let mut config = self.config.lock().await; if let Ok(mut device) = find_fan_curve_node() { - // There is a possibility that the curve was default zeroed, so this call - // initialises the data from system read and we need to save it - // after - loop { - if let Ok(mut config) = self.config.try_lock() { - config - .profiles - .write_profile_curve_to_platform(active, &mut device)?; - break; - } - } + config + .profiles + .write_profile_curve_to_platform(active, &mut device)?; } + Ok(()) } } diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index 6f0060f7..62003c1a 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -175,7 +175,7 @@ impl CtrlPlatform { fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> { self.platform.set_gpu_mux_mode(mode.to_mux_attr())?; // self.update_initramfs(enable)?; - if mode == GpuMode::Discrete { + if mode == GpuMode::Ultimate { info!("Set system-level graphics mode: Dedicated Nvidia"); } else { info!("Set system-level graphics mode: Optimus"); @@ -264,6 +264,7 @@ impl CtrlPlatform { #[interface(name = "org.asuslinux.Platform")] impl CtrlPlatform { + #[zbus(property)] async fn version(&self) -> String { crate::VERSION.to_string() } diff --git a/rog-aura/src/lib.rs b/rog-aura/src/lib.rs index 32b6b423..10971d85 100644 --- a/rog-aura/src/lib.rs +++ b/rog-aura/src/lib.rs @@ -1,3 +1,7 @@ +// TODO: Generic builtin modes +// TODO: Traits for finding device + writing generic modes +// TODO: Traits for writing aura_sync + mod builtin_modes; use advanced::LedCode; pub use builtin_modes::*; diff --git a/rog-control-center/src/lib.rs b/rog-control-center/src/lib.rs index 5217d7c0..cc663c5d 100644 --- a/rog-control-center/src/lib.rs +++ b/rog-control-center/src/lib.rs @@ -23,22 +23,12 @@ pub mod types; pub mod ui; pub mod update_and_notify; -#[cfg(feature = "mocking")] -pub use mocking::RogDbusClientBlocking; use nix::sys::stat; use nix::unistd; -#[cfg(not(feature = "mocking"))] -pub use rog_dbus::RogDbusClientBlocking; use tempfile::TempDir; // use log::{error, info, warn}; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg(not(feature = "mocking"))] -const DATA_DIR: &str = "/usr/share/rog-gui/"; -#[cfg(feature = "mocking")] -const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR"); -const BOARD_NAME: &str = "/sys/class/dmi/id/board_name"; pub const APP_ICON_PATH: &str = "/usr/share/icons/hicolor/512x512/apps/rog-control-center.png"; pub fn print_versions() { diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index e754a3f8..3787831b 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -15,19 +15,28 @@ use rog_control_center::cli_options::CliStart; use rog_control_center::config::Config; use rog_control_center::error::Result; use rog_control_center::slint::ComponentHandle; -use rog_control_center::system_state::{AuraCreation, SystemState}; +use rog_control_center::system_state::SystemState; use rog_control_center::tray::init_tray; use rog_control_center::ui::setup_window; use rog_control_center::update_and_notify::{start_notifications, EnabledNotifications}; use rog_control_center::{ - get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, RogDbusClientBlocking, QUIT_APP, - SHOWING_GUI, SHOW_GUI, + get_ipc_file, on_tmp_dir_exists, print_versions, MainWindow, QUIT_APP, SHOWING_GUI, SHOW_GUI, }; use tokio::runtime::Runtime; // use winit::monitor::VideoMode; // use winit::window::{Fullscreen, WindowLevel}; -fn main() -> Result<()> { +#[tokio::main] +async fn main() -> Result<()> { + let self_version = env!("CARGO_PKG_VERSION"); + let conn = zbus::blocking::Connection::system()?; + let proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&conn)?; + let asusd_version = proxy.version().unwrap(); + if asusd_version != self_version { + println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); + return Ok(()); + } + let dmi = DMIID::new().unwrap_or_default(); let board_name = dmi.board_name; let prod_family = dmi.product_family; @@ -70,13 +79,7 @@ fn main() -> Result<()> { // Enter the runtime so that `tokio::spawn` is available immediately. let _enter = rt.enter(); - let (dbus, _) = RogDbusClientBlocking::new() - .map_err(|_| { - // TODO: show an error window - }) - .unwrap(); - - let supported_properties = match dbus.proxies().platform().supported_properties() { + let supported_properties = match proxy.supported_properties() { Ok(s) => s, Err(_e) => { // TODO: show an error window @@ -113,10 +116,9 @@ fn main() -> Result<()> { config.write(); let enabled_notifications = EnabledNotifications::tokio_mutex(&config); - let aura_creation = AuraCreation::new(cli_parsed.board_name, cli_parsed.layout_viewing)?; // TODO: config mutex to share config in various places - let states = setup_page_state_and_notifs(aura_creation, &enabled_notifications, &config)?; + let states = setup_page_state_and_notifs(&enabled_notifications, &config).await?; let enable_tray_icon = config.enable_tray_icon; let startup_in_background = config.startup_in_background; @@ -214,17 +216,18 @@ fn main() -> Result<()> { Ok(()) } -fn setup_page_state_and_notifs( - aura_creation: AuraCreation, +async fn setup_page_state_and_notifs( enabled_notifications: &Arc>, config: &Config, ) -> Result>> { - let page_states = Arc::new(Mutex::new(SystemState::new( - aura_creation, - enabled_notifications.clone(), - config.enable_tray_icon, - config.run_in_background, - )?)); + let page_states = Arc::new(Mutex::new( + SystemState::new( + enabled_notifications.clone(), + config.enable_tray_icon, + config.run_in_background, + ) + .await?, + )); start_notifications(config, &page_states, enabled_notifications)?; @@ -261,8 +264,10 @@ fn setup_page_state_and_notifs( // IconData { // height, // width, -// rgba, -// } +// rgba +// +// +// / } // } fn do_cli_help(parsed: &CliStart) -> bool { diff --git a/rog-control-center/src/system_state.rs b/rog-control-center/src/system_state.rs index cab71e85..a6aecc9d 100644 --- a/rog-control-center/src/system_state.rs +++ b/rog-control-center/src/system_state.rs @@ -1,190 +1,15 @@ -use std::collections::{BTreeMap, HashSet}; -use std::path::PathBuf; use std::sync::{Arc, Mutex}; -use std::time::SystemTime; -use log::{error, warn}; -use rog_anime::{Animations, DeviceState}; -use rog_aura::aura_detection::{LaptopLedData, LedSupportFile}; -use rog_aura::layouts::KeyLayout; -use rog_aura::usb::AuraPowerDev; -use rog_aura::{AuraEffect, AuraModeNum, LedBrightness}; -use rog_platform::platform::{GpuMode, ThrottlePolicy}; -use rog_profiles::fan_curve_set::CurveData; -use rog_profiles::FanCurvePU; +use log::error; use supergfxctl::pci_device::{GfxMode, GfxPower}; #[cfg(not(feature = "mocking"))] -use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking; +use supergfxctl::zbus_proxy::DaemonProxy as GfxProxy; +use zbus::Connection; use crate::error::Result; #[cfg(feature = "mocking")] use crate::mocking::DaemonProxyBlocking as GfxProxyBlocking; use crate::update_and_notify::EnabledNotifications; -use crate::{RogDbusClientBlocking, BOARD_NAME, DATA_DIR}; - -#[derive(Clone, Debug, Default)] -pub struct PlatformState { - /// To be shared to a thread that checks notifications. - /// It's a bit general in that it won't provide *what* was - /// updated, so the full state needs refresh - pub post_sound: Option, - pub gpu_mux_mode: Option, - pub panel_overdrive: Option, - pub mini_led_mode: Option, - pub dgpu_disable: Option, - pub egpu_enable: Option, - pub throttle: Option, - pub charge_limit: Option, -} - -impl PlatformState { - pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result { - Ok(Self { - post_sound: dbus.proxies().platform().boot_sound().ok(), - gpu_mux_mode: dbus - .proxies() - .platform() - .gpu_mux_mode() - .map(GpuMode::from) - .ok(), - panel_overdrive: dbus.proxies().platform().panel_od().ok(), - mini_led_mode: dbus.proxies().platform().mini_led_mode().ok(), - // TODO: needs supergfx - dgpu_disable: dbus.proxies().platform().dgpu_disable().ok(), - egpu_enable: dbus.proxies().platform().egpu_enable().ok(), - throttle: dbus.proxies().platform().throttle_thermal_policy().ok(), - charge_limit: dbus - .proxies() - .platform() - .charge_control_end_threshold() - .ok(), - }) - } -} - -#[derive(Clone, Debug, Default)] -pub struct FanCurvesState { - pub show_curve: ThrottlePolicy, - pub show_graph: FanCurvePU, - pub curves: BTreeMap>, - pub available_fans: HashSet, - // pub drag_delta: Vec2, -} - -impl FanCurvesState { - pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result { - let profiles = vec![ - ThrottlePolicy::Balanced, - ThrottlePolicy::Quiet, - ThrottlePolicy::Performance, - ]; - - let mut available_fans = HashSet::new(); - let mut curves: BTreeMap> = BTreeMap::new(); - for p in &profiles { - if let Ok(curve) = dbus.proxies().fan_curves().fan_curve_data(*p) { - if available_fans.is_empty() { - for fan in &curve { - available_fans.insert(fan.fan); - } - } - curves.insert(*p, curve); - } else { - curves.insert(*p, Default::default()); - } - } - - let show_curve = dbus.proxies().platform().throttle_thermal_policy()?; - - Ok(Self { - show_curve, - show_graph: FanCurvePU::CPU, - curves, - available_fans, - // drag_delta: Vec2::default(), - }) - } -} - -#[derive(Clone, Debug, Default)] -pub struct AuraState { - pub current_mode: AuraModeNum, - pub modes: BTreeMap, - pub enabled: AuraPowerDev, - /// Brightness from 0-3 - pub bright: LedBrightness, - pub wave_red: [u8; 22], - pub wave_green: [u8; 22], - pub wave_blue: [u8; 22], -} - -impl AuraState { - pub fn new(layout: &KeyLayout, dbus: &RogDbusClientBlocking<'_>) -> Result { - Ok(Self { - current_mode: if !layout.basic_modes().is_empty() { - dbus.proxies().aura().led_mode().unwrap_or_default() - } else { - AuraModeNum::Static - }, - - modes: if !layout.basic_modes().is_empty() { - dbus.proxies().aura().all_mode_data().unwrap_or_default() - } else { - BTreeMap::new() - }, - enabled: dbus.proxies().aura().led_power().unwrap_or_default(), - bright: Default::default(), - wave_red: [0u8; 22], - wave_green: [0u8; 22], - wave_blue: [0u8; 22], - }) - } - - /// Bump value in to the wave and surf all along. - pub fn nudge_wave(&mut self, r: u8, g: u8, b: u8) { - for i in (0..self.wave_red.len()).rev() { - if i > 0 { - self.wave_red[i] = self.wave_red[i - 1]; - self.wave_green[i] = self.wave_green[i - 1]; - self.wave_blue[i] = self.wave_blue[i - 1]; - } - } - self.wave_red[0] = r; - self.wave_green[0] = g; - self.wave_blue[0] = b; - } -} - -#[derive(Clone, Debug, Default)] -pub struct AnimeState { - pub display_enabled: bool, - pub display_brightness: u8, - pub builtin_anims_enabled: bool, - pub builtin_anims: Animations, -} - -impl AnimeState { - pub fn new(dbus: &RogDbusClientBlocking<'_>) -> Result { - let device_state = dbus.proxies().anime().device_state()?; - Ok(Self { - display_enabled: device_state.display_enabled, - display_brightness: device_state.display_brightness as u8, - builtin_anims_enabled: device_state.builtin_anims_enabled, - builtin_anims: device_state.builtin_anims, - }) - } -} - -impl From for AnimeState { - fn from(dev: DeviceState) -> Self { - Self { - display_enabled: dev.display_enabled, - display_brightness: dev.display_brightness as u8, - builtin_anims_enabled: dev.builtin_anims_enabled, - builtin_anims: dev.builtin_anims, - } - } -} #[derive(Clone, Debug)] pub struct GfxState { @@ -194,11 +19,11 @@ pub struct GfxState { } impl GfxState { - pub fn new(dbus: &GfxProxyBlocking<'_>) -> Result { + pub async fn new(dbus: &GfxProxy<'_>) -> Result { Ok(Self { - has_supergfx: dbus.mode().is_ok(), - mode: dbus.mode().unwrap_or(GfxMode::None), - power_status: dbus.power().unwrap_or(GfxPower::Unknown), + has_supergfx: dbus.mode().await.is_ok(), + mode: dbus.mode().await.unwrap_or(GfxMode::None), + power_status: dbus.power().await.unwrap_or(GfxPower::Unknown), }) } } @@ -213,115 +38,16 @@ impl Default for GfxState { } } -/// The keyboard layout, used for such things as per-key and zones -#[derive(Clone, Debug)] -pub struct AuraCreation { - /// Specifically for testing the development of keyboard layouts (combined - /// with `--layout-name` CLI option) - pub layout_testing: Option, - pub layout_last_modified: SystemTime, - pub keyboard_layout: KeyLayout, - pub keyboard_layouts: Vec, - /// current index in to `self.keyboard_layouts` - pub keyboard_layout_index: usize, -} - -impl AuraCreation { - pub fn new(test_name: Option, view_layout: bool) -> Result { - let mut led_support = LaptopLedData::get_data(); - - let mut path = PathBuf::from(DATA_DIR); - let mut layout_testing = None; - let mut keyboard_layouts = Vec::new(); - - // Find and load a matching layout for laptop - let mut board_name = std::fs::read_to_string(BOARD_NAME).map_err(|e| { - println!("DOH! {BOARD_NAME}, {e}"); - e - })?; - - if test_name.is_some() || view_layout { - if cfg!(feature = "mocking") { - path.pop(); - path.push("rog-aura"); - path.push("data"); - } - keyboard_layouts = KeyLayout::layout_files(path.clone()).unwrap(); - - if let Some(name) = test_name { - if let Some(modes) = LedSupportFile::load_from_supoprt_db() { - if let Some(data) = modes.matcher(&name) { - led_support = data; - } - } - board_name = name; - for layout in &keyboard_layouts { - if layout - .file_name() - .unwrap() - .to_string_lossy() - .contains(&led_support.layout_name.to_lowercase()) - { - layout_testing = Some(layout.clone()); - } - } - } else { - board_name = "GQ401QM".to_owned(); - }; - - if view_layout { - layout_testing = Some(keyboard_layouts[0].clone()); - board_name = keyboard_layouts[0] - .file_name() - .unwrap() - .to_string_lossy() - .split_once('_') - .unwrap() - .0 - .to_owned(); - led_support.layout_name = board_name.clone(); - } - } - - let keyboard_layout = KeyLayout::find_layout(led_support, path) - .map_err(|e| { - println!("DERP! , {e}"); - }) - .unwrap_or_else(|_| { - warn!("Did not find a keyboard layout matching {board_name}"); - KeyLayout::default_layout() - }); - - Ok(Self { - layout_testing, - layout_last_modified: SystemTime::now(), - keyboard_layout, - keyboard_layouts, - keyboard_layout_index: 0, - }) - } -} - /// State stored from system daemons. This is shared with: tray, zbus /// notifications thread and the GUI app thread. pub struct SystemState { - pub aura_creation: AuraCreation, - //-- pub enabled_notifications: Arc>, - /// Because much of the app state here is the same as - /// `RogBiosSupportedFunctions` we can re-use that structure. - pub bios: PlatformState, - pub aura: AuraState, - pub anime: AnimeState, - pub fan_curves: FanCurvesState, pub gfx_state: GfxState, pub error: Option, /// Specific field for the tray only so that we can know when it does need /// update. The tray should set this to false when done. pub tray_should_update: bool, pub app_should_update: bool, - pub asus_dbus: RogDbusClientBlocking<'static>, - pub gfx_dbus: GfxProxyBlocking<'static>, pub tray_enabled: bool, pub run_in_bg: bool, } @@ -329,47 +55,22 @@ pub struct SystemState { impl SystemState { /// Creates self, including the relevant dbus connections and proixies for /// internal use - pub fn new( - aura_creation: AuraCreation, + pub async fn new( enabled_notifications: Arc>, tray_enabled: bool, run_in_bg: bool, ) -> Result { - let (asus_dbus, conn) = RogDbusClientBlocking::new()?; - let aura = AuraState::new(&aura_creation.keyboard_layout, &asus_dbus) - .map_err(|e| { - let e = format!("Could not get AuraState state: {e}"); - error!("{e}"); - }) - .unwrap_or_default(); + let conn = Connection::system().await?; - let gfx_dbus = GfxProxyBlocking::builder(&conn) + let gfx_dbus = GfxProxy::builder(&conn) .destination(":org.supergfxctl.Daemon")? .build() + .await .expect("Couldn't connect to supergfxd"); Ok(Self { - aura_creation, enabled_notifications, - bios: PlatformState::new(&asus_dbus) - .map_err(|e| { - let e = format!("Could not get BiosState state: {e}"); - error!("{e}"); - }) - .unwrap_or_default(), - aura, - anime: AnimeState::new(&asus_dbus) - .map_err(|e| { - let e = format!("Could not get AnimeState state: {e}"); - error!("{e}"); - }) - .unwrap_or_default(), - fan_curves: FanCurvesState::new(&asus_dbus) - .map_err(|e| { - let e = format!("Could not get FanCurvesState state: {e}"); - error!("{e}"); - }) - .unwrap_or_default(), gfx_state: GfxState::new(&gfx_dbus) + .await .map_err(|e| { let e = format!("Could not get supergfxd state: {e}"); error!("{e}"); @@ -378,8 +79,6 @@ impl SystemState { error: None, tray_should_update: true, app_should_update: true, - asus_dbus, - gfx_dbus, tray_enabled, run_in_bg, }) @@ -390,51 +89,3 @@ impl SystemState { self.app_should_update = true; } } - -impl Default for SystemState { - fn default() -> Self { - let (asus_dbus, conn) = RogDbusClientBlocking::new().expect("Couldn't connect to asusd"); - let gfx_dbus = GfxProxyBlocking::builder(&conn) - .build() - .expect("Couldn't connect to supergfxd"); - - Self { - aura_creation: AuraCreation { - layout_testing: None, - layout_last_modified: SystemTime::now(), - keyboard_layout: KeyLayout::default_layout(), - keyboard_layouts: Default::default(), - keyboard_layout_index: 0, - }, - enabled_notifications: Default::default(), - bios: PlatformState { - post_sound: Default::default(), - gpu_mux_mode: None, - charge_limit: Some(100), - ..Default::default() - }, - aura: AuraState { - current_mode: AuraModeNum::Static, - modes: Default::default(), - enabled: AuraPowerDev::default(), - ..Default::default() - }, - anime: AnimeState::default(), - fan_curves: FanCurvesState { - ..Default::default() - }, - gfx_state: GfxState { - has_supergfx: false, - mode: GfxMode::None, - power_status: GfxPower::Unknown, - }, - error: Default::default(), - tray_should_update: true, - app_should_update: true, - asus_dbus, - gfx_dbus, - tray_enabled: true, - run_in_bg: true, - } - } -} diff --git a/rog-control-center/src/tray.rs b/rog-control-center/src/tray.rs index 4fa4ed61..baa30273 100644 --- a/rog-control-center/src/tray.rs +++ b/rog-control-center/src/tray.rs @@ -11,7 +11,7 @@ use std::time::Duration; use betrayer::{Icon, Menu, MenuItem, TrayEvent, TrayIcon, TrayIconBuilder}; use log::{debug, error, info, warn}; -use rog_platform::platform::{GpuMode, Properties}; +use rog_platform::platform::Properties; use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::zbus_proxy::DaemonProxyBlocking as GfxProxy; use versions::Versioning; @@ -113,16 +113,7 @@ fn set_tray_icon_and_tip(lock: &SystemState, tray: &TrayIcon, superg } }; - let current_gpu_mode = if supergfx_active { - lock.gfx_state.mode - } else if let Some(mode) = lock.bios.gpu_mux_mode { - match mode { - GpuMode::Discrete => GfxMode::AsusMuxDgpu, - _ => GfxMode::Hybrid, - } - } else { - GfxMode::Hybrid - }; + let current_gpu_mode = lock.gfx_state.mode; tray.set_tooltip(format!( "ROG: gpu mode = {current_gpu_mode:?}, gpu power = {gpu_status:?}" diff --git a/rog-control-center/src/update_and_notify.rs b/rog-control-center/src/update_and_notify.rs index db760390..5418d049 100644 --- a/rog-control-center/src/update_and_notify.rs +++ b/rog-control-center/src/update_and_notify.rs @@ -11,10 +11,8 @@ use std::time::Duration; use log::{error, info, trace, warn}; use notify_rust::{Hint, Notification, NotificationHandle, Urgency}; -use rog_dbus::zbus_anime::AnimeProxy; -use rog_dbus::zbus_aura::AuraProxy; use rog_dbus::zbus_platform::PlatformProxy; -use rog_platform::platform::{GpuMode, ThrottlePolicy}; +use rog_platform::platform::GpuMode; use serde::{Deserialize, Serialize}; use supergfxctl::actions::UserActionRequired as GfxUserAction; use supergfxctl::pci_device::{GfxMode, GfxPower}; @@ -31,45 +29,12 @@ const NOTIF_HEADER: &str = "ROG Control"; static mut POWER_AC_CMD: Option = None; static mut POWER_BAT_CMD: Option = None; -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, Clone, Deserialize, Serialize)] #[serde(default)] pub struct EnabledNotifications { - pub receive_boot_sound_changed: bool, - pub receive_panel_od_changed: bool, - pub receive_mini_led_mode_changed: bool, - pub receive_dgpu_disable_changed: bool, - pub receive_egpu_enable_changed: bool, - pub receive_gpu_mux_mode_changed: bool, - pub receive_charge_control_end_threshold_changed: bool, - pub receive_notify_mains_online: bool, - pub receive_throttle_thermal_policy_changed: bool, - pub receive_led_mode_data_changed: bool, - /// Anime pub receive_power_states: bool, pub receive_notify_gfx: bool, pub receive_notify_gfx_status: bool, - pub all_enabled: bool, -} - -impl Default for EnabledNotifications { - fn default() -> Self { - Self { - receive_boot_sound_changed: false, - receive_panel_od_changed: true, - receive_mini_led_mode_changed: true, - receive_dgpu_disable_changed: true, - receive_egpu_enable_changed: true, - receive_gpu_mux_mode_changed: true, - receive_charge_control_end_threshold_changed: true, - receive_notify_mains_online: false, - receive_throttle_thermal_policy_changed: true, - receive_led_mode_data_changed: true, - receive_power_states: false, - receive_notify_gfx: false, - receive_notify_gfx_status: false, - all_enabled: false, - } - } } impl EnabledNotifications { @@ -78,6 +43,18 @@ impl EnabledNotifications { } } +fn gpu_to_gfx(value: GpuMode) -> GfxMode { + match value { + GpuMode::Optimus => GfxMode::Hybrid, + GpuMode::Integrated => GfxMode::Integrated, + GpuMode::Egpu => GfxMode::AsusEgpu, + GpuMode::Vfio => GfxMode::Vfio, + GpuMode::Ultimate => GfxMode::AsusMuxDgpu, + GpuMode::Error => GfxMode::None, + GpuMode::NotSupported => GfxMode::None, + } +} + // TODO: drop the macro and use generics plus closure macro_rules! recv_notif { ($proxy:ident, @@ -107,7 +84,7 @@ macro_rules! recv_notif { while let Some(e) = p.next().await { if let Ok(out) = e.args() { if let Ok(config) = notifs_enabled1.lock() { - if config.all_enabled && config.$signal { + if config.$signal { trace!("zbus signal {}", stringify!($signal)); $notifier($msg, &out.$($out_arg)+()).ok(); } @@ -124,49 +101,6 @@ macro_rules! recv_notif { }; } -macro_rules! recv_changed { - ($proxy:ident, - $signal:ident, - $last_notif:ident, - $notif_enabled:ident, - $page_states:ident, - ($($args: tt)*), - // ($($out_arg:tt)+), - $msg:literal, - $notifier:ident) => { - - let notifs_enabled1 = $notif_enabled.clone(); - let page_states1 = $page_states.clone(); - - tokio::spawn(async move { - let conn = zbus::Connection::system().await.map_err(|e| { - log::error!("zbus signal: {}: {e}", stringify!($signal)); - e - }).unwrap(); - let proxy = $proxy::new(&conn).await.map_err(|e| { - log::error!("zbus signal: {}: {e}", stringify!($signal)); - e - }).unwrap(); - info!("Started zbus signal thread: {}", stringify!($signal)); - while let Some(e) = proxy.$signal().await.next().await { - if let Ok(out) = e.get().await { - if let Ok(config) = notifs_enabled1.lock() { - if config.all_enabled && config.$signal { - trace!("zbus signal {}", stringify!($signal)); - $notifier($msg, &out).ok(); - } - } - if let Ok(mut lock) = page_states1.lock() { - lock.$($args)+ = out.into(); - lock.set_notified(); - } - } - sleep(Duration::from_millis(500)).await; - } - }); - }; -} - pub fn start_notifications( config: &Config, page_states: &Arc>, @@ -196,155 +130,6 @@ pub fn start_notifications( } } - // BIOS notif - recv_changed!( - PlatformProxy, - receive_boot_sound_changed, - last_notification, - enabled_notifications, - page_states, - (bios.post_sound), - "BIOS Post sound", - do_notification - ); - - recv_changed!( - PlatformProxy, - receive_panel_od_changed, - last_notification, - enabled_notifications, - page_states, - (bios.panel_overdrive), - "Panel Overdrive enabled:", - do_notification - ); - - recv_changed!( - PlatformProxy, - receive_mini_led_mode_changed, - last_notification, - enabled_notifications, - page_states, - (bios.mini_led_mode), - "MiniLED mode enabled:", - do_notification - ); - - recv_changed!( - PlatformProxy, - receive_dgpu_disable_changed, - last_notification, - enabled_notifications, - page_states, - (bios.dgpu_disable), - "BIOS dGPU disabled", - do_notification - ); - - recv_changed!( - PlatformProxy, - receive_egpu_enable_changed, - last_notification, - enabled_notifications, - page_states, - (bios.egpu_enable), - "BIOS eGPU enabled", - do_notification - ); - - // Charge notif - recv_changed!( - PlatformProxy, - receive_charge_control_end_threshold_changed, - last_notification, - enabled_notifications, - page_states, - (bios.charge_limit), - "Battery charge limit changed to", - do_notification - ); - - // Profile notif - recv_changed!( - PlatformProxy, - receive_throttle_thermal_policy_changed, - last_notification, - enabled_notifications, - page_states, - (bios.throttle), - "Profile changed to", - do_thermal_notif - ); - // notify!(do_thermal_notif(&out.profile), lock); - - // LED notif - recv_changed!( - AuraProxy, - receive_led_mode_data_changed, - last_notification, - enabled_notifications, - page_states, - (aura.current_mode), - "Keyboard LED mode changed to", - do_notification - ); - - // let page_states1 = page_states.clone(); - // tokio::spawn(async move { - // let conn = zbus::Connection::system() - // .await - // .map_err(|e| { - // error!("zbus signal: receive_device_state: {e}"); - // e - // }) - // .unwrap(); - // let proxy = AuraProxy::new(&conn) - // .await - // .map_err(|e| { - // error!("zbus signal: receive_device_state: {e}"); - // e - // }) - // .unwrap(); - // let p = proxy.receive_led_power_changed().await; - // info!("Started zbus signal thread: receive_notify_power_states"); - // while let Some(e) = p.next().await { - // if let Ok(out) = e.get().await { - // if let Ok(mut lock) = page_states1.lock() { - // lock.aura.enabled = out; - // lock.set_notified(); - // } - // } - // } - // }); - - let page_states1 = page_states.clone(); - tokio::spawn(async move { - let conn = zbus::Connection::system() - .await - .map_err(|e| { - error!("zbus signal: receive_device_state: {e}"); - e - }) - .unwrap(); - let proxy = AnimeProxy::new(&conn) - .await - .map_err(|e| { - error!("zbus signal: receive_device_state: {e}"); - e - }) - .unwrap(); - if let Ok(mut p) = proxy.receive_notify_device_state().await { - info!("Started zbus signal thread: receive_device_state"); - while let Some(e) = p.next().await { - if let Ok(out) = e.args() { - if let Ok(mut lock) = page_states1.lock() { - lock.anime = out.data.into(); - } - } - } - }; - }); - let page_states1 = page_states.clone(); tokio::spawn(async move { let conn = zbus::Connection::system() @@ -375,7 +160,7 @@ pub fn start_notifications( continue; } if let Ok(mut lock) = page_states1.lock() { - lock.bios.gpu_mux_mode = Some(mode); + lock.gfx_state.mode = gpu_to_gfx(mode); lock.set_notified(); } do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok(); @@ -397,7 +182,7 @@ pub fn start_notifications( if let Ok(status) = dev.get_runtime_status() { if status != GfxPower::Unknown && status != last_status { if let Ok(config) = notifs_enabled1.lock() { - if config.all_enabled && config.receive_notify_gfx_status { + if config.receive_notify_gfx_status { // Required check because status cycles through // active/unknown/suspended do_gpu_status_notif("dGPU status changed:", &status).ok(); @@ -498,7 +283,7 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode { match gfx { GfxMode::Hybrid => GpuMode::Optimus, GfxMode::Integrated => GpuMode::Integrated, - GfxMode::NvidiaNoModeset => GpuMode::Discrete, + GfxMode::NvidiaNoModeset => GpuMode::Optimus, GfxMode::Vfio => GpuMode::Vfio, GfxMode::AsusEgpu => GpuMode::Egpu, GfxMode::AsusMuxDgpu => GpuMode::Ultimate, @@ -553,17 +338,6 @@ fn _ac_power_notification(message: &str, on: &bool) -> Result Result { - let icon = match profile { - ThrottlePolicy::Balanced => "asus_notif_yellow", - ThrottlePolicy::Performance => "asus_notif_red", - ThrottlePolicy::Quiet => "asus_notif_green", - }; - let profile: &str = (*profile).into(); - let mut notif = base_notification(message, &profile.to_uppercase()); - Ok(notif.icon(icon).show()?) -} - fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Result { // eww let mut notif = base_notification(message, &<&str>::from(data).to_owned()); diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index a5ac5b60..e2833c70 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-03 20:58+0000\n" +"POT-Creation-Date: 2024-04-05 03:00+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/lib.rs b/rog-dbus/src/lib.rs index 0059de43..d619d4c9 100644 --- a/rog-dbus/src/lib.rs +++ b/rog-dbus/src/lib.rs @@ -4,124 +4,4 @@ pub mod zbus_aura; pub mod zbus_fan_curves; pub mod zbus_platform; -// use rog_anime::AnimePowerStates; -// use rog_aura::{AuraEffect, LedPowerStates}; -// use rog_profiles::Profile; -// use std::sync::mpsc::{channel, Receiver}; -use zbus::{blocking, Connection, Result}; - pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - -pub struct DbusProxiesBlocking<'a> { - anime: zbus_anime::AnimeProxyBlocking<'a>, - led: zbus_aura::AuraProxyBlocking<'a>, - profile: zbus_fan_curves::FanCurvesProxyBlocking<'a>, - rog_bios: zbus_platform::PlatformProxyBlocking<'a>, -} - -impl<'a> DbusProxiesBlocking<'a> { - #[inline] - pub fn new() -> Result<(Self, blocking::Connection)> { - let conn = blocking::Connection::system()?; - - Ok(( - DbusProxiesBlocking { - anime: zbus_anime::AnimeProxyBlocking::new(&conn)?, - led: zbus_aura::AuraProxyBlocking::new(&conn)?, - profile: zbus_fan_curves::FanCurvesProxyBlocking::new(&conn)?, - rog_bios: zbus_platform::PlatformProxyBlocking::new(&conn)?, - }, - conn, - )) - } - - pub fn anime(&self) -> &zbus_anime::AnimeProxyBlocking<'a> { - &self.anime - } - - pub fn aura(&self) -> &zbus_aura::AuraProxyBlocking<'a> { - &self.led - } - - pub fn fan_curves(&self) -> &zbus_fan_curves::FanCurvesProxyBlocking<'a> { - &self.profile - } - - pub fn platform(&self) -> &zbus_platform::PlatformProxyBlocking<'a> { - &self.rog_bios - } -} - -/// This is the main way to communicate with the DBUS interface -pub struct RogDbusClientBlocking<'a> { - proxies: DbusProxiesBlocking<'a>, -} - -impl<'a> RogDbusClientBlocking<'a> { - #[inline] - pub fn new() -> Result<(Self, blocking::Connection)> { - let (proxies, conn) = DbusProxiesBlocking::new()?; - Ok((RogDbusClientBlocking { proxies }, conn)) - } - - pub fn proxies(&self) -> &DbusProxiesBlocking<'_> { - &self.proxies - } -} - -pub struct DbusProxies<'a> { - anime: zbus_anime::AnimeProxy<'a>, - led: zbus_aura::AuraProxy<'a>, - profile: zbus_fan_curves::FanCurvesProxy<'a>, - rog_bios: zbus_platform::PlatformProxy<'a>, -} - -impl<'a> DbusProxies<'a> { - #[inline] - pub async fn new() -> Result<(DbusProxies<'a>, Connection)> { - let conn = Connection::system().await?; - - Ok(( - DbusProxies { - anime: zbus_anime::AnimeProxy::new(&conn).await?, - led: zbus_aura::AuraProxy::new(&conn).await?, - profile: zbus_fan_curves::FanCurvesProxy::new(&conn).await?, - rog_bios: zbus_platform::PlatformProxy::new(&conn).await?, - }, - conn, - )) - } - - pub fn anime(&self) -> &zbus_anime::AnimeProxy<'a> { - &self.anime - } - - pub fn led(&self) -> &zbus_aura::AuraProxy<'a> { - &self.led - } - - pub fn profile(&self) -> &zbus_fan_curves::FanCurvesProxy<'a> { - &self.profile - } - - pub fn rog_bios(&self) -> &zbus_platform::PlatformProxy<'a> { - &self.rog_bios - } -} - -/// This is the main way to communicate with the DBUS interface -pub struct RogDbusClient<'a> { - proxies: DbusProxies<'a>, -} - -impl<'a> RogDbusClient<'a> { - #[inline] - pub async fn new() -> Result<(RogDbusClient<'a>, Connection)> { - let (proxies, conn) = DbusProxies::new().await?; - Ok((RogDbusClient { proxies }, conn)) - } - - pub fn proxies(&self) -> &DbusProxies<'_> { - &self.proxies - } -} diff --git a/rog-dbus/src/zbus_platform.rs b/rog-dbus/src/zbus_platform.rs index b7be05ce..a79ac36a 100644 --- a/rog-dbus/src/zbus_platform.rs +++ b/rog-dbus/src/zbus_platform.rs @@ -30,6 +30,9 @@ use zbus::proxy; default_path = "/org/asuslinux" )] trait Platform { + #[zbus(property)] + fn version(&self) -> zbus::Result; + /// NextThrottleThermalPolicy method fn next_throttle_thermal_policy(&self) -> zbus::Result<()>; diff --git a/rog-platform/src/platform.rs b/rog-platform/src/platform.rs index 6ae7ef1b..f1f1aabd 100644 --- a/rog-platform/src/platform.rs +++ b/rog-platform/src/platform.rs @@ -154,27 +154,25 @@ impl Default for RogPlatform { Serialize, Deserialize, Default, Type, Value, OwnedValue, Debug, PartialEq, Eq, Clone, Copy, )] pub enum GpuMode { - Discrete = 0, - Optimus = 1, - Integrated = 2, - Egpu = 3, - Vfio = 4, - Ultimate = 5, + Optimus = 0, + Integrated = 1, + Egpu = 2, + Vfio = 3, + Ultimate = 4, #[default] - Error = 6, - NotSupported = 7, + Error = 254, + NotSupported = 255, } impl From for GpuMode { fn from(v: u8) -> Self { match v { - 0 => GpuMode::Discrete, - 1 => GpuMode::Optimus, - 2 => GpuMode::Integrated, - 3 => GpuMode::Egpu, - 4 => GpuMode::Vfio, - 5 => GpuMode::Ultimate, - 6 => GpuMode::Error, + 0 => GpuMode::Optimus, + 1 => GpuMode::Integrated, + 2 => GpuMode::Egpu, + 3 => GpuMode::Vfio, + 4 => GpuMode::Ultimate, + 5 => GpuMode::Error, _ => GpuMode::NotSupported, } } @@ -189,7 +187,7 @@ impl From for u8 { impl GpuMode { /// For writing to `gpu_mux_mode` attribute pub fn to_mux_attr(&self) -> u8 { - if *self == Self::Discrete { + if *self == Self::Ultimate { return 0; } 1 @@ -211,7 +209,7 @@ impl GpuMode { pub fn from_mux(num: u8) -> Self { if num == 0 { - return Self::Discrete; + return Self::Ultimate; } Self::Optimus } @@ -236,7 +234,6 @@ impl GpuMode { impl Display for GpuMode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - GpuMode::Discrete => write!(f, "Discrete"), GpuMode::Optimus => write!(f, "Optimus"), GpuMode::Integrated => write!(f, "Integrated"), GpuMode::Egpu => write!(f, "eGPU"), diff --git a/rog-profiles/src/lib.rs b/rog-profiles/src/lib.rs index 677422ee..a364b36a 100644 --- a/rog-profiles/src/lib.rs +++ b/rog-profiles/src/lib.rs @@ -14,6 +14,8 @@ use zbus::zvariant::{OwnedValue, Value}; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); +/// Use udev system to find the fan curve path/node which is labelled with +/// "asus_custom_fan_curve" in the kernel pub fn find_fan_curve_node() -> Result { let mut enumerator = udev::Enumerator::new()?; enumerator.match_subsystem("hwmon")?; @@ -170,9 +172,7 @@ impl FanCurveProfiles { } /// Write the curves for the selected profile to the device. If the curve is - /// in the enabled list it will become active. If the curve is zeroed it - /// will be initialised to a default read from the system. - // TODO: Make this return an error if curve is zeroed + /// in the enabled list it will become active. pub fn write_profile_curve_to_platform( &mut self, profile: ThrottlePolicy, From 1c729316f789b7791837084fdb8fe483e43ab6a8 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 5 Apr 2024 21:20:34 +1300 Subject: [PATCH 08/12] Refactor, rename, organise rog-aura stuff better --- asusctl/examples/aura-zoned-breathe.rs | 3 +- asusctl/src/main.rs | 36 +- asusd-user/src/config.rs | 2 +- asusd-user/src/daemon.rs | 2 +- asusd/src/ctrl_aura/config.rs | 56 +-- asusd/src/ctrl_aura/controller.rs | 6 +- asusd/src/ctrl_aura/trait_impls.rs | 2 +- rog-aura/src/advanced_to_str.rs | 149 ------ rog-aura/src/aura_detection.rs | 7 +- rog-aura/src/builtin_modes.rs | 6 - rog-aura/src/deprecated.rs | 162 ------ rog-aura/src/effects/base.rs | 4 +- rog-aura/src/effects/breathe.rs | 3 +- rog-aura/src/effects/doom.rs | 3 +- rog-aura/src/effects/mod.rs | 14 +- rog-aura/src/effects/static_.rs | 3 +- rog-aura/src/{ => keyboard}/advanced.rs | 150 +++++- rog-aura/src/{ => keyboard}/layouts.rs | 6 +- rog-aura/src/keyboard/mod.rs | 20 + rog-aura/src/keyboard/power.rs | 472 ++++++++++++++++++ rog-aura/src/lib.rs | 28 +- rog-aura/src/power.rs | 344 ------------- rog-aura/src/usb.rs | 165 +----- rog-control-center/src/types/aura_types.rs | 96 ++-- .../translations/en/rog-control-center.po | 2 +- rog-control-center/ui/types/aura_types.slint | 1 - rog-dbus/src/zbus_aura.rs | 2 +- 27 files changed, 770 insertions(+), 974 deletions(-) delete mode 100644 rog-aura/src/advanced_to_str.rs delete mode 100644 rog-aura/src/deprecated.rs rename rog-aura/src/{ => keyboard}/advanced.rs (74%) rename rog-aura/src/{ => keyboard}/layouts.rs (99%) create mode 100644 rog-aura/src/keyboard/mod.rs create mode 100644 rog-aura/src/keyboard/power.rs delete mode 100644 rog-aura/src/power.rs diff --git a/asusctl/examples/aura-zoned-breathe.rs b/asusctl/examples/aura-zoned-breathe.rs index dbbf1f25..f219ad1d 100644 --- a/asusctl/examples/aura-zoned-breathe.rs +++ b/asusctl/examples/aura-zoned-breathe.rs @@ -1,9 +1,8 @@ //! Using a combination of key-colour array plus a key layout to generate //! outputs. -use rog_aura::advanced::LedCode; use rog_aura::effects::{AdvancedEffects, Effect}; -use rog_aura::layouts::KeyLayout; +use rog_aura::keyboard::{KeyLayout, LedCode}; use rog_aura::Colour; use rog_dbus::zbus_aura::AuraProxyBlocking; use zbus::blocking::Connection; diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 596a650a..3d74809d 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -12,8 +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::power::KbAuraPowerState; -use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev}; +use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower}; +use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::{self, AuraEffect}; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; @@ -601,10 +601,10 @@ fn handle_led_power_1_do_1866( aura: &AuraProxyBlocking, power: &LedPowerCommand1, ) -> Result<(), Box> { - let mut enabled: Vec = Vec::new(); - let mut disabled: Vec = Vec::new(); + let mut enabled: Vec = Vec::new(); + let mut disabled: Vec = Vec::new(); - let mut check = |e: Option, a: AuraDevRog1| { + let mut check = |e: Option, a: LaptopOldAuraPower| { if let Some(arg) = e { if arg { enabled.push(a); @@ -614,11 +614,11 @@ fn handle_led_power_1_do_1866( } }; - check(power.awake, AuraDevRog1::Awake); - check(power.boot, AuraDevRog1::Boot); - check(power.sleep, AuraDevRog1::Sleep); - check(power.keyboard, AuraDevRog1::Keyboard); - check(power.lightbar, AuraDevRog1::Lightbar); + check(power.awake, LaptopOldAuraPower::Awake); + check(power.boot, LaptopOldAuraPower::Boot); + check(power.sleep, LaptopOldAuraPower::Sleep); + check(power.keyboard, LaptopOldAuraPower::Keyboard); + check(power.lightbar, LaptopOldAuraPower::Lightbar); let data = AuraPowerDev { old_rog: enabled, @@ -634,10 +634,10 @@ fn handle_led_power_1_do_tuf( aura: &AuraProxyBlocking, power: &LedPowerCommand1, ) -> Result<(), Box> { - let mut enabled: Vec = Vec::new(); - let mut disabled: Vec = Vec::new(); + let mut enabled: Vec = Vec::new(); + let mut disabled: Vec = Vec::new(); - let mut check = |e: Option, a: AuraDevTuf| { + let mut check = |e: Option, a: LaptopTufAuraPower| { if let Some(arg) = e { if arg { enabled.push(a); @@ -647,10 +647,10 @@ fn handle_led_power_1_do_tuf( } }; - check(power.awake, AuraDevTuf::Awake); - check(power.boot, AuraDevTuf::Boot); - check(power.sleep, AuraDevTuf::Sleep); - check(power.keyboard, AuraDevTuf::Keyboard); + check(power.awake, LaptopTufAuraPower::Awake); + check(power.boot, LaptopTufAuraPower::Boot); + check(power.sleep, LaptopTufAuraPower::Sleep); + check(power.keyboard, LaptopTufAuraPower::Keyboard); let data = AuraPowerDev { tuf: enabled, @@ -696,7 +696,7 @@ fn handle_led_power2( return Ok(()); } - let set = |power: &mut KbAuraPowerState, set_to: &AuraPowerStates| { + let set = |power: &mut AuraPowerState, set_to: &AuraPowerStates| { power.boot = set_to.boot; power.awake = set_to.awake; power.sleep = set_to.sleep; diff --git a/asusd-user/src/config.rs b/asusd-user/src/config.rs index 62c8c118..5aca5886 100644 --- a/asusd-user/src/config.rs +++ b/asusd-user/src/config.rs @@ -3,8 +3,8 @@ use std::time::Duration; use config_traits::{StdConfig, StdConfigLoad}; use rog_anime::{ActionLoader, AnimTime, AnimeType, Fade, Sequences as AnimeSequences, Vec2}; -use rog_aura::advanced::LedCode; use rog_aura::effects::{AdvancedEffects as AuraSequences, Breathe, DoomFlicker, Effect, Static}; +use rog_aura::keyboard::LedCode; use rog_aura::{Colour, Speed}; use serde_derive::{Deserialize, Serialize}; diff --git a/asusd-user/src/daemon.rs b/asusd-user/src/daemon.rs index 87622b14..34bc3263 100644 --- a/asusd-user/src/daemon.rs +++ b/asusd-user/src/daemon.rs @@ -8,7 +8,7 @@ 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::layouts::KeyLayout; +use rog_aura::keyboard::KeyLayout; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking; diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index 09c9e59a..6effc4a0 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -3,8 +3,8 @@ use std::collections::{BTreeMap, HashSet}; use config_traits::{StdConfig, StdConfigLoad}; use log::{debug, info}; use rog_aura::aura_detection::LaptopLedData; -use rog_aura::power::AuraPower; -use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev}; +use rog_aura::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower}; +use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT}; use serde_derive::{Deserialize, Serialize}; @@ -13,9 +13,9 @@ use serde_derive::{Deserialize, Serialize}; /// booting. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum AuraPowerConfig { - AuraDevTuf(HashSet), - AuraDevRog1(HashSet), - AuraDevRog2(AuraPower), + AuraDevTuf(HashSet), + AuraDevRog1(HashSet), + AuraDevRog2(LaptopAuraPower), } impl Default for AuraPowerConfig { @@ -30,8 +30,8 @@ impl AuraPowerConfig { match control { AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0], AuraPowerConfig::AuraDevRog1(c) => { - let c: Vec = c.iter().copied().collect(); - AuraDevRog1::to_bytes(&c) + let c: Vec = c.iter().copied().collect(); + LaptopOldAuraPower::to_bytes(&c) } AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(), } @@ -41,27 +41,27 @@ impl AuraPowerConfig { if let Self::AuraDevTuf(c) = control { return Some([ true, - c.contains(&AuraDevTuf::Boot), - c.contains(&AuraDevTuf::Awake), - c.contains(&AuraDevTuf::Sleep), - c.contains(&AuraDevTuf::Keyboard), + c.contains(&LaptopTufAuraPower::Boot), + c.contains(&LaptopTufAuraPower::Awake), + c.contains(&LaptopTufAuraPower::Sleep), + c.contains(&LaptopTufAuraPower::Keyboard), ]); } if let Self::AuraDevRog1(c) = control { return Some([ true, - c.contains(&AuraDevRog1::Boot), - c.contains(&AuraDevRog1::Awake), - c.contains(&AuraDevRog1::Sleep), - c.contains(&AuraDevRog1::Keyboard), + c.contains(&LaptopOldAuraPower::Boot), + c.contains(&LaptopOldAuraPower::Awake), + c.contains(&LaptopOldAuraPower::Sleep), + c.contains(&LaptopOldAuraPower::Keyboard), ]); } None } - pub fn set_tuf(&mut self, power: AuraDevTuf, on: bool) { + pub fn set_tuf(&mut self, power: LaptopTufAuraPower, on: bool) { if let Self::AuraDevTuf(p) = self { if on { p.insert(power); @@ -71,7 +71,7 @@ impl AuraPowerConfig { } } - pub fn set_0x1866(&mut self, power: AuraDevRog1, on: bool) { + pub fn set_0x1866(&mut self, power: LaptopOldAuraPower, on: bool) { if let Self::AuraDevRog1(p) = self { if on { p.insert(power); @@ -81,7 +81,7 @@ impl AuraPowerConfig { } } - pub fn set_0x19b6(&mut self, power: AuraPower) { + pub fn set_0x19b6(&mut self, power: LaptopAuraPower) { if let Self::AuraDevRog2(p) = self { *p = power; } @@ -151,21 +151,21 @@ impl AuraConfig { pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self { // create a default config here let enabled = if prod_id.is_new_style() { - AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on()) + AuraPowerConfig::AuraDevRog2(LaptopAuraPower::new_all_on()) } else if prod_id.is_tuf_style() { AuraPowerConfig::AuraDevTuf(HashSet::from([ - AuraDevTuf::Awake, - AuraDevTuf::Boot, - AuraDevTuf::Sleep, - AuraDevTuf::Keyboard, + LaptopTufAuraPower::Awake, + LaptopTufAuraPower::Boot, + LaptopTufAuraPower::Sleep, + LaptopTufAuraPower::Keyboard, ])) } else { AuraPowerConfig::AuraDevRog1(HashSet::from([ - AuraDevRog1::Awake, - AuraDevRog1::Boot, - AuraDevRog1::Sleep, - AuraDevRog1::Keyboard, - AuraDevRog1::Lightbar, + LaptopOldAuraPower::Awake, + LaptopOldAuraPower::Boot, + LaptopOldAuraPower::Sleep, + LaptopOldAuraPower::Keyboard, + LaptopOldAuraPower::Lightbar, ])) }; let mut config = AuraConfig { diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index 0a906640..bf9fdfee 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -3,8 +3,8 @@ use std::collections::{BTreeMap, HashSet}; use config_traits::{StdConfig, StdConfigLoad}; use inotify::Inotify; use log::{debug, info, warn}; -use rog_aura::advanced::{LedUsbPackets, UsbPackets}; use rog_aura::aura_detection::LaptopLedData; +use rog_aura::keyboard::{LedUsbPackets, UsbPackets}; use rog_aura::usb::{AuraDevice, LED_APPLY, LED_SET}; use rog_aura::{AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN}; use rog_platform::hid_raw::HidRaw; @@ -362,7 +362,7 @@ mod tests { layout_name: "ga401".to_owned(), basic_modes: vec![AuraModeNum::Static], basic_zones: vec![], - advanced_type: rog_aura::AdvancedAuraType::None, + advanced_type: rog_aura::keyboard::AdvancedAuraType::None, power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], }; let mut controller = CtrlKbdLed { @@ -405,7 +405,7 @@ mod tests { layout_name: "ga401".to_owned(), basic_modes: vec![AuraModeNum::Static], basic_zones: vec![AuraZone::Key1, AuraZone::Key2], - advanced_type: rog_aura::AdvancedAuraType::None, + advanced_type: rog_aura::keyboard::AdvancedAuraType::None, power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], }; let mut controller = CtrlKbdLed { diff --git a/asusd/src/ctrl_aura/trait_impls.rs b/asusd/src/ctrl_aura/trait_impls.rs index 2f2fa805..4338c2f6 100644 --- a/asusd/src/ctrl_aura/trait_impls.rs +++ b/asusd/src/ctrl_aura/trait_impls.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use config_traits::StdConfig; use log::{debug, error, info, warn}; -use rog_aura::advanced::UsbPackets; use rog_aura::aura_detection::PowerZones; +use rog_aura::keyboard::UsbPackets; use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::export::futures_util::lock::{Mutex, MutexGuard}; diff --git a/rog-aura/src/advanced_to_str.rs b/rog-aura/src/advanced_to_str.rs deleted file mode 100644 index 3555eed8..00000000 --- a/rog-aura/src/advanced_to_str.rs +++ /dev/null @@ -1,149 +0,0 @@ -use crate::advanced::LedCode; - -impl From for &str { - fn from(k: LedCode) -> Self { - (&k).into() - } -} - -impl From<&LedCode> for &str { - fn from(k: &LedCode) -> Self { - #[allow(clippy::match_same_arms)] - match k { - LedCode::VolUp => "Volume Up", - LedCode::VolDown => "Volume Down", - LedCode::MicMute => "Mute Mic", - LedCode::RogApp => "ROG", - LedCode::RogFan => "Fan Control", - LedCode::Esc => "Escape", - LedCode::F1 => "F1", - LedCode::F2 => "F2", - LedCode::F3 => "F3", - LedCode::F4 => "F4", - LedCode::F5 => "F5", - LedCode::F6 => "F6", - LedCode::F7 => "F7", - LedCode::F8 => "F8", - LedCode::F9 => "F9", - LedCode::F10 => "F10", - LedCode::F11 => "F11", - LedCode::F12 => "F12", - LedCode::Del => "Delete", - LedCode::Tilde => "Tilde", - LedCode::N1 => "1", - LedCode::N2 => "2", - LedCode::N3 => "3", - LedCode::N4 => "4", - LedCode::N5 => "5", - LedCode::N6 => "6", - LedCode::N7 => "7", - LedCode::N8 => "8", - LedCode::N9 => "9", - LedCode::N0 => "0", - LedCode::Hyphen => "-", - LedCode::Equals => "=", - LedCode::Backspace => "Backspace", - LedCode::Backspace3_1 => "Backspace LED 1", - LedCode::Backspace3_2 => "Backspace LED 2", - LedCode::Backspace3_3 => "Backspace LED 3", - LedCode::Home => "Home", - LedCode::Tab => "Tab", - LedCode::Q => "Q", - LedCode::W => "W", - LedCode::E => "E", - LedCode::R => "R", - LedCode::T => "T", - LedCode::Y => "Y", - LedCode::U => "U", - LedCode::I => "I", - LedCode::O => "O", - LedCode::P => "P", - LedCode::LBracket => "[", - LedCode::RBracket => "]", - LedCode::BackSlash => "\\", - LedCode::PgUp => "Page Up", - LedCode::Caps => "Caps Lock", - LedCode::A => "A", - LedCode::S => "S", - LedCode::D => "D", - LedCode::F => "F", - LedCode::G => "G", - LedCode::H => "H", - LedCode::J => "J", - LedCode::K => "K", - LedCode::L => "L", - LedCode::SemiColon => ";", - LedCode::Quote => "'", - LedCode::Return => "Return", - LedCode::Return3_1 => "Return LED 1", - LedCode::Return3_2 => "Return LED 2", - LedCode::Return3_3 => "Return LED 3", - LedCode::PgDn => "Page Down", - LedCode::LShift => "Left Shift", - LedCode::LShift3_1 => "Left Shift LED 1", - LedCode::LShift3_2 => "Left Shift LED 2", - LedCode::LShift3_3 => "Left Shift LED 3", - LedCode::Z => "Z", - LedCode::X => "X", - LedCode::C => "C", - LedCode::V => "V", - LedCode::B => "B", - LedCode::N => "N", - LedCode::M => "M", - LedCode::Comma => ",", - LedCode::Period => ".", - LedCode::Star => "*", - LedCode::NumPadDel => "Delete", - LedCode::NumPadPlus => "+", - LedCode::NumPadEnter => "Enter", - LedCode::NumPadPause => "Pause", - LedCode::NumPadPrtSc => "Print Screen", - LedCode::NumPadHome => "Home", - LedCode::NumLock => "Num-Lock", - LedCode::FwdSlash => "/", - LedCode::Rshift => "Right Shift", - LedCode::Rshift3_1 => "Right Shift LED 1", - LedCode::Rshift3_2 => "Right Shift LED 2", - LedCode::Rshift3_3 => "Right Shift LED 3", - LedCode::End => "End", - LedCode::LCtrl => "Left Control", - LedCode::LFn => "Left Fn", - LedCode::Meta => "Meta", - LedCode::LAlt => "Left Alt", - LedCode::Spacebar => "Space", - LedCode::Spacebar5_1 => "Space LED 1", - LedCode::Spacebar5_2 => "Space LED 2", - LedCode::Spacebar5_3 => "Space LED 3", - LedCode::Spacebar5_4 => "Space LED 4", - LedCode::Spacebar5_5 => "Space LED 5", - LedCode::RAlt => "Right Alt", - LedCode::PrtSc => "Print Screen", - LedCode::RCtrl => "Right Control", - LedCode::Pause => "Pause", - LedCode::Up => "Up", - LedCode::Down => "Down", - LedCode::Left => "Left", - LedCode::Right => "Right", - LedCode::RFn => "Right Fn", - LedCode::MediaPlay => "Media Play", - LedCode::MediaStop => "Media Stop", - LedCode::MediaNext => "Media Next", - LedCode::MediaPrev => "Media Previous", - LedCode::LidLogo => "Lid Logo", - LedCode::LidLeft => "Lid Left", - LedCode::LidRight => "Lid Right", - LedCode::LightbarRight => "Lightbar Right", - LedCode::LightbarRightCorner => "Lightbar Right Corner", - LedCode::LightbarRightBottom => "Lightbar Right Bottom", - LedCode::LightbarLeftBottom => "Lightbar Left Bottom", - LedCode::LightbarLeftCorner => "Lightbar Left Corner", - LedCode::LightbarLeft => "Lightbar Left", - LedCode::Spacing | LedCode::Blocking => "", - LedCode::SingleZone => "Single Zoned Keyboard", - LedCode::ZonedKbLeft => "Left Zone (zone 1)", - LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)", - LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)", - LedCode::ZonedKbRight => "Right Zone (zone 4)", - } - } -} diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index cdd1e3b3..75062d02 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -4,8 +4,9 @@ use serde_derive::{Deserialize, Serialize}; use typeshare::typeshare; use zbus::zvariant::{OwnedValue, Type, Value}; +use crate::keyboard::AdvancedAuraType; use crate::usb::AuraDevice; -use crate::{AdvancedAuraType, AuraModeNum, AuraZone}; +use crate::{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"; @@ -153,10 +154,10 @@ mod tests { use ron::ser::PrettyConfig; use super::LaptopLedData; - use crate::advanced::LedCode; use crate::aura_detection::{LedSupportFile, PowerZones}; + use crate::keyboard::{AdvancedAuraType, LedCode}; // use crate::zoned::Zone; - use crate::{AdvancedAuraType, AuraModeNum, AuraZone}; + use crate::{AuraModeNum, AuraZone}; #[test] fn check_data_parse() { diff --git a/rog-aura/src/builtin_modes.rs b/rog-aura/src/builtin_modes.rs index d955c74c..ceca2c79 100644 --- a/rog-aura/src/builtin_modes.rs +++ b/rog-aura/src/builtin_modes.rs @@ -1,9 +1,3 @@ -pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9]; -pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d -pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08]; -pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e -pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08]; - use std::fmt::Display; use std::str::FromStr; diff --git a/rog-aura/src/deprecated.rs b/rog-aura/src/deprecated.rs deleted file mode 100644 index a2bac1eb..00000000 --- a/rog-aura/src/deprecated.rs +++ /dev/null @@ -1,162 +0,0 @@ -//! Older code that is not useful but stillr elevant as a reference - -/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models -/// -/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label | -/// |--------|---------|---------|---------|----------| -/// |00000001| 00000000| 00000000| 00000000|boot_logo_| -/// |00000010| 00000000| 00000000| 00000000|boot_keyb_| -/// |00000100| 00000000| 00000000| 00000000|awake_logo| -/// |00001000| 00000000| 00000000| 00000000|awake_keyb| -/// |00010000| 00000000| 00000000| 00000000|sleep_logo| -/// |00100000| 00000000| 00000000| 00000000|sleep_keyb| -/// |01000000| 00000000| 00000000| 00000000|shut_logo_| -/// |10000000| 00000000| 00000000| 00000000|shut_keyb_| -/// |00000000| 00000010| 00000000| 00000000|boot_bar__| -/// |00000000| 00000100| 00000000| 00000000|awake_bar_| -/// |00000000| 00001000| 00000000| 00000000|sleep_bar_| -/// |00000000| 00010000| 00000000| 00000000|shut_bar__| -/// |00000000| 00000000| 00000001| 00000000|boot_lid__| -/// |00000000| 00000000| 00000010| 00000000|awkae_lid_| -/// |00000000| 00000000| 00000100| 00000000|sleep_lid_| -/// |00000000| 00000000| 00001000| 00000000|shut_lid__| -/// |00000000| 00000000| 00000000| 00000001|boot_rear_| -/// |00000000| 00000000| 00000000| 00000010|awake_rear| -/// |00000000| 00000000| 00000000| 00000100|sleep_rear| -/// |00000000| 00000000| 00000000| 00001000|shut_rear_| -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[repr(u32)] -pub enum AuraDevRog2 { - BootLogo = 1, - BootKeyb = 1 << 1, - AwakeLogo = 1 << 2, - AwakeKeyb = 1 << 3, - SleepLogo = 1 << 4, - SleepKeyb = 1 << 5, - ShutdownLogo = 1 << 6, - ShutdownKeyb = 1 << 7, - BootBar = 1 << (7 + 2), - AwakeBar = 1 << (7 + 3), - SleepBar = 1 << (7 + 4), - ShutdownBar = 1 << (7 + 5), - BootLid = 1 << (15 + 1), - AwakeLid = 1 << (15 + 2), - SleepLid = 1 << (15 + 3), - ShutdownLid = 1 << (15 + 4), - BootRearGlow = 1 << (23 + 1), - AwakeRearGlow = 1 << (23 + 2), - SleepRearGlow = 1 << (23 + 3), - ShutdownRearGlow = 1 << (23 + 4), -} - -impl From for u32 { - fn from(a: AuraDevRog2) -> Self { - a as u32 - } -} - -impl AuraDevRog2 { - pub fn to_bytes(control: &[Self]) -> [u8; 4] { - let mut a: u32 = 0; - for n in control { - a |= *n as u32; - } - [ - (a & 0xff) as u8, - ((a & 0xff00) >> 8) as u8, - ((a & 0xff0000) >> 16) as u8, - ((a & 0xff000000) >> 24) as u8, - ] - } - - pub const fn dev_id() -> &'static str { - "0x196b" - } -} - -#[cfg(test)] -mod tests { - use crate::deprecated::AuraDevRog2; - - #[test] - fn check_0x19b6_control_bytes_binary_rep() { - fn to_binary_string(bytes: &[AuraDevRog2]) -> String { - let bytes = AuraDevRog2::to_bytes(bytes); - format!( - "{:08b}, {:08b}, {:08b}, {:08b}", - bytes[0], bytes[1], bytes[2], bytes[3] - ) - } - - let boot_logo_ = to_binary_string(&[AuraDevRog2::BootLogo]); - let boot_keyb_ = to_binary_string(&[AuraDevRog2::BootKeyb]); - let sleep_logo = to_binary_string(&[AuraDevRog2::SleepLogo]); - let sleep_keyb = to_binary_string(&[AuraDevRog2::SleepKeyb]); - let awake_logo = to_binary_string(&[AuraDevRog2::AwakeLogo]); - let awake_keyb = to_binary_string(&[AuraDevRog2::AwakeKeyb]); - let shut_logo_ = to_binary_string(&[AuraDevRog2::ShutdownLogo]); - let shut_keyb_ = to_binary_string(&[AuraDevRog2::ShutdownKeyb]); - let boot_bar__ = to_binary_string(&[AuraDevRog2::BootBar]); - let awake_bar_ = to_binary_string(&[AuraDevRog2::AwakeBar]); - let sleep_bar_ = to_binary_string(&[AuraDevRog2::SleepBar]); - let shut_bar__ = to_binary_string(&[AuraDevRog2::ShutdownBar]); - let boot_lid__ = to_binary_string(&[AuraDevRog2::BootLid]); - let awkae_lid_ = to_binary_string(&[AuraDevRog2::AwakeLid]); - let sleep_lid_ = to_binary_string(&[AuraDevRog2::SleepLid]); - let shut_lid__ = to_binary_string(&[AuraDevRog2::ShutdownLid]); - let boot_rear_ = to_binary_string(&[AuraDevRog2::BootRearGlow]); - let awake_rear = to_binary_string(&[AuraDevRog2::AwakeRearGlow]); - let sleep_rear = to_binary_string(&[AuraDevRog2::SleepRearGlow]); - let shut_rear_ = to_binary_string(&[AuraDevRog2::ShutdownRearGlow]); - - assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); - assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000"); - assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000"); - assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000"); - assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000"); - assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000"); - assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000"); - assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000"); - // - assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000"); - assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000"); - assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000"); - assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000"); - // - assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000"); - assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000"); - assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000"); - assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000"); - // - assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001"); - assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010"); - assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100"); - assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); - - // All on - let byte1 = [ - AuraDevRog2::BootLogo, - AuraDevRog2::BootKeyb, - AuraDevRog2::SleepLogo, - AuraDevRog2::SleepKeyb, - AuraDevRog2::AwakeLogo, - AuraDevRog2::AwakeKeyb, - AuraDevRog2::ShutdownLogo, - AuraDevRog2::ShutdownKeyb, - AuraDevRog2::BootBar, - AuraDevRog2::AwakeBar, - AuraDevRog2::SleepBar, - AuraDevRog2::ShutdownBar, - AuraDevRog2::AwakeLid, - AuraDevRog2::BootLid, - AuraDevRog2::SleepLid, - AuraDevRog2::ShutdownLid, - AuraDevRog2::AwakeRearGlow, - AuraDevRog2::BootRearGlow, - AuraDevRog2::SleepRearGlow, - AuraDevRog2::ShutdownRearGlow, - ]; - let out = to_binary_string(&byte1); - assert_eq!(out, "11111111, 00011110, 00001111, 00001111"); - } -} diff --git a/rog-aura/src/effects/base.rs b/rog-aura/src/effects/base.rs index fce1b490..d9453657 100644 --- a/rog-aura/src/effects/base.rs +++ b/rog-aura/src/effects/base.rs @@ -1,5 +1,5 @@ use super::{EffectState, InputForEffect}; -use crate::advanced::LedCode; +use crate::keyboard::{KeyLayout, LedCode}; use crate::Colour; pub struct InputBased { @@ -14,7 +14,7 @@ pub struct InputBased { } impl EffectState for InputBased { - fn next_colour_state(&mut self, _layout: &crate::layouts::KeyLayout) { + fn next_colour_state(&mut self, _layout: &KeyLayout) { self.input.next_colour_state(); self.colour = self.input.get_colour(); } diff --git a/rog-aura/src/effects/breathe.rs b/rog-aura/src/effects/breathe.rs index b9fc481e..a3c5a345 100644 --- a/rog-aura/src/effects/breathe.rs +++ b/rog-aura/src/effects/breathe.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use super::EffectState; -use crate::advanced::LedCode; -use crate::layouts::KeyLayout; +use crate::keyboard::{KeyLayout, LedCode}; use crate::{effect_state_impl, Colour, Speed}; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/rog-aura/src/effects/doom.rs b/rog-aura/src/effects/doom.rs index 28492e0a..773a8bb2 100644 --- a/rog-aura/src/effects/doom.rs +++ b/rog-aura/src/effects/doom.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; -use crate::advanced::LedCode; use crate::effects::{p_random, EffectState}; -use crate::layouts::KeyLayout; +use crate::keyboard::{KeyLayout, LedCode}; use crate::{effect_state_impl, Colour}; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/rog-aura/src/effects/mod.rs b/rog-aura/src/effects/mod.rs index 6e567c67..39576a16 100644 --- a/rog-aura/src/effects/mod.rs +++ b/rog-aura/src/effects/mod.rs @@ -12,8 +12,7 @@ pub use breathe::*; mod static_; pub use static_::*; -use crate::advanced::{LedCode, LedUsbPackets, UsbPackets}; -use crate::layouts::KeyLayout; +use crate::keyboard::{KeyLayout, LedCode, LedUsbPackets, UsbPackets}; use crate::Colour; // static mut RNDINDEX: usize = 0; @@ -132,12 +131,12 @@ macro_rules! effect_state_impl { self.colour } - fn get_led(&self) -> $crate::advanced::LedCode { + fn get_led(&self) -> $crate::keyboard::LedCode { self.led.clone() } /// Change the led type - fn set_led(&mut self, address: $crate::advanced::LedCode) { + fn set_led(&mut self, address: $crate::keyboard::LedCode) { self.led = address; } }; @@ -148,14 +147,14 @@ macro_rules! effect_impl { ($($effect:ident),*) => { impl Effect { /// Get the type of LED set - pub fn led(&self) -> $crate::advanced::LedCode { + pub fn led(&self) -> $crate::keyboard::LedCode { match self { $(Effect::$effect(c) => c.get_led(),)* } } /// Change the led type (can be used to change location of the effect) - pub fn set_led(&mut self, address: $crate::advanced::LedCode) { + pub fn set_led(&mut self, address: $crate::keyboard::LedCode) { match self { $(Effect::$effect(c) => c.set_led(address),)* } @@ -200,9 +199,8 @@ effect_impl!(Static, Breathe, DoomFlicker, DoomLightFlash); #[cfg(test)] mod tests { - use crate::advanced::LedCode; use crate::effects::{AdvancedEffects, Breathe, DoomFlicker, Effect, Static}; - use crate::layouts::KeyLayout; + use crate::keyboard::{KeyLayout, LedCode}; use crate::{Colour, Speed}; #[test] diff --git a/rog-aura/src/effects/static_.rs b/rog-aura/src/effects/static_.rs index 8e2b4bd9..0c57646a 100644 --- a/rog-aura/src/effects/static_.rs +++ b/rog-aura/src/effects/static_.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use super::EffectState; -use crate::advanced::LedCode; -use crate::layouts::KeyLayout; +use crate::keyboard::{KeyLayout, LedCode}; use crate::{effect_state_impl, Colour}; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/rog-aura/src/advanced.rs b/rog-aura/src/keyboard/advanced.rs similarity index 74% rename from rog-aura/src/advanced.rs rename to rog-aura/src/keyboard/advanced.rs index a546c200..b58e1614 100644 --- a/rog-aura/src/advanced.rs +++ b/rog-aura/src/keyboard/advanced.rs @@ -490,9 +490,157 @@ impl From for UsbPackets { } } +impl From for &str { + fn from(k: LedCode) -> Self { + (&k).into() + } +} + +impl From<&LedCode> for &str { + fn from(k: &LedCode) -> Self { + #[allow(clippy::match_same_arms)] + match k { + LedCode::VolUp => "Volume Up", + LedCode::VolDown => "Volume Down", + LedCode::MicMute => "Mute Mic", + LedCode::RogApp => "ROG", + LedCode::RogFan => "Fan Control", + LedCode::Esc => "Escape", + LedCode::F1 => "F1", + LedCode::F2 => "F2", + LedCode::F3 => "F3", + LedCode::F4 => "F4", + LedCode::F5 => "F5", + LedCode::F6 => "F6", + LedCode::F7 => "F7", + LedCode::F8 => "F8", + LedCode::F9 => "F9", + LedCode::F10 => "F10", + LedCode::F11 => "F11", + LedCode::F12 => "F12", + LedCode::Del => "Delete", + LedCode::Tilde => "Tilde", + LedCode::N1 => "1", + LedCode::N2 => "2", + LedCode::N3 => "3", + LedCode::N4 => "4", + LedCode::N5 => "5", + LedCode::N6 => "6", + LedCode::N7 => "7", + LedCode::N8 => "8", + LedCode::N9 => "9", + LedCode::N0 => "0", + LedCode::Hyphen => "-", + LedCode::Equals => "=", + LedCode::Backspace => "Backspace", + LedCode::Backspace3_1 => "Backspace LED 1", + LedCode::Backspace3_2 => "Backspace LED 2", + LedCode::Backspace3_3 => "Backspace LED 3", + LedCode::Home => "Home", + LedCode::Tab => "Tab", + LedCode::Q => "Q", + LedCode::W => "W", + LedCode::E => "E", + LedCode::R => "R", + LedCode::T => "T", + LedCode::Y => "Y", + LedCode::U => "U", + LedCode::I => "I", + LedCode::O => "O", + LedCode::P => "P", + LedCode::LBracket => "[", + LedCode::RBracket => "]", + LedCode::BackSlash => "\\", + LedCode::PgUp => "Page Up", + LedCode::Caps => "Caps Lock", + LedCode::A => "A", + LedCode::S => "S", + LedCode::D => "D", + LedCode::F => "F", + LedCode::G => "G", + LedCode::H => "H", + LedCode::J => "J", + LedCode::K => "K", + LedCode::L => "L", + LedCode::SemiColon => ";", + LedCode::Quote => "'", + LedCode::Return => "Return", + LedCode::Return3_1 => "Return LED 1", + LedCode::Return3_2 => "Return LED 2", + LedCode::Return3_3 => "Return LED 3", + LedCode::PgDn => "Page Down", + LedCode::LShift => "Left Shift", + LedCode::LShift3_1 => "Left Shift LED 1", + LedCode::LShift3_2 => "Left Shift LED 2", + LedCode::LShift3_3 => "Left Shift LED 3", + LedCode::Z => "Z", + LedCode::X => "X", + LedCode::C => "C", + LedCode::V => "V", + LedCode::B => "B", + LedCode::N => "N", + LedCode::M => "M", + LedCode::Comma => ",", + LedCode::Period => ".", + LedCode::Star => "*", + LedCode::NumPadDel => "Delete", + LedCode::NumPadPlus => "+", + LedCode::NumPadEnter => "Enter", + LedCode::NumPadPause => "Pause", + LedCode::NumPadPrtSc => "Print Screen", + LedCode::NumPadHome => "Home", + LedCode::NumLock => "Num-Lock", + LedCode::FwdSlash => "/", + LedCode::Rshift => "Right Shift", + LedCode::Rshift3_1 => "Right Shift LED 1", + LedCode::Rshift3_2 => "Right Shift LED 2", + LedCode::Rshift3_3 => "Right Shift LED 3", + LedCode::End => "End", + LedCode::LCtrl => "Left Control", + LedCode::LFn => "Left Fn", + LedCode::Meta => "Meta", + LedCode::LAlt => "Left Alt", + LedCode::Spacebar => "Space", + LedCode::Spacebar5_1 => "Space LED 1", + LedCode::Spacebar5_2 => "Space LED 2", + LedCode::Spacebar5_3 => "Space LED 3", + LedCode::Spacebar5_4 => "Space LED 4", + LedCode::Spacebar5_5 => "Space LED 5", + LedCode::RAlt => "Right Alt", + LedCode::PrtSc => "Print Screen", + LedCode::RCtrl => "Right Control", + LedCode::Pause => "Pause", + LedCode::Up => "Up", + LedCode::Down => "Down", + LedCode::Left => "Left", + LedCode::Right => "Right", + LedCode::RFn => "Right Fn", + LedCode::MediaPlay => "Media Play", + LedCode::MediaStop => "Media Stop", + LedCode::MediaNext => "Media Next", + LedCode::MediaPrev => "Media Previous", + LedCode::LidLogo => "Lid Logo", + LedCode::LidLeft => "Lid Left", + LedCode::LidRight => "Lid Right", + LedCode::LightbarRight => "Lightbar Right", + LedCode::LightbarRightCorner => "Lightbar Right Corner", + LedCode::LightbarRightBottom => "Lightbar Right Bottom", + LedCode::LightbarLeftBottom => "Lightbar Left Bottom", + LedCode::LightbarLeftCorner => "Lightbar Left Corner", + LedCode::LightbarLeft => "Lightbar Left", + LedCode::Spacing | LedCode::Blocking => "", + LedCode::SingleZone => "Single Zoned Keyboard", + LedCode::ZonedKbLeft => "Left Zone (zone 1)", + LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)", + LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)", + LedCode::ZonedKbRight => "Right Zone (zone 4)", + } + } +} + #[cfg(test)] mod tests { - use crate::advanced::{LedCode, LedUsbPackets, UsbPackets}; + use crate::keyboard::{LedCode, LedUsbPackets, UsbPackets}; macro_rules! colour_check_zoned { ($zone:expr, $pkt_idx_start:expr) => { diff --git a/rog-aura/src/layouts.rs b/rog-aura/src/keyboard/layouts.rs similarity index 99% rename from rog-aura/src/layouts.rs rename to rog-aura/src/keyboard/layouts.rs index 086c68ba..2e978af6 100644 --- a/rog-aura/src/layouts.rs +++ b/rog-aura/src/keyboard/layouts.rs @@ -8,10 +8,10 @@ use std::slice::Iter; use log::warn; use serde::{Deserialize, Serialize}; -use crate::advanced::LedCode; use crate::aura_detection::LaptopLedData; use crate::error::Error; -use crate::{AdvancedAuraType, AuraModeNum, AuraZone}; +use crate::keyboard::{AdvancedAuraType, LedCode}; +use crate::{AuraModeNum, AuraZone}; /// The `key_type` plays a role in effects (eventually). You could for example /// add a `ShapeType::Spacing` to pad out an effect, such as a laserbeam across @@ -459,7 +459,7 @@ mod tests { use std::path::PathBuf; use crate::aura_detection::LedSupportFile; - use crate::layouts::KeyLayout; + use crate::keyboard::KeyLayout; #[test] fn check_parse_all() { diff --git a/rog-aura/src/keyboard/mod.rs b/rog-aura/src/keyboard/mod.rs new file mode 100644 index 00000000..16d2ee61 --- /dev/null +++ b/rog-aura/src/keyboard/mod.rs @@ -0,0 +1,20 @@ +/// All handling for `RgbAddress`ing. +mod advanced; +pub use advanced::*; + +/// Helpers for consructing keyboard layouts for UI use and effects +mod layouts; +pub use layouts::*; + +mod power; +pub use power::*; + +#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize)] +pub enum AdvancedAuraType { + /// A `None` will apply the effect to the whole keyboard via basic-static + /// mode + #[default] + None, + Zoned(Vec), + PerKey, +} diff --git a/rog-aura/src/keyboard/power.rs b/rog-aura/src/keyboard/power.rs new file mode 100644 index 00000000..131dac02 --- /dev/null +++ b/rog-aura/src/keyboard/power.rs @@ -0,0 +1,472 @@ +//! Power state for Laptop MCU RGB/LED. This is generally for newer +//! 0x18c6, 0x19B6, 0x1a30, keyboard models (2021+) +use std::fmt::Debug; +use std::ops::{BitAnd, BitOr}; + +use serde::{Deserialize, Serialize}; +use typeshare::typeshare; +#[cfg(feature = "dbus")] +use zbus::zvariant::{OwnedValue, Type, Value}; + +use crate::aura_detection::PowerZones; + +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct AuraPowerState { + pub boot: bool, + pub awake: bool, + pub sleep: bool, + pub shutdown: bool, +} + +impl Default for AuraPowerState { + /// Defaults all to off + fn default() -> Self { + Self { + boot: false, + awake: false, + sleep: false, + shutdown: false, + } + } +} + +impl AuraPowerState { + pub fn to_byte(&self, zone: PowerZones) -> u32 { + match zone { + PowerZones::Logo => { + self.boot as u32 + | (self.awake as u32) << 2 + | (self.sleep as u32) << 4 + | (self.shutdown as u32) << 6 + } + PowerZones::Keyboard => { + (self.boot as u32) << 1 + | (self.awake as u32) << 3 + | (self.sleep as u32) << 5 + | (self.shutdown as u32) << 7 + } + PowerZones::Lightbar => { + (self.boot as u32) << (7 + 2) + | (self.awake as u32) << (7 + 3) + | (self.sleep as u32) << (7 + 4) + | (self.shutdown as u32) << (7 + 5) + } + PowerZones::Lid => { + (self.boot as u32) << (15 + 1) + | (self.awake as u32) << (15 + 2) + | (self.sleep as u32) << (15 + 3) + | (self.shutdown as u32) << (15 + 4) + } + PowerZones::RearGlow => { + (self.boot as u32) << (23 + 1) + | (self.awake as u32) << (23 + 2) + | (self.sleep as u32) << (23 + 3) + | (self.shutdown as u32) << (23 + 4) + } + } + } +} + +/// Track and control the Aura keyboard power state +/// +/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models +/// +/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label | +/// |--------|---------|---------|---------|----------| +/// |00000001| 00000000| 00000000| 00000000|boot_logo_| +/// |00000010| 00000000| 00000000| 00000000|boot_keyb_| +/// |00000100| 00000000| 00000000| 00000000|awake_logo| +/// |00001000| 00000000| 00000000| 00000000|awake_keyb| +/// |00010000| 00000000| 00000000| 00000000|sleep_logo| +/// |00100000| 00000000| 00000000| 00000000|sleep_keyb| +/// |01000000| 00000000| 00000000| 00000000|shut_logo_| +/// |10000000| 00000000| 00000000| 00000000|shut_keyb_| +/// |00000000| 00000010| 00000000| 00000000|boot_bar__| +/// |00000000| 00000100| 00000000| 00000000|awake_bar_| +/// |00000000| 00001000| 00000000| 00000000|sleep_bar_| +/// |00000000| 00010000| 00000000| 00000000|shut_bar__| +/// |00000000| 00000000| 00000001| 00000000|boot_lid__| +/// |00000000| 00000000| 00000010| 00000000|awkae_lid_| +/// |00000000| 00000000| 00000100| 00000000|sleep_lid_| +/// |00000000| 00000000| 00001000| 00000000|shut_lid__| +/// |00000000| 00000000| 00000000| 00000001|boot_rear_| +/// |00000000| 00000000| 00000000| 00000010|awake_rear| +/// |00000000| 00000000| 00000000| 00000100|sleep_rear| +/// |00000000| 00000000| 00000000| 00001000|shut_rear_| +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct LaptopAuraPower { + pub keyboard: AuraPowerState, + pub logo: AuraPowerState, + pub lightbar: AuraPowerState, + pub lid: AuraPowerState, + pub rear_glow: AuraPowerState, +} + +impl LaptopAuraPower { + pub fn new_all_on() -> Self { + Self { + keyboard: AuraPowerState { + boot: true, + awake: true, + sleep: true, + shutdown: true, + }, + logo: AuraPowerState { + boot: true, + awake: true, + sleep: true, + shutdown: true, + }, + lightbar: AuraPowerState { + boot: true, + awake: true, + sleep: true, + shutdown: true, + }, + lid: AuraPowerState { + boot: true, + awake: true, + sleep: true, + shutdown: true, + }, + rear_glow: AuraPowerState { + boot: true, + awake: true, + sleep: true, + shutdown: true, + }, + } + } + + pub fn to_bytes(&self) -> [u8; 4] { + let mut a: u32 = 0; + a |= self.keyboard.to_byte(PowerZones::Keyboard); + a |= self.logo.to_byte(PowerZones::Logo); + a |= self.lid.to_byte(PowerZones::Lid); + a |= self.lightbar.to_byte(PowerZones::Lightbar); + a |= self.rear_glow.to_byte(PowerZones::RearGlow); + [ + (a & 0xff) as u8, + ((a & 0xff00) >> 8) as u8, + ((a & 0xff0000) >> 16) as u8, + ((a & 0xff000000) >> 24) as u8, + ] + } +} + +#[typeshare] +#[cfg_attr( + feature = "dbus", + derive(Type, Value, OwnedValue), + zvariant(signature = "u") +)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum LaptopTufAuraPower { + Boot = 0, + Awake = 1, + Sleep = 2, + Keyboard = 3, +} + +impl LaptopTufAuraPower { + pub const fn dev_id() -> &'static str { + "tuf" + } +} + +/// # Bits for older 0x1866 keyboard model +/// +/// Keybord and Lightbar require Awake, Boot and Sleep apply to both +/// Keybord and Lightbar regardless of if either are enabled (or Awake is +/// enabled) +/// +/// | Byte 1 | Byte 2 | Byte 3 | function | hex | +/// |------------|------------|------------|----------|----------| +/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 | +/// | 0000, 1000 | 0000, 0000 | 0000, 0000 | Keyboard | 08,00,00 | +/// | 0000, 0100 | 0000, 0101 | 0000, 0000 | Lightbar | 04,05,00 | +/// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 | +/// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 | +/// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | | +#[typeshare] +#[cfg_attr( + feature = "dbus", + derive(Type, Value, OwnedValue), + zvariant(signature = "u") +)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum LaptopOldAuraPower { + Awake = 0x000002, + Keyboard = 0x080000, + Lightbar = 0x040500, + Boot = 0xc31209, + Sleep = 0x300804, +} + +impl From for u32 { + fn from(a: LaptopOldAuraPower) -> Self { + a as u32 + } +} + +impl LaptopOldAuraPower { + pub fn to_bytes(control: &[Self]) -> [u8; 4] { + let mut a: u32 = 0; + for n in control { + a |= *n as u32; + } + [ + ((a & 0xff0000) >> 16) as u8, + ((a & 0xff00) >> 8) as u8, + (a & 0xff) as u8, + 0x00, + ] + } + + pub const fn dev_id() -> &'static str { + "0x1866" + } +} + +impl BitOr for LaptopOldAuraPower { + type Output = u32; + + fn bitor(self, rhs: LaptopOldAuraPower) -> Self::Output { + self as u32 | rhs as u32 + } +} + +impl BitAnd for LaptopOldAuraPower { + type Output = u32; + + fn bitand(self, rhs: LaptopOldAuraPower) -> Self::Output { + self as u32 & rhs as u32 + } +} + +#[cfg(test)] +mod test { + use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopOldAuraPower}; + + #[test] + fn check_0x1866_control_bytes() { + let bytes = [LaptopOldAuraPower::Keyboard, LaptopOldAuraPower::Awake]; + let bytes = LaptopOldAuraPower::to_bytes(&bytes); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); + + let bytes = [LaptopOldAuraPower::Lightbar, LaptopOldAuraPower::Awake]; + let bytes = LaptopOldAuraPower::to_bytes(&bytes); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]); + + let bytes = [LaptopOldAuraPower::Sleep]; + let bytes = LaptopOldAuraPower::to_bytes(&bytes); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]); + + let bytes = [LaptopOldAuraPower::Boot]; + let bytes = LaptopOldAuraPower::to_bytes(&bytes); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]); + + let bytes = [ + LaptopOldAuraPower::Keyboard, + LaptopOldAuraPower::Lightbar, + LaptopOldAuraPower::Awake, + LaptopOldAuraPower::Sleep, + LaptopOldAuraPower::Boot, + ]; + + let bytes = LaptopOldAuraPower::to_bytes(&bytes); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); + } + + #[test] + fn check_0x19b6_control_bytes_binary_rep() { + fn to_binary_string(power: &LaptopAuraPower) -> String { + let bytes = power.to_bytes(); + format!( + "{:08b}, {:08b}, {:08b}, {:08b}", + bytes[0], bytes[1], bytes[2], bytes[3] + ) + } + + let boot_logo_ = to_binary_string(&LaptopAuraPower { + logo: AuraPowerState { + boot: true, + ..Default::default() + }, + ..Default::default() + }); + let boot_keyb_ = to_binary_string(&LaptopAuraPower { + keyboard: AuraPowerState { + boot: true, + ..Default::default() + }, + ..Default::default() + }); + let sleep_logo = to_binary_string(&LaptopAuraPower { + logo: AuraPowerState { + sleep: true, + ..Default::default() + }, + ..Default::default() + }); + let sleep_keyb = to_binary_string(&LaptopAuraPower { + keyboard: AuraPowerState { + sleep: true, + ..Default::default() + }, + ..Default::default() + }); + let awake_logo = to_binary_string(&LaptopAuraPower { + logo: AuraPowerState { + awake: true, + ..Default::default() + }, + ..Default::default() + }); + let awake_keyb = to_binary_string(&LaptopAuraPower { + keyboard: AuraPowerState { + awake: true, + ..Default::default() + }, + ..Default::default() + }); + let shut_logo_ = to_binary_string(&LaptopAuraPower { + logo: AuraPowerState { + shutdown: true, + ..Default::default() + }, + ..Default::default() + }); + let shut_keyb_ = to_binary_string(&LaptopAuraPower { + keyboard: AuraPowerState { + shutdown: true, + ..Default::default() + }, + ..Default::default() + }); + let boot_bar__ = to_binary_string(&LaptopAuraPower { + lightbar: AuraPowerState { + boot: true, + ..Default::default() + }, + ..Default::default() + }); + let awake_bar_ = to_binary_string(&LaptopAuraPower { + lightbar: AuraPowerState { + awake: true, + ..Default::default() + }, + ..Default::default() + }); + let sleep_bar_ = to_binary_string(&LaptopAuraPower { + lightbar: AuraPowerState { + sleep: true, + ..Default::default() + }, + ..Default::default() + }); + let shut_bar__ = to_binary_string(&LaptopAuraPower { + lightbar: AuraPowerState { + shutdown: true, + ..Default::default() + }, + ..Default::default() + }); + let boot_lid__ = to_binary_string(&LaptopAuraPower { + lid: AuraPowerState { + boot: true, + ..Default::default() + }, + ..Default::default() + }); + let awake_lid_ = to_binary_string(&LaptopAuraPower { + lid: AuraPowerState { + awake: true, + ..Default::default() + }, + ..Default::default() + }); + let sleep_lid_ = to_binary_string(&LaptopAuraPower { + lid: AuraPowerState { + sleep: true, + ..Default::default() + }, + ..Default::default() + }); + let shut_lid__ = to_binary_string(&LaptopAuraPower { + lid: AuraPowerState { + shutdown: true, + ..Default::default() + }, + ..Default::default() + }); + let boot_rear_ = to_binary_string(&LaptopAuraPower { + rear_glow: AuraPowerState { + boot: true, + ..Default::default() + }, + ..Default::default() + }); + let awake_rear = to_binary_string(&LaptopAuraPower { + rear_glow: AuraPowerState { + awake: true, + ..Default::default() + }, + ..Default::default() + }); + let sleep_rear = to_binary_string(&LaptopAuraPower { + rear_glow: AuraPowerState { + sleep: true, + ..Default::default() + }, + ..Default::default() + }); + let shut_rear_ = to_binary_string(&LaptopAuraPower { + rear_glow: AuraPowerState { + shutdown: true, + ..Default::default() + }, + ..Default::default() + }); + + assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); + assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000"); + assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000"); + assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000"); + assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000"); + assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000"); + assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000"); + assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000"); + // + assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000"); + assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000"); + assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000"); + assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000"); + // + assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000"); + assert_eq!(awake_lid_, "00000000, 00000000, 00000010, 00000000"); + assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000"); + assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000"); + // + assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001"); + assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010"); + assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100"); + assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); + + // All on + let byte1 = LaptopAuraPower::new_all_on(); + 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 10971d85..3d34a0e9 100644 --- a/rog-aura/src/lib.rs +++ b/rog-aura/src/lib.rs @@ -1,29 +1,21 @@ // TODO: Generic builtin modes // TODO: Traits for finding device + writing generic modes // TODO: Traits for writing aura_sync - -mod builtin_modes; -use advanced::LedCode; -pub use builtin_modes::*; +// TODO: separate keyboard and laptop parts? /// A container of images/grids/gifs/pauses which can be iterated over to /// generate cool effects pub mod effects; -/// All handling for `RgbAddress`ing. -pub mod advanced; -/// Convert the `RgbAddress` to `&str` labels -pub mod advanced_to_str; +mod builtin_modes; +pub use builtin_modes::*; + /// Helper for detecting what is available pub mod aura_detection; pub mod error; -/// Helpers for consructing keyboard layouts for UI use and effects -pub mod layouts; pub mod usb; -pub mod power; - -mod deprecated; +pub mod keyboard; pub const LED_MSG_LEN: usize = 17; pub const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -64,13 +56,3 @@ pub const ORANGE: Colour = Colour { b: 0x00, }; pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE]; - -#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize)] -pub enum AdvancedAuraType { - /// A `None` will apply the effect to the whole keyboard via basic-static - /// mode - #[default] - None, - Zoned(Vec), - PerKey, -} diff --git a/rog-aura/src/power.rs b/rog-aura/src/power.rs deleted file mode 100644 index 944446da..00000000 --- a/rog-aura/src/power.rs +++ /dev/null @@ -1,344 +0,0 @@ -use std::fmt::Debug; - -use serde::{Deserialize, Serialize}; -use typeshare::typeshare; -#[cfg(feature = "dbus")] -use zbus::zvariant::{OwnedValue, Type, Value}; - -use crate::aura_detection::PowerZones; - -#[typeshare] -#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct KbAuraPowerState { - pub zone: PowerZones, - pub boot: bool, - pub awake: bool, - pub sleep: bool, - pub shutdown: bool, -} - -impl Default for KbAuraPowerState { - /// Defaults all to off - fn default() -> Self { - Self { - zone: PowerZones::Keyboard, - boot: false, - awake: false, - sleep: false, - shutdown: false, - } - } -} - -impl KbAuraPowerState { - pub fn to_byte(&self, zone: PowerZones) -> u32 { - match zone { - PowerZones::Logo => { - self.boot as u32 - | (self.awake as u32) << 2 - | (self.sleep as u32) << 4 - | (self.shutdown as u32) << 6 - } - PowerZones::Keyboard => { - (self.boot as u32) << 1 - | (self.awake as u32) << 3 - | (self.sleep as u32) << 5 - | (self.shutdown as u32) << 7 - } - PowerZones::Lightbar => { - (self.boot as u32) << (7 + 2) - | (self.awake as u32) << (7 + 3) - | (self.sleep as u32) << (7 + 4) - | (self.shutdown as u32) << (7 + 5) - } - PowerZones::Lid => { - (self.boot as u32) << (15 + 1) - | (self.awake as u32) << (15 + 2) - | (self.sleep as u32) << (15 + 3) - | (self.shutdown as u32) << (15 + 4) - } - PowerZones::RearGlow => { - (self.boot as u32) << (23 + 1) - | (self.awake as u32) << (23 + 2) - | (self.sleep as u32) << (23 + 3) - | (self.shutdown as u32) << (23 + 4) - } - } - } -} - -/// Track and control the Aura keyboard power state -/// -/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models -/// -/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label | -/// |--------|---------|---------|---------|----------| -/// |00000001| 00000000| 00000000| 00000000|boot_logo_| -/// |00000010| 00000000| 00000000| 00000000|boot_keyb_| -/// |00000100| 00000000| 00000000| 00000000|awake_logo| -/// |00001000| 00000000| 00000000| 00000000|awake_keyb| -/// |00010000| 00000000| 00000000| 00000000|sleep_logo| -/// |00100000| 00000000| 00000000| 00000000|sleep_keyb| -/// |01000000| 00000000| 00000000| 00000000|shut_logo_| -/// |10000000| 00000000| 00000000| 00000000|shut_keyb_| -/// |00000000| 00000010| 00000000| 00000000|boot_bar__| -/// |00000000| 00000100| 00000000| 00000000|awake_bar_| -/// |00000000| 00001000| 00000000| 00000000|sleep_bar_| -/// |00000000| 00010000| 00000000| 00000000|shut_bar__| -/// |00000000| 00000000| 00000001| 00000000|boot_lid__| -/// |00000000| 00000000| 00000010| 00000000|awkae_lid_| -/// |00000000| 00000000| 00000100| 00000000|sleep_lid_| -/// |00000000| 00000000| 00001000| 00000000|shut_lid__| -/// |00000000| 00000000| 00000000| 00000001|boot_rear_| -/// |00000000| 00000000| 00000000| 00000010|awake_rear| -/// |00000000| 00000000| 00000000| 00000100|sleep_rear| -/// |00000000| 00000000| 00000000| 00001000|shut_rear_| -#[typeshare] -#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct AuraPower { - pub keyboard: KbAuraPowerState, - pub logo: KbAuraPowerState, - pub lightbar: KbAuraPowerState, - pub lid: KbAuraPowerState, - pub rear_glow: KbAuraPowerState, -} - -impl AuraPower { - pub fn new_all_on() -> Self { - Self { - keyboard: KbAuraPowerState { - zone: PowerZones::Keyboard, - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - logo: KbAuraPowerState { - zone: PowerZones::Logo, - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - lightbar: KbAuraPowerState { - zone: PowerZones::Lightbar, - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - lid: KbAuraPowerState { - zone: PowerZones::Lid, - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - rear_glow: KbAuraPowerState { - zone: PowerZones::RearGlow, - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - } - } - - pub fn to_bytes(&self) -> [u8; 4] { - let mut a: u32 = 0; - a |= self.keyboard.to_byte(PowerZones::Keyboard); - a |= self.logo.to_byte(PowerZones::Logo); - a |= self.lid.to_byte(PowerZones::Lid); - a |= self.lightbar.to_byte(PowerZones::Lightbar); - a |= self.rear_glow.to_byte(PowerZones::RearGlow); - [ - (a & 0xff) as u8, - ((a & 0xff00) >> 8) as u8, - ((a & 0xff0000) >> 16) as u8, - ((a & 0xff000000) >> 24) as u8, - ] - } -} - -#[test] -fn check_0x19b6_control_bytes_binary_rep() { - fn to_binary_string(power: &AuraPower) -> String { - let bytes = power.to_bytes(); - format!( - "{:08b}, {:08b}, {:08b}, {:08b}", - bytes[0], bytes[1], bytes[2], bytes[3] - ) - } - - let boot_logo_ = to_binary_string(&AuraPower { - logo: KbAuraPowerState { - boot: true, - ..Default::default() - }, - ..Default::default() - }); - let boot_keyb_ = to_binary_string(&AuraPower { - keyboard: KbAuraPowerState { - boot: true, - ..Default::default() - }, - ..Default::default() - }); - let sleep_logo = to_binary_string(&AuraPower { - logo: KbAuraPowerState { - sleep: true, - ..Default::default() - }, - ..Default::default() - }); - let sleep_keyb = to_binary_string(&AuraPower { - keyboard: KbAuraPowerState { - sleep: true, - ..Default::default() - }, - ..Default::default() - }); - let awake_logo = to_binary_string(&AuraPower { - logo: KbAuraPowerState { - awake: true, - ..Default::default() - }, - ..Default::default() - }); - let awake_keyb = to_binary_string(&AuraPower { - keyboard: KbAuraPowerState { - awake: true, - ..Default::default() - }, - ..Default::default() - }); - let shut_logo_ = to_binary_string(&AuraPower { - logo: KbAuraPowerState { - shutdown: true, - ..Default::default() - }, - ..Default::default() - }); - let shut_keyb_ = to_binary_string(&AuraPower { - keyboard: KbAuraPowerState { - shutdown: true, - ..Default::default() - }, - ..Default::default() - }); - let boot_bar__ = to_binary_string(&AuraPower { - lightbar: KbAuraPowerState { - boot: true, - ..Default::default() - }, - ..Default::default() - }); - let awake_bar_ = to_binary_string(&AuraPower { - lightbar: KbAuraPowerState { - awake: true, - ..Default::default() - }, - ..Default::default() - }); - let sleep_bar_ = to_binary_string(&AuraPower { - lightbar: KbAuraPowerState { - sleep: true, - ..Default::default() - }, - ..Default::default() - }); - let shut_bar__ = to_binary_string(&AuraPower { - lightbar: KbAuraPowerState { - shutdown: true, - ..Default::default() - }, - ..Default::default() - }); - let boot_lid__ = to_binary_string(&AuraPower { - lid: KbAuraPowerState { - boot: true, - ..Default::default() - }, - ..Default::default() - }); - let awkae_lid_ = to_binary_string(&AuraPower { - lid: KbAuraPowerState { - awake: true, - ..Default::default() - }, - ..Default::default() - }); - let sleep_lid_ = to_binary_string(&AuraPower { - lid: KbAuraPowerState { - sleep: true, - ..Default::default() - }, - ..Default::default() - }); - let shut_lid__ = to_binary_string(&AuraPower { - lid: KbAuraPowerState { - shutdown: true, - ..Default::default() - }, - ..Default::default() - }); - let boot_rear_ = to_binary_string(&AuraPower { - rear_glow: KbAuraPowerState { - boot: true, - ..Default::default() - }, - ..Default::default() - }); - let awake_rear = to_binary_string(&AuraPower { - rear_glow: KbAuraPowerState { - awake: true, - ..Default::default() - }, - ..Default::default() - }); - let sleep_rear = to_binary_string(&AuraPower { - rear_glow: KbAuraPowerState { - sleep: true, - ..Default::default() - }, - ..Default::default() - }); - let shut_rear_ = to_binary_string(&AuraPower { - rear_glow: KbAuraPowerState { - shutdown: true, - ..Default::default() - }, - ..Default::default() - }); - - assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); - assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000"); - assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000"); - assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000"); - assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000"); - assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000"); - assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000"); - assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000"); - // - assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000"); - assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000"); - assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000"); - assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000"); - // - assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000"); - assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000"); - assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000"); - assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000"); - // - assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001"); - assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010"); - assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100"); - assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); - - // All on - let byte1 = AuraPower::new_all_on(); - let out = to_binary_string(&byte1); - assert_eq!(out, "11111111, 00011110, 00001111, 00001111"); -} diff --git a/rog-aura/src/usb.rs b/rog-aura/src/usb.rs index 19944b41..d612ea05 100644 --- a/rog-aura/src/usb.rs +++ b/rog-aura/src/usb.rs @@ -1,18 +1,11 @@ use std::fmt::Debug; -use std::ops::{BitAnd, BitOr}; use serde::{Deserialize, Serialize}; use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::{OwnedValue, Type, Value}; -use crate::power::AuraPower; - -pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9]; -pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d -pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08]; -pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e -pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08]; +use crate::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower}; // Only these two packets must be 17 bytes pub const LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; @@ -36,11 +29,15 @@ pub enum AuraDevice { Tuf = 0, X1854 = 1, X1869 = 2, + /// Pre-2020 laptops X1866 = 3, + /// Z13 lightbar X18c6 = 4, + /// Most modern laptops #[default] X19b6 = 5, X1a30 = 6, + /// The ROG Ally X1abe = 7, Unknown = 99, } @@ -51,22 +48,14 @@ impl AuraDevice { } pub fn is_old_style(&self) -> bool { - !matches!( + matches!( self, - AuraDevice::Unknown - | AuraDevice::Tuf - | AuraDevice::X19b6 - | AuraDevice::X18c6 - | AuraDevice::X1a30 - | AuraDevice::X1abe + AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 | AuraDevice::X1abe ) } pub fn is_new_style(&self) -> bool { - matches!( - self, - AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 | AuraDevice::X1abe - ) + !self.is_old_style() && !self.is_tuf_style() } } @@ -125,142 +114,10 @@ impl Debug for AuraDevice { pub struct AuraPowerDev { /// TUF laptops use a similar style of control to the older ROG devices but /// through WMI - pub tuf: Vec, + pub tuf: Vec, /// Pre-0x19b6 devices use a different smaller scheme to the newer ROG /// devices - pub old_rog: Vec, + pub old_rog: Vec, /// ASUS standardised control scheme from 2020 onwards - pub rog: AuraPower, -} - -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "u") -)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum AuraDevTuf { - Boot = 0, - Awake = 1, - Sleep = 2, - Keyboard = 3, -} - -impl AuraDevTuf { - pub const fn dev_id() -> &'static str { - "tuf" - } -} - -/// # Bits for older 0x1866 keyboard model -/// -/// Keybord and Lightbar require Awake, Boot and Sleep apply to both -/// Keybord and Lightbar regardless of if either are enabled (or Awake is -/// enabled) -/// -/// | Byte 1 | Byte 2 | Byte 3 | function | hex | -/// |------------|------------|------------|----------|----------| -/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 | -/// | 0000, 1000 | 0000, 0000 | 0000, 0000 | Keyboard | 08,00,00 | -/// | 0000, 0100 | 0000, 0101 | 0000, 0000 | Lightbar | 04,05,00 | -/// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 | -/// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 | -/// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | | -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "u") -)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum AuraDevRog1 { - Awake = 0x000002, - Keyboard = 0x080000, - Lightbar = 0x040500, - Boot = 0xc31209, - Sleep = 0x300804, -} - -impl From for u32 { - fn from(a: AuraDevRog1) -> Self { - a as u32 - } -} - -impl AuraDevRog1 { - pub fn to_bytes(control: &[Self]) -> [u8; 4] { - let mut a: u32 = 0; - for n in control { - a |= *n as u32; - } - [ - ((a & 0xff0000) >> 16) as u8, - ((a & 0xff00) >> 8) as u8, - (a & 0xff) as u8, - 0x00, - ] - } - - pub const fn dev_id() -> &'static str { - "0x1866" - } -} - -impl BitOr for AuraDevRog1 { - type Output = u32; - - fn bitor(self, rhs: AuraDevRog1) -> Self::Output { - self as u32 | rhs as u32 - } -} - -impl BitAnd for AuraDevRog1 { - type Output = u32; - - fn bitand(self, rhs: AuraDevRog1) -> Self::Output { - self as u32 & rhs as u32 - } -} - -#[cfg(test)] -mod tests { - use super::AuraDevRog1; - - #[test] - fn check_0x1866_control_bytes() { - let bytes = [AuraDevRog1::Keyboard, AuraDevRog1::Awake]; - let bytes = AuraDevRog1::to_bytes(&bytes); - println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); - assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); - - let bytes = [AuraDevRog1::Lightbar, AuraDevRog1::Awake]; - let bytes = AuraDevRog1::to_bytes(&bytes); - println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); - assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]); - - let bytes = [AuraDevRog1::Sleep]; - let bytes = AuraDevRog1::to_bytes(&bytes); - println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); - assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]); - - let bytes = [AuraDevRog1::Boot]; - let bytes = AuraDevRog1::to_bytes(&bytes); - println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); - assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]); - - let bytes = [ - AuraDevRog1::Keyboard, - AuraDevRog1::Lightbar, - AuraDevRog1::Awake, - AuraDevRog1::Sleep, - AuraDevRog1::Boot, - ]; - - let bytes = AuraDevRog1::to_bytes(&bytes); - println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); - assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); - } + pub rog: LaptopAuraPower, } diff --git a/rog-control-center/src/types/aura_types.rs b/rog-control-center/src/types/aura_types.rs index 35f363f3..085c4d54 100644 --- a/rog-control-center/src/types/aura_types.rs +++ b/rog-control-center/src/types/aura_types.rs @@ -46,53 +46,54 @@ impl From for rog_aura::AuraEffect } } -use rog_aura::power::KbAuraPowerState; +use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower}; +use rog_aura::usb::AuraPowerDev; use slint::{Model, ModelRc, RgbaColor}; use crate::slint_generatedMainWindow::AuraDevTuf as SlintAuraDevTuf; -impl From for SlintAuraDevTuf { - fn from(value: rog_aura::usb::AuraDevTuf) -> Self { +impl From for SlintAuraDevTuf { + fn from(value: LaptopTufAuraPower) -> Self { match value { - rog_aura::usb::AuraDevTuf::Boot => SlintAuraDevTuf::Boot, - rog_aura::usb::AuraDevTuf::Awake => SlintAuraDevTuf::Awake, - rog_aura::usb::AuraDevTuf::Sleep => SlintAuraDevTuf::Sleep, - rog_aura::usb::AuraDevTuf::Keyboard => SlintAuraDevTuf::Keyboard, + LaptopTufAuraPower::Boot => SlintAuraDevTuf::Boot, + LaptopTufAuraPower::Awake => SlintAuraDevTuf::Awake, + LaptopTufAuraPower::Sleep => SlintAuraDevTuf::Sleep, + LaptopTufAuraPower::Keyboard => SlintAuraDevTuf::Keyboard, } } } -impl From for rog_aura::usb::AuraDevTuf { +impl From for LaptopTufAuraPower { fn from(value: SlintAuraDevTuf) -> Self { match value { - SlintAuraDevTuf::Boot => rog_aura::usb::AuraDevTuf::Boot, - SlintAuraDevTuf::Awake => rog_aura::usb::AuraDevTuf::Awake, - SlintAuraDevTuf::Sleep => rog_aura::usb::AuraDevTuf::Sleep, - SlintAuraDevTuf::Keyboard => rog_aura::usb::AuraDevTuf::Keyboard, + SlintAuraDevTuf::Boot => LaptopTufAuraPower::Boot, + SlintAuraDevTuf::Awake => LaptopTufAuraPower::Awake, + SlintAuraDevTuf::Sleep => LaptopTufAuraPower::Sleep, + SlintAuraDevTuf::Keyboard => LaptopTufAuraPower::Keyboard, } } } use crate::slint_generatedMainWindow::AuraDevRog1 as SlintAuraDevRog1; -impl From for SlintAuraDevRog1 { - fn from(value: rog_aura::usb::AuraDevRog1) -> Self { +impl From for SlintAuraDevRog1 { + fn from(value: LaptopOldAuraPower) -> Self { match value { - rog_aura::usb::AuraDevRog1::Awake => SlintAuraDevRog1::Awake, - rog_aura::usb::AuraDevRog1::Keyboard => SlintAuraDevRog1::Keyboard, - rog_aura::usb::AuraDevRog1::Lightbar => SlintAuraDevRog1::Lightbar, - rog_aura::usb::AuraDevRog1::Boot => SlintAuraDevRog1::Boot, - rog_aura::usb::AuraDevRog1::Sleep => SlintAuraDevRog1::Sleep, + LaptopOldAuraPower::Awake => SlintAuraDevRog1::Awake, + LaptopOldAuraPower::Keyboard => SlintAuraDevRog1::Keyboard, + LaptopOldAuraPower::Lightbar => SlintAuraDevRog1::Lightbar, + LaptopOldAuraPower::Boot => SlintAuraDevRog1::Boot, + LaptopOldAuraPower::Sleep => SlintAuraDevRog1::Sleep, } } } -impl From for rog_aura::usb::AuraDevRog1 { +impl From for LaptopOldAuraPower { fn from(value: SlintAuraDevRog1) -> Self { match value { - SlintAuraDevRog1::Awake => rog_aura::usb::AuraDevRog1::Awake, - SlintAuraDevRog1::Keyboard => rog_aura::usb::AuraDevRog1::Keyboard, - SlintAuraDevRog1::Lightbar => rog_aura::usb::AuraDevRog1::Lightbar, - SlintAuraDevRog1::Boot => rog_aura::usb::AuraDevRog1::Boot, - SlintAuraDevRog1::Sleep => rog_aura::usb::AuraDevRog1::Sleep, + SlintAuraDevRog1::Awake => LaptopOldAuraPower::Awake, + SlintAuraDevRog1::Keyboard => LaptopOldAuraPower::Keyboard, + SlintAuraDevRog1::Lightbar => LaptopOldAuraPower::Lightbar, + SlintAuraDevRog1::Boot => LaptopOldAuraPower::Boot, + SlintAuraDevRog1::Sleep => LaptopOldAuraPower::Sleep, } } } @@ -125,93 +126,83 @@ impl From for rog_aura::aura_detection::PowerZones { use crate::slint_generatedMainWindow::{ AuraPower as SlintAuraPower, KbAuraPowerState as SlintKbAuraPowerState, }; -impl From for SlintAuraPower { - fn from(value: rog_aura::power::AuraPower) -> Self { +impl From for SlintAuraPower { + fn from(value: rog_aura::keyboard::LaptopAuraPower) -> Self { Self { keyboard: SlintKbAuraPowerState { awake: value.keyboard.awake, boot: value.keyboard.boot, shutdown: value.keyboard.shutdown, sleep: value.keyboard.sleep, - zone: value.keyboard.zone.into(), }, lid: SlintKbAuraPowerState { awake: value.lid.awake, boot: value.lid.boot, shutdown: value.lid.shutdown, sleep: value.lid.sleep, - zone: value.lid.zone.into(), }, lightbar: SlintKbAuraPowerState { awake: value.lightbar.awake, boot: value.lightbar.boot, shutdown: value.lightbar.shutdown, sleep: value.lightbar.sleep, - zone: value.lightbar.zone.into(), }, logo: SlintKbAuraPowerState { awake: value.logo.awake, boot: value.logo.boot, shutdown: value.logo.shutdown, sleep: value.logo.sleep, - zone: value.logo.zone.into(), }, rear_glow: SlintKbAuraPowerState { awake: value.rear_glow.awake, boot: value.rear_glow.boot, shutdown: value.rear_glow.shutdown, sleep: value.rear_glow.sleep, - zone: value.rear_glow.zone.into(), }, } } } -impl From for rog_aura::power::AuraPower { +impl From for rog_aura::keyboard::LaptopAuraPower { fn from(value: SlintAuraPower) -> Self { Self { - keyboard: KbAuraPowerState { + keyboard: AuraPowerState { awake: value.keyboard.awake, boot: value.keyboard.boot, shutdown: value.keyboard.shutdown, sleep: value.keyboard.sleep, - zone: value.keyboard.zone.into(), }, - lid: KbAuraPowerState { + lid: AuraPowerState { awake: value.lid.awake, boot: value.lid.boot, shutdown: value.lid.shutdown, sleep: value.lid.sleep, - zone: value.lid.zone.into(), }, - lightbar: KbAuraPowerState { + lightbar: AuraPowerState { awake: value.lightbar.awake, boot: value.lightbar.boot, shutdown: value.lightbar.shutdown, sleep: value.lightbar.sleep, - zone: value.lightbar.zone.into(), }, - logo: KbAuraPowerState { + logo: AuraPowerState { awake: value.logo.awake, boot: value.logo.boot, shutdown: value.logo.shutdown, sleep: value.logo.sleep, - zone: value.logo.zone.into(), }, - rear_glow: KbAuraPowerState { + rear_glow: AuraPowerState { awake: value.rear_glow.awake, boot: value.rear_glow.boot, shutdown: value.rear_glow.shutdown, sleep: value.rear_glow.sleep, - zone: value.rear_glow.zone.into(), }, } } } use crate::slint_generatedMainWindow::AuraPowerDev as SlintAuraPowerDev; -impl From for SlintAuraPowerDev { - fn from(value: rog_aura::usb::AuraPowerDev) -> Self { +impl From for SlintAuraPowerDev { + fn from(value: AuraPowerDev) -> Self { let tuf: Vec = value .tuf .iter() @@ -230,18 +221,11 @@ impl From for SlintAuraPowerDev { } } -impl From for rog_aura::usb::AuraPowerDev { +impl From for AuraPowerDev { fn from(value: SlintAuraPowerDev) -> Self { - let tuf: Vec = value - .tuf - .iter() - .map(rog_aura::usb::AuraDevTuf::from) - .collect(); - let old_rog: Vec = value - .old_rog - .iter() - .map(rog_aura::usb::AuraDevRog1::from) - .collect(); + let tuf: Vec = value.tuf.iter().map(LaptopTufAuraPower::from).collect(); + let old_rog: Vec = + value.old_rog.iter().map(LaptopOldAuraPower::from).collect(); Self { tuf, old_rog, diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index e2833c70..d0956a8d 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-05 03:00+0000\n" +"POT-Creation-Date: 2024-04-05 07:19+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-control-center/ui/types/aura_types.slint b/rog-control-center/ui/types/aura_types.slint index c0243a21..623bb31e 100644 --- a/rog-control-center/ui/types/aura_types.slint +++ b/rog-control-center/ui/types/aura_types.slint @@ -43,7 +43,6 @@ export enum PowerZones { } export struct KbAuraPowerState { - zone: PowerZones, boot: bool, awake: bool, sleep: bool, diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index f1e5e221..20760857 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -22,8 +22,8 @@ use std::collections::BTreeMap; -use rog_aura::advanced::UsbPackets; use rog_aura::aura_detection::PowerZones; +use rog_aura::keyboard::UsbPackets; use rog_aura::usb::{AuraDevice, AuraPowerDev}; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::blocking::Connection; From 635d0378ac5f5a15a10e0affd900202e8b445173 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 6 Apr 2024 14:10:18 +1300 Subject: [PATCH 09/12] Bump deps --- Cargo.lock | 118 ++++++++++-------- Cargo.toml | 4 +- .../translations/en/rog-control-center.po | 66 +++++----- 3 files changed, 100 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9627694b..b49005c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225" +checksum = "8e08104bebc65a46f8bc7aa733d39ea6874bfa7156f41a46b805785e3af1587d" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -139,7 +139,7 @@ dependencies = [ "tinybmp", "tokio", "toml 0.5.11", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -165,7 +165,7 @@ dependencies = [ "systemd-zbus", "tokio", "udev 0.8.0", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -185,7 +185,7 @@ dependencies = [ "serde_derive", "serde_json", "smol", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -204,7 +204,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258b52a1aa741b9f09783b2d86cf0aeeb617bbf847f6933340a39644227acbdb" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.0", "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", @@ -228,7 +228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 5.2.0", + "event-listener 5.3.0", "event-listener-strategy 0.5.1", "futures-core", "pin-project-lite", @@ -371,7 +371,7 @@ dependencies = [ "async-task", "blocking", "cfg-if", - "event-listener 5.2.0", + "event-listener 5.3.0", "futures-lite 2.3.0", "rustix 0.38.32", "tracing", @@ -854,7 +854,7 @@ dependencies = [ [[package]] name = "const-field-offset" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "const-field-offset-macro", "field-offset", @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "const-field-offset-macro" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "proc-macro2", "quote", @@ -1348,9 +1348,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91" +checksum = "6d9944b8ca13534cdfb2800775f8dd4902ff3fc75a50101466decadfdf322a24" dependencies = [ "concurrent-queue", "parking", @@ -1373,7 +1373,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" dependencies = [ - "event-listener 5.2.0", + "event-listener 5.3.0", "pin-project-lite", ] @@ -1695,9 +1695,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" dependencies = [ "cfg-if", "js-sys", @@ -1931,7 +1931,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "i-slint-backend-linuxkms" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "calloop", "drm", @@ -1951,7 +1951,7 @@ dependencies = [ [[package]] name = "i-slint-backend-qt" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "const-field-offset", "i-slint-common", @@ -1963,7 +1963,7 @@ dependencies = [ [[package]] name = "i-slint-backend-selector" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "cfg-if", "i-slint-backend-linuxkms", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "i-slint-backend-winit" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "bytemuck", "cfg-if", @@ -2009,7 +2009,7 @@ dependencies = [ [[package]] name = "i-slint-common" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "cfg-if", "derive_more", @@ -2020,7 +2020,7 @@ dependencies = [ [[package]] name = "i-slint-compiler" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "by_address", "codemap", @@ -2049,7 +2049,7 @@ dependencies = [ [[package]] name = "i-slint-core" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "auto_enums", "bytemuck", @@ -2094,7 +2094,7 @@ dependencies = [ [[package]] name = "i-slint-core-macros" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "quote", "syn 2.0.58", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "i-slint-renderer-femtovg" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "cfg-if", "const-field-offset", @@ -2134,7 +2134,7 @@ dependencies = [ [[package]] name = "i-slint-renderer-skia" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "bytemuck", "cfg-if", @@ -2605,12 +2605,12 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logind-zbus" -version = "4.0.0" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afde78d03ee08949efb760d0cd7ad9599379d91207de5c6e778fe9f8f98eae2" +checksum = "15b2375aeabe771d0774a333bf20aa89ea1805f4f9d094fc45e7390bfc7da42a" dependencies = [ "serde", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -2844,6 +2844,18 @@ dependencies = [ "bitflags 2.5.0", "cfg-if", "libc", +] + +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "cfg_aliases 0.1.1", + "libc", "memoffset 0.9.1", ] @@ -2865,7 +2877,7 @@ dependencies = [ "mac-notification-sys", "serde", "tauri-winrt-notification", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3459,7 +3471,7 @@ dependencies = [ "tokio", "versions", "winit", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3476,7 +3488,7 @@ dependencies = [ "serde", "serde_derive", "typeshare", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3490,7 +3502,7 @@ dependencies = [ "serde", "serde_derive", "typeshare", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3503,7 +3515,7 @@ dependencies = [ "rog_aura", "rog_platform", "rog_profiles", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3520,7 +3532,7 @@ dependencies = [ "serde_derive", "typeshare", "udev 0.8.0", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3534,7 +3546,7 @@ dependencies = [ "serde_derive", "typeshare", "udev 0.8.0", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -3889,7 +3901,7 @@ dependencies = [ [[package]] name = "slint" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "const-field-offset", "i-slint-backend-selector", @@ -3905,7 +3917,7 @@ dependencies = [ [[package]] name = "slint-build" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "i-slint-compiler", "spin_on", @@ -3916,7 +3928,7 @@ dependencies = [ [[package]] name = "slint-macros" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "i-slint-compiler", "proc-macro2", @@ -4115,7 +4127,7 @@ dependencies = [ [[package]] name = "supergfxctl" version = "5.2.2" -source = "git+https://gitlab.com/asus-linux/supergfxctl.git#a645c15fdb2eee6b16c8213eebcd90df2c950cdb" +source = "git+https://gitlab.com/asus-linux/supergfxctl.git#4eb6e97c22b68ae8d1e80500709b0c0580776ad3" dependencies = [ "log", "logind-zbus", @@ -4124,7 +4136,7 @@ dependencies = [ "serde_json", "tokio", "udev 0.8.0", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -4161,12 +4173,12 @@ dependencies = [ [[package]] name = "systemd-zbus" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7402f02e82714cc736e1c37449344ae06a181f9b8318d81a65af76d85868d51" +checksum = "a98ac0c9c7b08a92b01576551942fbfc80c64e7f2354e04b57264d9349fd2b2e" dependencies = [ "serde", - "zbus 4.0.1", + "zbus 4.1.2", ] [[package]] @@ -4691,7 +4703,7 @@ dependencies = [ [[package]] name = "vtable" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "const-field-offset", "portable-atomic", @@ -4702,7 +4714,7 @@ dependencies = [ [[package]] name = "vtable-macro" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#a8c3faa9a3e11766afece9b8cc3d35e6a2ca7c31" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" dependencies = [ "proc-macro2", "quote", @@ -5515,9 +5527,9 @@ dependencies = [ [[package]] name = "zbus" -version = "4.0.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b8e3d6ae3342792a6cc2340e4394334c7402f3d793b390d2c5494a4032b3030" +checksum = "c9ff46f2a25abd690ed072054733e0bc3157e3d4c45f41bd183dce09c2ff8ab9" dependencies = [ "async-broadcast 0.7.0", "async-executor", @@ -5531,12 +5543,12 @@ dependencies = [ "blocking", "derivative", "enumflags2", - "event-listener 5.2.0", + "event-listener 5.3.0", "futures-core", "futures-sink", "futures-util", "hex", - "nix 0.27.1", + "nix 0.28.0", "ordered-stream", "rand", "serde", @@ -5547,7 +5559,7 @@ dependencies = [ "uds_windows", "windows-sys 0.52.0", "xdg-home", - "zbus_macros 4.0.1", + "zbus_macros 4.1.2", "zbus_names 3.0.0", "zvariant 4.0.2", ] @@ -5568,11 +5580,11 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "4.0.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a3e850ff1e7217a3b7a07eba90d37fe9bb9e89a310f718afcde5885ca9b6d7" +checksum = "4e0e3852c93dcdb49c9462afe67a2a468f7bd464150d866e861eaf06208633e0" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "regex", diff --git a/Cargo.toml b/Cargo.toml index 3cbeb525..7d260ef6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,8 +39,8 @@ dirs = "^4.0" smol = "^1.3" mio = "0.8.11" -zbus = "~4.0.1" -logind-zbus = { version = "~4.0.0" } #, default-features = false, features = ["non_blocking"] } +zbus = "~4.1.2" +logind-zbus = { version = "~4.0.2" } #, default-features = false, features = ["non_blocking"] } serde = "^1.0" serde_derive = "^1.0" diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index d0956a8d..4fd1796b 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-05 07:19+0000\n" +"POT-Creation-Date: 2024-04-05 08:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -467,162 +467,162 @@ msgctxt "AuraPowerGroup" msgid "Shutdown" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:69 +#: rog-control-center/ui/types/aura_types.slint:68 msgctxt "Aura brightness" msgid "Off" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:70 +#: rog-control-center/ui/types/aura_types.slint:69 msgctxt "Aura brightness" msgid "Low" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:71 +#: rog-control-center/ui/types/aura_types.slint:70 msgctxt "Aura brightness" msgid "Med" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:72 +#: rog-control-center/ui/types/aura_types.slint:71 msgctxt "Aura brightness" msgid "High" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92 +#: rog-control-center/ui/types/aura_types.slint:76 rog-control-center/ui/types/aura_types.slint:91 msgctxt "Basic aura mode" msgid "Static" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93 +#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92 msgctxt "Basic aura mode" msgid "Breathe" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:79 rog-control-center/ui/types/aura_types.slint:94 +#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93 msgctxt "Basic aura mode" msgid "Strobe" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:80 +#: rog-control-center/ui/types/aura_types.slint:79 msgctxt "Basic aura mode" msgid "Rainbow" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:81 +#: rog-control-center/ui/types/aura_types.slint:80 msgctxt "Basic aura mode" msgid "Star" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:82 +#: rog-control-center/ui/types/aura_types.slint:81 msgctxt "Basic aura mode" msgid "Rain" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:83 +#: rog-control-center/ui/types/aura_types.slint:82 msgctxt "Basic aura mode" msgid "Highlight" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:84 +#: rog-control-center/ui/types/aura_types.slint:83 msgctxt "Basic aura mode" msgid "Laser" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:85 +#: rog-control-center/ui/types/aura_types.slint:84 msgctxt "Basic aura mode" msgid "Ripple" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:86 +#: rog-control-center/ui/types/aura_types.slint:85 msgctxt "Basic aura mode" msgid "Nothing" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:87 +#: rog-control-center/ui/types/aura_types.slint:86 msgctxt "Basic aura mode" msgid "Pulse" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:88 +#: rog-control-center/ui/types/aura_types.slint:87 msgctxt "Basic aura mode" msgid "Comet" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:89 +#: rog-control-center/ui/types/aura_types.slint:88 msgctxt "Basic aura mode" msgid "Flash" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:101 +#: rog-control-center/ui/types/aura_types.slint:100 msgctxt "Aura zone" msgid "None" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:102 +#: rog-control-center/ui/types/aura_types.slint:101 msgctxt "Aura zone" msgid "Key1" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:103 +#: rog-control-center/ui/types/aura_types.slint:102 msgctxt "Aura zone" msgid "Key2" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:104 +#: rog-control-center/ui/types/aura_types.slint:103 msgctxt "Aura zone" msgid "Key3" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:105 +#: rog-control-center/ui/types/aura_types.slint:104 msgctxt "Aura zone" msgid "Key4" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:106 +#: rog-control-center/ui/types/aura_types.slint:105 msgctxt "Aura zone" msgid "Logo" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:107 +#: rog-control-center/ui/types/aura_types.slint:106 msgctxt "Aura zone" msgid "Lightbar Left" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:108 +#: rog-control-center/ui/types/aura_types.slint:107 msgctxt "Aura zone" msgid "Lightbar Right" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:112 +#: rog-control-center/ui/types/aura_types.slint:111 msgctxt "Aura direction" msgid "Right" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:113 +#: rog-control-center/ui/types/aura_types.slint:112 msgctxt "Aura direction" msgid "Left" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:114 +#: rog-control-center/ui/types/aura_types.slint:113 msgctxt "Aura direction" msgid "Up" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:115 +#: rog-control-center/ui/types/aura_types.slint:114 msgctxt "Aura direction" msgid "Down" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:119 +#: rog-control-center/ui/types/aura_types.slint:118 msgctxt "Aura speed" msgid "Low" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:120 +#: rog-control-center/ui/types/aura_types.slint:119 msgctxt "Aura speed" msgid "Medium" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:121 +#: rog-control-center/ui/types/aura_types.slint:120 msgctxt "Aura speed" msgid "High" msgstr "" From 91ca049298eb26c8025ffc7374c266ac7bdb72d5 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 8 Apr 2024 21:33:28 +1200 Subject: [PATCH 10/12] Unify the laptop aura power stuff --- Cargo.lock | 58 +- asusctl/src/aura_cli.rs | 8 +- asusctl/src/main.rs | 115 ++-- asusd/src/ctrl_aura/config.rs | 124 +---- asusd/src/ctrl_aura/controller.rs | 14 +- asusd/src/ctrl_aura/trait_impls.rs | 26 +- rog-aura/src/aura_detection.rs | 4 +- rog-aura/src/keyboard/power.rs | 526 ++++++++++-------- rog-aura/src/usb.rs | 17 - rog-control-center/src/types/aura_types.rs | 12 +- rog-control-center/src/ui/setup_aura.rs | 4 +- .../translations/en/rog-control-center.po | 2 +- .../ui/widgets/colour_picker.slint | 8 +- rog-dbus/src/zbus_aura.rs | 8 +- 14 files changed, 425 insertions(+), 501 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b49005c6..3cd5b9ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,9 +236,9 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316" +checksum = "5f98c37cf288e302c16ef6c8472aad1e034c6c84ce5ea7b8101c98eb4a802fee" dependencies = [ "async-lock 3.3.0", "async-task", @@ -666,9 +666,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" dependencies = [ "jobserver", "libc", @@ -854,7 +854,7 @@ dependencies = [ [[package]] name = "const-field-offset" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "const-field-offset-macro", "field-offset", @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "const-field-offset-macro" version = "0.1.5" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "proc-macro2", "quote", @@ -1168,9 +1168,9 @@ dependencies = [ [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "drm" @@ -1877,9 +1877,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -1931,7 +1931,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "i-slint-backend-linuxkms" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "calloop", "drm", @@ -1951,7 +1951,7 @@ dependencies = [ [[package]] name = "i-slint-backend-qt" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "const-field-offset", "i-slint-common", @@ -1963,7 +1963,7 @@ dependencies = [ [[package]] name = "i-slint-backend-selector" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "cfg-if", "i-slint-backend-linuxkms", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "i-slint-backend-winit" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "bytemuck", "cfg-if", @@ -2009,7 +2009,7 @@ dependencies = [ [[package]] name = "i-slint-common" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "cfg-if", "derive_more", @@ -2020,7 +2020,7 @@ dependencies = [ [[package]] name = "i-slint-compiler" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "by_address", "codemap", @@ -2049,7 +2049,7 @@ dependencies = [ [[package]] name = "i-slint-core" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "auto_enums", "bytemuck", @@ -2094,7 +2094,7 @@ dependencies = [ [[package]] name = "i-slint-core-macros" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "quote", "syn 2.0.58", @@ -2103,7 +2103,7 @@ dependencies = [ [[package]] name = "i-slint-renderer-femtovg" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "cfg-if", "const-field-offset", @@ -2134,7 +2134,7 @@ dependencies = [ [[package]] name = "i-slint-renderer-skia" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "bytemuck", "cfg-if", @@ -3651,9 +3651,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "rustybuzz" @@ -3901,7 +3901,7 @@ dependencies = [ [[package]] name = "slint" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "const-field-offset", "i-slint-backend-selector", @@ -3917,7 +3917,7 @@ dependencies = [ [[package]] name = "slint-build" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "i-slint-compiler", "spin_on", @@ -3928,7 +3928,7 @@ dependencies = [ [[package]] name = "slint-macros" version = "1.6.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "i-slint-compiler", "proc-macro2", @@ -4703,7 +4703,7 @@ dependencies = [ [[package]] name = "vtable" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "const-field-offset", "portable-atomic", @@ -4714,7 +4714,7 @@ dependencies = [ [[package]] name = "vtable-macro" version = "0.2.0" -source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9" +source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223" dependencies = [ "proc-macro2", "quote", @@ -4993,9 +4993,9 @@ dependencies = [ [[package]] name = "winapi-wsapoll" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" +checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28" dependencies = [ "winapi", ] diff --git a/asusctl/src/aura_cli.rs b/asusctl/src/aura_cli.rs index 28cc3b89..9ca64202 100644 --- a/asusctl/src/aura_cli.rs +++ b/asusctl/src/aura_cli.rs @@ -10,10 +10,10 @@ pub struct LedPowerCommand1 { pub help: bool, #[options(meta = "", help = "Control if LEDs enabled while awake ")] pub awake: Option, - #[options(meta = "", help = "Use with awake option ")] - pub keyboard: Option, - #[options(meta = "", help = "Use with awake option ")] - pub lightbar: Option, + #[options(help = "Use with awake option, if excluded defaults to false")] + pub keyboard: bool, + #[options(help = "Use with awake option, if excluded defaults to false")] + pub lightbar: bool, #[options(meta = "", help = "Control boot animations ")] pub boot: Option, #[options(meta = "", help = "Control suspend animations ")] diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 3d74809d..e8ad6bce 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -12,8 +12,9 @@ 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::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower}; -use rog_aura::usb::{AuraDevice, AuraPowerDev}; +use rog_aura::aura_detection::PowerZones; +use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; +use rog_aura::usb::AuraDevice; use rog_aura::{self, AuraEffect}; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; @@ -572,8 +573,8 @@ fn handle_led_power1( if power.awake.is_none() && power.sleep.is_none() && power.boot.is_none() - && power.keyboard.is_none() - && power.lightbar.is_none() + && !power.keyboard + && !power.lightbar { if !power.help { println!("Missing arg or command\n"); @@ -582,15 +583,10 @@ fn handle_led_power1( return Ok(()); } - if dev_type.is_old_style() { + if dev_type.is_old_style() || dev_type.is_tuf_style() { handle_led_power_1_do_1866(aura, power)?; return Ok(()); } - - if dev_type.is_tuf_style() { - handle_led_power_1_do_tuf(aura, power)?; - return Ok(()); - } } println!("These options are for keyboards of product ID 0x1866 or TUF only"); @@ -601,62 +597,24 @@ fn handle_led_power_1_do_1866( aura: &AuraProxyBlocking, power: &LedPowerCommand1, ) -> Result<(), Box> { - let mut enabled: Vec = Vec::new(); - let mut disabled: Vec = Vec::new(); - - let mut check = |e: Option, a: LaptopOldAuraPower| { - if let Some(arg) = e { - if arg { - enabled.push(a); - } else { - disabled.push(a); - } - } + let zone = if power.keyboard && power.lightbar { + PowerZones::KeyboardAndLightbar + } else if power.lightbar { + PowerZones::Lightbar + } else { + PowerZones::Keyboard + }; + let states = LaptopAuraPower { + states: vec![AuraPowerState { + zone, + boot: power.boot.unwrap_or_default(), + awake: power.awake.unwrap_or_default(), + sleep: power.sleep.unwrap_or_default(), + shutdown: false, + }], }; - check(power.awake, LaptopOldAuraPower::Awake); - check(power.boot, LaptopOldAuraPower::Boot); - check(power.sleep, LaptopOldAuraPower::Sleep); - check(power.keyboard, LaptopOldAuraPower::Keyboard); - check(power.lightbar, LaptopOldAuraPower::Lightbar); - - let data = AuraPowerDev { - old_rog: enabled, - ..Default::default() - }; - - aura.set_led_power(data.clone())?; // TODO: verify this - - Ok(()) -} - -fn handle_led_power_1_do_tuf( - aura: &AuraProxyBlocking, - power: &LedPowerCommand1, -) -> Result<(), Box> { - let mut enabled: Vec = Vec::new(); - let mut disabled: Vec = Vec::new(); - - let mut check = |e: Option, a: LaptopTufAuraPower| { - if let Some(arg) = e { - if arg { - enabled.push(a); - } else { - disabled.push(a); - } - } - }; - - check(power.awake, LaptopTufAuraPower::Awake); - check(power.boot, LaptopTufAuraPower::Boot); - check(power.sleep, LaptopTufAuraPower::Sleep); - check(power.keyboard, LaptopTufAuraPower::Keyboard); - - let data = AuraPowerDev { - tuf: enabled, - ..Default::default() - }; - aura.set_led_power(data.clone())?; // TODO: verify this + aura.set_led_power(states)?; Ok(()) } @@ -696,25 +654,30 @@ fn handle_led_power2( return Ok(()); } - let set = |power: &mut AuraPowerState, set_to: &AuraPowerStates| { - power.boot = set_to.boot; - power.awake = set_to.awake; - power.sleep = set_to.sleep; - power.shutdown = set_to.shutdown; + let mut states = aura.led_power()?; + let mut set = |zone: PowerZones, set_to: &AuraPowerStates| { + for state in states.states.iter_mut() { + if state.zone == zone { + state.boot = set_to.boot; + state.awake = set_to.awake; + state.sleep = set_to.sleep; + state.shutdown = set_to.shutdown; + break; + } + } }; - let mut enabled = aura.led_power()?; if let Some(cmd) = &power.command { match cmd { - aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(&mut enabled.rog.keyboard, k), - aura_cli::SetAuraZoneEnabled::Logo(l) => set(&mut enabled.rog.logo, l), - aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(&mut enabled.rog.lightbar, l), - aura_cli::SetAuraZoneEnabled::Lid(l) => set(&mut enabled.rog.lid, l), - aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(&mut enabled.rog.rear_glow, r), + aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(PowerZones::Keyboard, k), + aura_cli::SetAuraZoneEnabled::Logo(l) => set(PowerZones::Logo, l), + aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l), + aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l), + aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r), } } - aura.set_led_power(enabled)?; + aura.set_led_power(states)?; } } diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index 6effc4a0..96a19e2d 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -1,112 +1,13 @@ -use std::collections::{BTreeMap, HashSet}; +use std::collections::BTreeMap; use config_traits::{StdConfig, StdConfigLoad}; use log::{debug, info}; use rog_aura::aura_detection::LaptopLedData; -use rog_aura::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower}; -use rog_aura::usb::{AuraDevice, AuraPowerDev}; +use rog_aura::keyboard::{LaptopAuraPower, LaptopAuraType}; +use rog_aura::usb::AuraDevice; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT}; use serde_derive::{Deserialize, Serialize}; -/// Enable/disable LED control in various states such as -/// when the device is awake, suspended, shutting down or -/// booting. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum AuraPowerConfig { - AuraDevTuf(HashSet), - AuraDevRog1(HashSet), - AuraDevRog2(LaptopAuraPower), -} - -impl Default for AuraPowerConfig { - fn default() -> Self { - Self::AuraDevTuf(HashSet::default()) - } -} - -impl AuraPowerConfig { - /// Invalid for TUF laptops - pub fn to_bytes(control: &Self) -> [u8; 4] { - match control { - AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0], - AuraPowerConfig::AuraDevRog1(c) => { - let c: Vec = c.iter().copied().collect(); - LaptopOldAuraPower::to_bytes(&c) - } - AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(), - } - } - - pub fn to_tuf_bool_array(control: &Self) -> Option<[bool; 5]> { - if let Self::AuraDevTuf(c) = control { - return Some([ - true, - c.contains(&LaptopTufAuraPower::Boot), - c.contains(&LaptopTufAuraPower::Awake), - c.contains(&LaptopTufAuraPower::Sleep), - c.contains(&LaptopTufAuraPower::Keyboard), - ]); - } - - if let Self::AuraDevRog1(c) = control { - return Some([ - true, - c.contains(&LaptopOldAuraPower::Boot), - c.contains(&LaptopOldAuraPower::Awake), - c.contains(&LaptopOldAuraPower::Sleep), - c.contains(&LaptopOldAuraPower::Keyboard), - ]); - } - - None - } - - pub fn set_tuf(&mut self, power: LaptopTufAuraPower, on: bool) { - if let Self::AuraDevTuf(p) = self { - if on { - p.insert(power); - } else { - p.remove(&power); - } - } - } - - pub fn set_0x1866(&mut self, power: LaptopOldAuraPower, on: bool) { - if let Self::AuraDevRog1(p) = self { - if on { - p.insert(power); - } else { - p.remove(&power); - } - } - } - - pub fn set_0x19b6(&mut self, power: LaptopAuraPower) { - if let Self::AuraDevRog2(p) = self { - *p = power; - } - } -} - -impl From<&AuraPowerConfig> for AuraPowerDev { - fn from(config: &AuraPowerConfig) -> Self { - match config { - AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev { - tuf: d.iter().copied().collect(), - ..Default::default() - }, - AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev { - old_rog: d.iter().copied().collect(), - ..Default::default() - }, - AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev { - rog: d.clone(), - ..Default::default() - }, - } - } -} - #[derive(Deserialize, Serialize, Default, Debug, Clone)] // #[serde(default)] pub struct AuraConfig { @@ -116,7 +17,7 @@ pub struct AuraConfig { pub builtins: BTreeMap, pub multizone: Option>>, pub multizone_on: bool, - pub enabled: AuraPowerConfig, + pub enabled: LaptopAuraPower, } impl AuraConfig { @@ -151,22 +52,11 @@ impl AuraConfig { pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self { // create a default config here let enabled = if prod_id.is_new_style() { - AuraPowerConfig::AuraDevRog2(LaptopAuraPower::new_all_on()) + LaptopAuraPower::new(LaptopAuraType::New, support_data) } else if prod_id.is_tuf_style() { - AuraPowerConfig::AuraDevTuf(HashSet::from([ - LaptopTufAuraPower::Awake, - LaptopTufAuraPower::Boot, - LaptopTufAuraPower::Sleep, - LaptopTufAuraPower::Keyboard, - ])) + LaptopAuraPower::new(LaptopAuraType::Tuf, support_data) } else { - AuraPowerConfig::AuraDevRog1(HashSet::from([ - LaptopOldAuraPower::Awake, - LaptopOldAuraPower::Boot, - LaptopOldAuraPower::Sleep, - LaptopOldAuraPower::Keyboard, - LaptopOldAuraPower::Lightbar, - ])) + LaptopAuraPower::new(LaptopAuraType::Old, 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 bf9fdfee..8acfa316 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -11,7 +11,7 @@ use rog_platform::hid_raw::HidRaw; use rog_platform::keyboard_led::KeyboardLed; use zbus::zvariant::OwnedObjectPath; -use super::config::{AuraConfig, AuraPowerConfig}; +use super::config::AuraConfig; use crate::ctrl_aura::manager::dbus_path_for_dev; use crate::error::RogError; @@ -191,12 +191,14 @@ impl CtrlKbdLed { /// leds/side leds LED active pub(super) fn set_power_states(&mut self) -> Result<(), RogError> { if let LEDNode::KbdLed(platform) = &mut self.led_node { - if let Some(pwr) = AuraPowerConfig::to_tuf_bool_array(&self.config.enabled) { - let buf = [1, pwr[1] as u8, pwr[2] as u8, pwr[3] as u8, pwr[4] as u8]; - platform.set_kbd_rgb_state(&buf)?; - } + // TODO: tuf bool array + // if let Some(pwr) = + // AuraPowerConfig::to_tuf_bool_array(&self.config.enabled) { + // let buf = [1, pwr[1] as u8, pwr[2] as u8, pwr[3] as u8, + // pwr[4] as u8]; platform.set_kbd_rgb_state(&buf)?; + // } } else if let LEDNode::Rog(_, hid_raw) = &self.led_node { - let bytes = AuraPowerConfig::to_bytes(&self.config.enabled); + let bytes = self.config.enabled.to_bytes(self.led_prod.into()); let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]]; hid_raw.write_bytes(&message)?; diff --git a/asusd/src/ctrl_aura/trait_impls.rs b/asusd/src/ctrl_aura/trait_impls.rs index 4338c2f6..9de9c522 100644 --- a/asusd/src/ctrl_aura/trait_impls.rs +++ b/asusd/src/ctrl_aura/trait_impls.rs @@ -4,8 +4,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::UsbPackets; -use rog_aura::usb::{AuraDevice, AuraPowerDev}; +use rog_aura::keyboard::{LaptopAuraPower, UsbPackets}; +use rog_aura::usb::AuraDevice; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::export::futures_util::lock::{Mutex, MutexGuard}; use zbus::export::futures_util::StreamExt; @@ -167,9 +167,9 @@ impl CtrlAuraZbus { // As property doesn't work for AuraPowerDev (complexity of serialization?) #[zbus(property)] - async fn led_power(&self) -> AuraPowerDev { + async fn led_power(&self) -> LaptopAuraPower { let ctrl = self.0.lock().await; - AuraPowerDev::from(&ctrl.config.enabled) + ctrl.config.enabled.clone() } /// Set a variety of states, input is array of enum. @@ -177,16 +177,16 @@ impl CtrlAuraZbus { /// /// For Modern ROG devices the "enabled" flag is ignored. #[zbus(property)] - async fn set_led_power(&mut self, options: AuraPowerDev) -> Result<(), ZbErr> { + async fn set_led_power(&mut self, options: LaptopAuraPower) -> Result<(), ZbErr> { let mut ctrl = self.0.lock().await; - // TODO: set the older devices - // for p in options.tuf { - // ctrl.config.enabled.set_tuf(p, enabled); - // } - // for p in options.old_rog { - // ctrl.config.enabled.set_0x1866(p, enabled); - // } - ctrl.config.enabled.set_0x19b6(options.rog); + for opt in options.states { + let zone = opt.zone; + for config in ctrl.config.enabled.states.iter_mut() { + if config.zone == zone { + *config = opt; + } + } + } ctrl.config.write(); Ok(ctrl.set_power_states().map_err(|e| { warn!("{}", e); diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index 75062d02..5f5c2081 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -31,7 +31,7 @@ pub struct LedSupportFile(Vec); derive(Type, Value, OwnedValue), zvariant(signature = "u") )] -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default, Copy, Clone)] pub enum PowerZones { /// The logo on some laptop lids #[default] @@ -44,6 +44,8 @@ pub enum PowerZones { 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)] diff --git a/rog-aura/src/keyboard/power.rs b/rog-aura/src/keyboard/power.rs index 131dac02..755c7416 100644 --- a/rog-aura/src/keyboard/power.rs +++ b/rog-aura/src/keyboard/power.rs @@ -8,15 +8,64 @@ use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::{OwnedValue, Type, Value}; -use crate::aura_detection::PowerZones; +use crate::aura_detection::{LaptopLedData, PowerZones}; +use crate::usb::AuraDevice; + +// Possible API: +// # Common parts: +// - boot +// - awake +// - sleep +// ## New only +// - shutdown +// +// ## Only only +// - keyboard +// - lightbar +// ## TUF only +// - keyboard +// +// # New has parts: +// - keyboard +// - lightbar +// - logo +// - lid +// - rear_glow +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum LaptopAuraType { + New = 0, + Old = 1, + Tuf = 2, +} + +impl From for LaptopAuraType { + fn from(value: AuraDevice) -> Self { + if value.is_old_style() { + Self::Old + } else if value.is_tuf_style() { + Self::Tuf + } else { + Self::New + } + } +} + +/// Meaning of this struct depends on the laptop generation. +/// - 2021+, the struct is a single zone with 4 states +/// - pre-2021, the struct is 1 or 2 zones and 3 states +/// - Tuf, the struct is 1 zone and 3 states #[typeshare] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct AuraPowerState { + pub zone: PowerZones, pub boot: bool, pub awake: bool, pub sleep: bool, + /// Ignored for pre-2021 and Tuf pub shutdown: bool, } @@ -24,17 +73,77 @@ impl Default for AuraPowerState { /// Defaults all to off fn default() -> Self { Self { - boot: false, - awake: false, - sleep: false, - shutdown: false, + zone: PowerZones::Keyboard, + boot: true, + awake: true, + sleep: true, + shutdown: true, } } } impl AuraPowerState { - pub fn to_byte(&self, zone: PowerZones) -> u32 { - match zone { + fn default_for(zone: PowerZones) -> Self { + Self { + zone, + boot: true, + awake: true, + sleep: true, + shutdown: true, + } + } + + fn tuf_to_bytes(&self) -> Vec { + todo!("0s and 1s for bool array") + } + + /// # Bits for older 0x1866 keyboard model + /// + /// Keybord and Lightbar require Awake, Boot and Sleep apply to both + /// Keybord and Lightbar regardless of if either are enabled (or Awake is + /// enabled) + /// + /// | Byte 1 | Byte 2 | Byte 3 | function | hex | + /// |------------|------------|------------|----------|----------| + /// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 | + /// | 0000, 1000 | 0000, 0000 | 0000, 0000 | Keyboard | 08,00,00 | + /// | 0000, 0100 | 0000, 0101 | 0000, 0000 | Lightbar | 04,05,00 | + /// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 | + /// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 | + /// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | | + fn old_to_bytes(&self) -> Vec { + let mut a: u32 = 0; + if self.awake { + a |= OldAuraPower::Awake as u32; + } + if self.boot { + a |= OldAuraPower::Boot as u32; + } + if self.sleep { + a |= OldAuraPower::Sleep as u32; + } + if matches!( + self.zone, + PowerZones::Keyboard | PowerZones::KeyboardAndLightbar + ) { + a |= OldAuraPower::Keyboard as u32; + } + if matches!( + self.zone, + PowerZones::Lightbar | PowerZones::KeyboardAndLightbar + ) { + a |= OldAuraPower::Lightbar as u32; + } + vec![ + ((a & 0xff0000) >> 16) as u8, + ((a & 0xff00) >> 8) as u8, + (a & 0xff) as u8, + 0x00, + ] + } + + fn new_to_byte(&self) -> u32 { + match self.zone { PowerZones::Logo => { self.boot as u32 | (self.awake as u32) << 2 @@ -65,126 +174,100 @@ impl AuraPowerState { | (self.sleep as u32) << (23 + 3) | (self.shutdown as u32) << (23 + 4) } + PowerZones::KeyboardAndLightbar => 0, } } } -/// Track and control the Aura keyboard power state -/// -/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models -/// -/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label | -/// |--------|---------|---------|---------|----------| -/// |00000001| 00000000| 00000000| 00000000|boot_logo_| -/// |00000010| 00000000| 00000000| 00000000|boot_keyb_| -/// |00000100| 00000000| 00000000| 00000000|awake_logo| -/// |00001000| 00000000| 00000000| 00000000|awake_keyb| -/// |00010000| 00000000| 00000000| 00000000|sleep_logo| -/// |00100000| 00000000| 00000000| 00000000|sleep_keyb| -/// |01000000| 00000000| 00000000| 00000000|shut_logo_| -/// |10000000| 00000000| 00000000| 00000000|shut_keyb_| -/// |00000000| 00000010| 00000000| 00000000|boot_bar__| -/// |00000000| 00000100| 00000000| 00000000|awake_bar_| -/// |00000000| 00001000| 00000000| 00000000|sleep_bar_| -/// |00000000| 00010000| 00000000| 00000000|shut_bar__| -/// |00000000| 00000000| 00000001| 00000000|boot_lid__| -/// |00000000| 00000000| 00000010| 00000000|awkae_lid_| -/// |00000000| 00000000| 00000100| 00000000|sleep_lid_| -/// |00000000| 00000000| 00001000| 00000000|shut_lid__| -/// |00000000| 00000000| 00000000| 00000001|boot_rear_| -/// |00000000| 00000000| 00000000| 00000010|awake_rear| -/// |00000000| 00000000| 00000000| 00000100|sleep_rear| -/// |00000000| 00000000| 00000000| 00001000|shut_rear_| #[typeshare] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct LaptopAuraPower { - pub keyboard: AuraPowerState, - pub logo: AuraPowerState, - pub lightbar: AuraPowerState, - pub lid: AuraPowerState, - pub rear_glow: AuraPowerState, + pub states: Vec, } impl LaptopAuraPower { - pub fn new_all_on() -> Self { - Self { - keyboard: AuraPowerState { - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - logo: AuraPowerState { - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - lightbar: AuraPowerState { - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - lid: AuraPowerState { - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - rear_glow: AuraPowerState { - boot: true, - awake: true, - sleep: true, - shutdown: true, - }, - } - } - - pub fn to_bytes(&self) -> [u8; 4] { + /// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models + /// + /// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label | + /// |--------|---------|---------|---------|----------| + /// |00000001| 00000000| 00000000| 00000000|boot_logo_| + /// |00000010| 00000000| 00000000| 00000000|boot_keyb_| + /// |00000100| 00000000| 00000000| 00000000|awake_logo| + /// |00001000| 00000000| 00000000| 00000000|awake_keyb| + /// |00010000| 00000000| 00000000| 00000000|sleep_logo| + /// |00100000| 00000000| 00000000| 00000000|sleep_keyb| + /// |01000000| 00000000| 00000000| 00000000|shut_logo_| + /// |10000000| 00000000| 00000000| 00000000|shut_keyb_| + /// |00000000| 00000010| 00000000| 00000000|boot_bar__| + /// |00000000| 00000100| 00000000| 00000000|awake_bar_| + /// |00000000| 00001000| 00000000| 00000000|sleep_bar_| + /// |00000000| 00010000| 00000000| 00000000|shut_bar__| + /// |00000000| 00000000| 00000001| 00000000|boot_lid__| + /// |00000000| 00000000| 00000010| 00000000|awkae_lid_| + /// |00000000| 00000000| 00000100| 00000000|sleep_lid_| + /// |00000000| 00000000| 00001000| 00000000|shut_lid__| + /// |00000000| 00000000| 00000000| 00000001|boot_rear_| + /// |00000000| 00000000| 00000000| 00000010|awake_rear| + /// |00000000| 00000000| 00000000| 00000100|sleep_rear| + /// |00000000| 00000000| 00000000| 00001000|shut_rear_| + fn new_to_bytes(&self) -> Vec { let mut a: u32 = 0; - a |= self.keyboard.to_byte(PowerZones::Keyboard); - a |= self.logo.to_byte(PowerZones::Logo); - a |= self.lid.to_byte(PowerZones::Lid); - a |= self.lightbar.to_byte(PowerZones::Lightbar); - a |= self.rear_glow.to_byte(PowerZones::RearGlow); - [ + for state in self.states.iter() { + a |= state.new_to_byte(); + } + vec![ (a & 0xff) as u8, ((a & 0xff00) >> 8) as u8, ((a & 0xff0000) >> 16) as u8, ((a & 0xff000000) >> 24) as u8, ] } -} -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "u") -)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[repr(u32)] -pub enum LaptopTufAuraPower { - Boot = 0, - Awake = 1, - Sleep = 2, - Keyboard = 3, -} + // TODO: use support data to setup correct zones + pub fn new(aura_type: LaptopAuraType, _support_data: &LaptopLedData) -> Self { + match aura_type { + LaptopAuraType::New => { + let mut states = Vec::new(); + for zone in [ + PowerZones::Keyboard, + PowerZones::Lid, + PowerZones::Lightbar, + PowerZones::Logo, + PowerZones::RearGlow, + ] { + states.push(AuraPowerState::default_for(zone)) + } + Self { states } + } + LaptopAuraType::Old => Self { + states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)], + }, + LaptopAuraType::Tuf => Self { + states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], + }, + } + } -impl LaptopTufAuraPower { - pub const fn dev_id() -> &'static str { - "tuf" + pub fn to_bytes(&self, aura_type: LaptopAuraType) -> Vec { + match aura_type { + LaptopAuraType::New => self.new_to_bytes(), + LaptopAuraType::Old => self + .states + .first() + .cloned() + .unwrap_or_default() + .old_to_bytes(), + LaptopAuraType::Tuf => self + .states + .first() + .cloned() + .unwrap_or_default() + .tuf_to_bytes(), + } } } -/// # Bits for older 0x1866 keyboard model -/// -/// Keybord and Lightbar require Awake, Boot and Sleep apply to both -/// Keybord and Lightbar regardless of if either are enabled (or Awake is -/// enabled) -/// /// | Byte 1 | Byte 2 | Byte 3 | function | hex | /// |------------|------------|------------|----------|----------| /// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 | @@ -193,98 +276,97 @@ impl LaptopTufAuraPower { /// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 | /// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 | /// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | | -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "u") -)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[repr(u32)] -pub enum LaptopOldAuraPower { +enum OldAuraPower { Awake = 0x000002, - Keyboard = 0x080000, - Lightbar = 0x040500, Boot = 0xc31209, Sleep = 0x300804, + Keyboard = 0x080000, + Lightbar = 0x040500, } -impl From for u32 { - fn from(a: LaptopOldAuraPower) -> Self { - a as u32 - } -} - -impl LaptopOldAuraPower { - pub fn to_bytes(control: &[Self]) -> [u8; 4] { - let mut a: u32 = 0; - for n in control { - a |= *n as u32; - } - [ - ((a & 0xff0000) >> 16) as u8, - ((a & 0xff00) >> 8) as u8, - (a & 0xff) as u8, - 0x00, - ] - } - - pub const fn dev_id() -> &'static str { - "0x1866" - } -} - -impl BitOr for LaptopOldAuraPower { +impl BitOr for OldAuraPower { type Output = u32; - fn bitor(self, rhs: LaptopOldAuraPower) -> Self::Output { + fn bitor(self, rhs: OldAuraPower) -> Self::Output { self as u32 | rhs as u32 } } -impl BitAnd for LaptopOldAuraPower { +impl BitAnd for OldAuraPower { type Output = u32; - fn bitand(self, rhs: LaptopOldAuraPower) -> Self::Output { + fn bitand(self, rhs: OldAuraPower) -> Self::Output { self as u32 & rhs as u32 } } +impl From for u32 { + fn from(a: OldAuraPower) -> Self { + a as u32 + } +} + #[cfg(test)] mod test { - use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopOldAuraPower}; + use crate::aura_detection::{LaptopLedData, PowerZones}; + use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopAuraType}; #[test] fn check_0x1866_control_bytes() { - let bytes = [LaptopOldAuraPower::Keyboard, LaptopOldAuraPower::Awake]; - let bytes = LaptopOldAuraPower::to_bytes(&bytes); + let state = AuraPowerState { + zone: PowerZones::Keyboard, + awake: true, + boot: false, + sleep: false, + shutdown: false, + }; + let bytes = state.old_to_bytes(); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]); - let bytes = [LaptopOldAuraPower::Lightbar, LaptopOldAuraPower::Awake]; - let bytes = LaptopOldAuraPower::to_bytes(&bytes); + let state = AuraPowerState { + zone: PowerZones::Lightbar, + awake: true, + boot: false, + sleep: false, + shutdown: false, + }; + let bytes = state.old_to_bytes(); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]); - let bytes = [LaptopOldAuraPower::Sleep]; - let bytes = LaptopOldAuraPower::to_bytes(&bytes); + let bytes = AuraPowerState { + zone: PowerZones::Keyboard, + awake: false, + boot: false, + sleep: true, + shutdown: false, + }; + let bytes = bytes.old_to_bytes(); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]); - let bytes = [LaptopOldAuraPower::Boot]; - let bytes = LaptopOldAuraPower::to_bytes(&bytes); + let bytes = AuraPowerState { + zone: PowerZones::Keyboard, + awake: false, + boot: true, + sleep: false, + shutdown: false, + }; + let bytes = bytes.old_to_bytes(); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]); - let bytes = [ - LaptopOldAuraPower::Keyboard, - LaptopOldAuraPower::Lightbar, - LaptopOldAuraPower::Awake, - LaptopOldAuraPower::Sleep, - LaptopOldAuraPower::Boot, - ]; + let power = AuraPowerState { + zone: PowerZones::KeyboardAndLightbar, + awake: true, + boot: true, + sleep: true, + shutdown: false, + }; - let bytes = LaptopOldAuraPower::to_bytes(&bytes); + let bytes = power.old_to_bytes(); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]); } @@ -292,7 +374,7 @@ mod test { #[test] fn check_0x19b6_control_bytes_binary_rep() { fn to_binary_string(power: &LaptopAuraPower) -> String { - let bytes = power.to_bytes(); + let bytes = power.to_bytes(LaptopAuraType::New); format!( "{:08b}, {:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2], bytes[3] @@ -300,144 +382,144 @@ mod test { } let boot_logo_ = to_binary_string(&LaptopAuraPower { - logo: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Logo, boot: true, ..Default::default() - }, - ..Default::default() + }], }); let boot_keyb_ = to_binary_string(&LaptopAuraPower { - keyboard: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Keyboard, boot: true, ..Default::default() - }, - ..Default::default() + }], }); let sleep_logo = to_binary_string(&LaptopAuraPower { - logo: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Logo, sleep: true, ..Default::default() - }, - ..Default::default() + }], }); let sleep_keyb = to_binary_string(&LaptopAuraPower { - keyboard: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Keyboard, sleep: true, ..Default::default() - }, - ..Default::default() + }], }); let awake_logo = to_binary_string(&LaptopAuraPower { - logo: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Logo, awake: true, ..Default::default() - }, - ..Default::default() + }], }); let awake_keyb = to_binary_string(&LaptopAuraPower { - keyboard: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Keyboard, awake: true, ..Default::default() - }, - ..Default::default() + }], }); let shut_logo_ = to_binary_string(&LaptopAuraPower { - logo: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Logo, shutdown: true, ..Default::default() - }, - ..Default::default() + }], }); let shut_keyb_ = to_binary_string(&LaptopAuraPower { - keyboard: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Keyboard, shutdown: true, ..Default::default() - }, - ..Default::default() + }], }); let boot_bar__ = to_binary_string(&LaptopAuraPower { - lightbar: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lightbar, boot: true, ..Default::default() - }, - ..Default::default() + }], }); let awake_bar_ = to_binary_string(&LaptopAuraPower { - lightbar: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lightbar, awake: true, ..Default::default() - }, - ..Default::default() + }], }); let sleep_bar_ = to_binary_string(&LaptopAuraPower { - lightbar: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lightbar, sleep: true, ..Default::default() - }, - ..Default::default() + }], }); let shut_bar__ = to_binary_string(&LaptopAuraPower { - lightbar: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lightbar, shutdown: true, ..Default::default() - }, - ..Default::default() + }], }); let boot_lid__ = to_binary_string(&LaptopAuraPower { - lid: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lid, boot: true, ..Default::default() - }, - ..Default::default() + }], }); let awake_lid_ = to_binary_string(&LaptopAuraPower { - lid: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lid, awake: true, ..Default::default() - }, - ..Default::default() + }], }); let sleep_lid_ = to_binary_string(&LaptopAuraPower { - lid: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lid, sleep: true, ..Default::default() - }, - ..Default::default() + }], }); let shut_lid__ = to_binary_string(&LaptopAuraPower { - lid: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::Lid, shutdown: true, ..Default::default() - }, - ..Default::default() + }], }); let boot_rear_ = to_binary_string(&LaptopAuraPower { - rear_glow: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::RearGlow, boot: true, ..Default::default() - }, - ..Default::default() + }], }); let awake_rear = to_binary_string(&LaptopAuraPower { - rear_glow: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::RearGlow, awake: true, ..Default::default() - }, - ..Default::default() + }], }); let sleep_rear = to_binary_string(&LaptopAuraPower { - rear_glow: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::RearGlow, sleep: true, ..Default::default() - }, - ..Default::default() + }], }); let shut_rear_ = to_binary_string(&LaptopAuraPower { - rear_glow: AuraPowerState { + states: vec![AuraPowerState { + zone: PowerZones::RearGlow, shutdown: true, ..Default::default() - }, - ..Default::default() + }], }); assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); @@ -465,7 +547,7 @@ mod test { assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); // All on - let byte1 = LaptopAuraPower::new_all_on(); + let byte1 = LaptopAuraPower::new(LaptopAuraType::New, &LaptopLedData::default()); let out = to_binary_string(&byte1); assert_eq!(out, "11111111, 00011110, 00001111, 00001111"); } diff --git a/rog-aura/src/usb.rs b/rog-aura/src/usb.rs index d612ea05..b048ce75 100644 --- a/rog-aura/src/usb.rs +++ b/rog-aura/src/usb.rs @@ -5,8 +5,6 @@ use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::{OwnedValue, Type, Value}; -use crate::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower}; - // Only these two packets must be 17 bytes pub const LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; pub const LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; @@ -106,18 +104,3 @@ impl Debug for AuraDevice { } } } - -/// This struct is intended as a helper to pass args to generic dbus interface -#[typeshare] -#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Clone, Default, Debug, Serialize, Deserialize)] -pub struct AuraPowerDev { - /// TUF laptops use a similar style of control to the older ROG devices but - /// through WMI - pub tuf: Vec, - /// Pre-0x19b6 devices use a different smaller scheme to the newer ROG - /// devices - pub old_rog: Vec, - /// ASUS standardised control scheme from 2020 onwards - pub rog: LaptopAuraPower, -} diff --git a/rog-control-center/src/types/aura_types.rs b/rog-control-center/src/types/aura_types.rs index 085c4d54..6a409bc1 100644 --- a/rog-control-center/src/types/aura_types.rs +++ b/rog-control-center/src/types/aura_types.rs @@ -46,6 +46,7 @@ impl From for rog_aura::AuraEffect } } +use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower}; use rog_aura::usb::AuraPowerDev; use slint::{Model, ModelRc, RgbaColor}; @@ -102,11 +103,12 @@ use crate::slint_generatedMainWindow::PowerZones as SlintPowerZones; impl From for SlintPowerZones { fn from(value: rog_aura::aura_detection::PowerZones) -> Self { match value { - rog_aura::aura_detection::PowerZones::Logo => SlintPowerZones::Logo, - rog_aura::aura_detection::PowerZones::Keyboard => SlintPowerZones::Keyboard, - rog_aura::aura_detection::PowerZones::Lightbar => SlintPowerZones::Lightbar, - rog_aura::aura_detection::PowerZones::Lid => SlintPowerZones::Lid, - rog_aura::aura_detection::PowerZones::RearGlow => SlintPowerZones::RearGlow, + PowerZones::Logo => SlintPowerZones::Logo, + PowerZones::Keyboard => SlintPowerZones::Keyboard, + PowerZones::Lightbar => SlintPowerZones::Lightbar, + PowerZones::Lid => SlintPowerZones::Lid, + PowerZones::RearGlow => SlintPowerZones::RearGlow, + PowerZones::KeyboardAndLightbar => todo!(), } } } diff --git a/rog-control-center/src/ui/setup_aura.rs b/rog-control-center/src/ui/setup_aura.rs index 6a857853..8489f598 100644 --- a/rog-control-center/src/ui/setup_aura.rs +++ b/rog-control-center/src/ui/setup_aura.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, Mutex}; -use rog_aura::usb::AuraPowerDev; +use rog_aura::keyboard::LaptopAuraPower; use rog_dbus::zbus_aura::AuraProxy; use slint::{ComponentHandle, Model, RgbaColor, SharedString}; @@ -166,7 +166,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc>) { .on_set_led_power(move |power| { let handle_copy = handle_copy.clone(); let proxy_copy = aura.clone(); - let power: AuraPowerDev = power.into(); + let power: LaptopAuraPower = power.into(); tokio::spawn(async move { show_toast( "Anime builtin animations changed".into(), diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 4fd1796b..852d111f 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-05 08:20+0000\n" +"POT-Creation-Date: 2024-04-08 09:19+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-control-center/ui/widgets/colour_picker.slint b/rog-control-center/ui/widgets/colour_picker.slint index eb7a398d..6fd5d7ec 100644 --- a/rog-control-center/ui/widgets/colour_picker.slint +++ b/rog-control-center/ui/widgets/colour_picker.slint @@ -77,12 +77,12 @@ export component ColourSlider inherits VerticalLayout { callback external_colour_change(); external_colour_change => { - if (root.final_colour.hue() < 0) { - c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue() + 360) / 360); + if (root.final_colour.hue < 0) { + c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue + 360) / 360); } else { - c1.value = (root.base_colours.length - 1) * (root.final_colour.hue() / 360); + c1.value = (root.base_colours.length - 1) * (root.final_colour.hue / 360); } - c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.brightness()); + c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.value); root.set_base_colour(); } Rectangle { diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index 20760857..92497728 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -23,8 +23,8 @@ use std::collections::BTreeMap; use rog_aura::aura_detection::PowerZones; -use rog_aura::keyboard::UsbPackets; -use rog_aura::usb::{AuraDevice, AuraPowerDev}; +use rog_aura::keyboard::{LaptopAuraPower, UsbPackets}; +use rog_aura::usb::AuraDevice; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::blocking::Connection; use zbus::{proxy, Result}; @@ -67,9 +67,9 @@ trait Aura { /// LedPower property #[zbus(property)] - fn led_power(&self) -> zbus::Result; + fn led_power(&self) -> zbus::Result; #[zbus(property)] - fn set_led_power(&self, value: AuraPowerDev) -> zbus::Result<()>; + fn set_led_power(&self, value: LaptopAuraPower) -> zbus::Result<()>; /// SupportedBrightness property #[zbus(property)] From 4f70055f854b237d3ed3e7db2631777553dea431 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 9 Apr 2024 14:33:24 +1200 Subject: [PATCH 11/12] Complete building --- Cargo.toml | 2 +- asusctl/src/main.rs | 19 +- asusd/src/ctrl_aura/config.rs | 44 +- asusd/src/ctrl_aura/controller.rs | 50 +- asusd/src/ctrl_aura/manager.rs | 8 +- asusd/src/ctrl_aura/trait_impls.rs | 7 +- rog-aura/src/aura_detection.rs | 11 - rog-aura/src/keyboard/power.rs | 96 ++-- rog-aura/src/lib.rs | 49 ++ rog-aura/src/usb.rs | 96 ---- rog-control-center/src/types/aura_types.rs | 200 +++----- rog-control-center/src/ui/setup_aura.rs | 4 +- .../translations/en/rog-control-center.po | 464 ++++++++---------- rog-control-center/ui/main_window.slint | 4 +- rog-control-center/ui/pages/aura.slint | 282 ++--------- rog-control-center/ui/types/aura_types.slint | 58 +-- rog-dbus/src/zbus_aura.rs | 5 +- .../examples/ally-gamepad-calibration.rs | 15 +- .../examples/ally-gamepad-mode-changes.rs | 15 +- .../examples/ally-set-qam-secondary.rs | 15 +- 20 files changed, 477 insertions(+), 967 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7d260ef6..b32d7d22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,8 +79,8 @@ panic = "abort" codegen-units = 1 [profile.dev] -debug = true opt-level = 1 +codegen-units = 16 [profile.bench] debug = false diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index e8ad6bce..e07ff71c 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -14,8 +14,7 @@ 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::usb::AuraDevice; -use rog_aura::{self, AuraEffect}; +use rog_aura::{self, AuraDeviceType, AuraEffect}; use rog_dbus::zbus_anime::AnimeProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; @@ -189,19 +188,19 @@ fn do_parsed( .first() .unwrap() .device_type() - .unwrap_or(AuraDevice::Unknown) + .unwrap_or(AuraDeviceType::Unknown) } else { - AuraDevice::Unknown + AuraDeviceType::Unknown }; let commands: Vec = cmdlist.lines().map(|s| s.to_owned()).collect(); for command in commands.iter().filter(|command| { - if !dev_type.is_old_style() - && !dev_type.is_tuf_style() + if !dev_type.is_old_laptop() + && !dev_type.is_tuf_laptop() && command.trim().starts_with("led-pow-1") { return false; } - if !dev_type.is_new_style() && command.trim().starts_with("led-pow-2") { + if !dev_type.is_new_laptop() && command.trim().starts_with("led-pow-2") { return false; } true @@ -566,7 +565,7 @@ fn handle_led_power1( ) -> Result<(), Box> { for aura in aura { let dev_type = aura.device_type()?; - if !dev_type.is_old_style() && !dev_type.is_tuf_style() { + if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() { println!("This option applies only to keyboards 2021+"); } @@ -583,7 +582,7 @@ fn handle_led_power1( return Ok(()); } - if dev_type.is_old_style() || dev_type.is_tuf_style() { + if dev_type.is_old_laptop() || dev_type.is_tuf_laptop() { handle_led_power_1_do_1866(aura, power)?; return Ok(()); } @@ -625,7 +624,7 @@ fn handle_led_power2( ) -> Result<(), Box> { for aura in aura { let dev_type = aura.device_type()?; - if !dev_type.is_new_style() { + if !dev_type.is_new_laptop() { println!("This option applies only to keyboards 2021+"); continue; } diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index 96a19e2d..4ad5138e 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -1,11 +1,12 @@ use std::collections::BTreeMap; use config_traits::{StdConfig, StdConfigLoad}; -use log::{debug, info}; +use log::{debug, info, warn}; use rog_aura::aura_detection::LaptopLedData; -use rog_aura::keyboard::{LaptopAuraPower, LaptopAuraType}; -use rog_aura::usb::AuraDevice; -use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT}; +use rog_aura::keyboard::LaptopAuraPower; +use rog_aura::{ + AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT, +}; use serde_derive::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Default, Debug, Clone)] @@ -20,14 +21,6 @@ pub struct AuraConfig { pub enabled: LaptopAuraPower, } -impl AuraConfig { - /// Detect the keyboard type and load from default DB if data available - pub fn new_with(prod_id: AuraDevice) -> Self { - info!("Setting up AuraConfig for {prod_id:?}"); - Self::from_default_support(prod_id, &LaptopLedData::get_data()) - } -} - impl StdConfig for AuraConfig { /// Detect the keyboard type and load from default DB if data available fn new() -> Self { @@ -49,17 +42,18 @@ impl StdConfig for AuraConfig { impl StdConfigLoad for AuraConfig {} impl AuraConfig { - pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self { + /// Detect the keyboard type and load from default DB if data available + pub fn new(prod_id: &str) -> Self { + info!("Setting up AuraConfig for {prod_id:?}"); // create a default config here - let enabled = if prod_id.is_new_style() { - LaptopAuraPower::new(LaptopAuraType::New, support_data) - } else if prod_id.is_tuf_style() { - LaptopAuraPower::new(LaptopAuraType::Tuf, support_data) - } else { - LaptopAuraPower::new(LaptopAuraType::Old, support_data) - }; + 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 enabled = LaptopAuraPower::new(device_type, &support_data); let mut config = AuraConfig { - config_name: format!("aura_{prod_id:?}.ron"), + config_name: format!("aura_{prod_id}.ron"), brightness: LedBrightness::Med, current_mode: AuraModeNum::Static, builtins: BTreeMap::new(), @@ -139,16 +133,13 @@ impl AuraConfig { #[cfg(test)] mod tests { - use rog_aura::aura_detection::LaptopLedData; - use rog_aura::usb::AuraDevice; use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Colour}; use super::AuraConfig; #[test] fn set_multizone_4key_config() { - let mut config = - AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); + let mut config = AuraConfig::new("19b6"); let effect = AuraEffect { colour1: Colour { @@ -238,8 +229,7 @@ mod tests { #[test] fn set_multizone_multimode_config() { - let mut config = - AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); + let mut config = AuraConfig::new("19b6"); let effect = AuraEffect { zone: AuraZone::Key1, diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index 8acfa316..96b956d6 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -5,8 +5,10 @@ use inotify::Inotify; use log::{debug, info, warn}; use rog_aura::aura_detection::LaptopLedData; use rog_aura::keyboard::{LedUsbPackets, UsbPackets}; -use rog_aura::usb::{AuraDevice, LED_APPLY, LED_SET}; -use rog_aura::{AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN}; +use rog_aura::usb::{LED_APPLY, LED_SET}; +use rog_aura::{ + AuraDeviceType, AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN, +}; use rog_platform::hid_raw::HidRaw; use rog_platform::keyboard_led::KeyboardLed; use zbus::zvariant::OwnedObjectPath; @@ -50,7 +52,7 @@ impl LEDNode { /// Individual controller for one Aura device pub struct CtrlKbdLed { - pub led_prod: AuraDevice, + pub led_type: AuraDeviceType, pub led_node: LEDNode, pub supported_data: LaptopLedData, // TODO: is storing this really required? pub per_key_mode_active: bool, @@ -92,10 +94,11 @@ impl CtrlKbdLed { } // Device is something like 002, while its parent is the MCU // Think of it like the device is an endpoint of the USB device attached - let mut aura_dev = AuraDevice::Unknown; + let mut prod_id = String::new(); if let Some(usb_id) = usb_device.attribute_value("idProduct") { - aura_dev = AuraDevice::from(usb_id.to_str().unwrap()); - if aura_dev == AuraDevice::Unknown || found.contains(&aura_dev) { + prod_id = usb_id.to_string_lossy().to_string(); + let aura_dev = AuraDeviceType::from(prod_id.as_str()); + if aura_dev == AuraDeviceType::Unknown || found.contains(&aura_dev) { log::debug!("Unknown or invalid device: {usb_id:?}, skipping"); continue; } @@ -112,7 +115,7 @@ impl CtrlKbdLed { 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(aura_dev, data); + dev.config = Self::init_config(&prod_id, data); devices.push(dev); } } @@ -130,8 +133,8 @@ impl CtrlKbdLed { data: &LaptopLedData, ) -> Result { let rgb_led = KeyboardLed::new()?; - let prod_id = AuraDevice::from(device.prod_id()); - if prod_id == AuraDevice::Unknown { + let prod_id = AuraDeviceType::from(device.prod_id()); + if prod_id == AuraDeviceType::Unknown { log::error!("{} is AuraDevice::Unknown", device.prod_id()); return Err(RogError::NoAuraNode); } @@ -140,7 +143,7 @@ impl CtrlKbdLed { // let config = Self::init_config(prod_id, data); let ctrl = CtrlKbdLed { - led_prod: prod_id, + led_type: prod_id, led_node: LEDNode::Rog(rgb_led, device), supported_data: data.clone(), per_key_mode_active: false, @@ -150,9 +153,9 @@ impl CtrlKbdLed { Ok(ctrl) } - pub fn init_config(prod_id: AuraDevice, supported_basic_modes: &LaptopLedData) -> AuraConfig { + pub fn init_config(prod_id: &str, supported_basic_modes: &LaptopLedData) -> AuraConfig { // New loads data from the DB also - let mut config_init = AuraConfig::new_with(prod_id); + let mut config_init = AuraConfig::new(prod_id); // config_init.set_filename(prod_id); let mut config_loaded = config_init.clone().load(); // update the initialised data with what we loaded from disk @@ -198,7 +201,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_prod.into()); + let bytes = self.config.enabled.to_bytes(self.led_type.into()); let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]]; hid_raw.write_bytes(&message)?; @@ -344,8 +347,7 @@ impl CtrlKbdLed { #[cfg(test)] mod tests { use rog_aura::aura_detection::{LaptopLedData, PowerZones}; - use rog_aura::usb::AuraDevice; - use rog_aura::{AuraModeNum, AuraZone}; + use rog_aura::{AuraDeviceType, AuraModeNum, AuraZone}; use rog_platform::hid_raw::HidRaw; use rog_platform::keyboard_led::KeyboardLed; use zbus::zvariant::OwnedObjectPath; @@ -358,7 +360,7 @@ mod tests { #[ignore = "Unable to run in CI as the HIDRAW device is required"] fn create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried - let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); + let config = AuraConfig::new("19b6"); let supported_basic_modes = LaptopLedData { board_name: String::new(), layout_name: "ga401".to_owned(), @@ -368,11 +370,8 @@ mod tests { power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], }; let mut controller = CtrlKbdLed { - led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog( - KeyboardLed::default(), - HidRaw::new(AuraDevice::X19b6.into()).unwrap(), - ), + led_type: AuraDeviceType::LaptopPost2021, + led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("19b6").unwrap()), supported_data: supported_basic_modes, per_key_mode_active: false, config, @@ -401,7 +400,7 @@ mod tests { // TODO: use sim device fn next_mode_create_multizone_if_no_config() { // Checking to ensure set_mode errors when unsupported modes are tried - let config = AuraConfig::from_default_support(AuraDevice::X19b6, &LaptopLedData::default()); + let config = AuraConfig::new("19b6"); let supported_basic_modes = LaptopLedData { board_name: String::new(), layout_name: "ga401".to_owned(), @@ -411,11 +410,8 @@ mod tests { power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow], }; let mut controller = CtrlKbdLed { - led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog( - KeyboardLed::default(), - HidRaw::new(AuraDevice::X19b6.into()).unwrap(), - ), + led_type: AuraDeviceType::LaptopPost2021, + led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("19b6").unwrap()), supported_data: supported_basic_modes, per_key_mode_active: false, config, diff --git a/asusd/src/ctrl_aura/manager.rs b/asusd/src/ctrl_aura/manager.rs index feeea021..6b9b0840 100644 --- a/asusd/src/ctrl_aura/manager.rs +++ b/asusd/src/ctrl_aura/manager.rs @@ -9,7 +9,7 @@ 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::usb::AuraDevice; +use rog_aura::AuraDeviceType; use rog_platform::hid_raw::HidRaw; use tokio::task::spawn_blocking; use udev::{Device, MonitorBuilder}; @@ -86,8 +86,8 @@ impl AuraManager { continue; }; - let aura_device = AuraDevice::from(&*id_product); - if aura_device == AuraDevice::Unknown { + let aura_device = AuraDeviceType::from(&*id_product); + if aura_device == AuraDeviceType::Unknown { warn!("idProduct:{id_product:?} is unknown, not using"); continue; } @@ -135,7 +135,7 @@ impl AuraManager { if let Ok(mut ctrl) = CtrlKbdLed::from_hidraw(raw, path.clone(), &data) { - ctrl.config = CtrlKbdLed::init_config(aura_device, &data); + ctrl.config = CtrlKbdLed::init_config(&id_product, &data); 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 9de9c522..30b7535f 100644 --- a/asusd/src/ctrl_aura/trait_impls.rs +++ b/asusd/src/ctrl_aura/trait_impls.rs @@ -5,8 +5,7 @@ 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::usb::AuraDevice; -use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; +use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::export::futures_util::lock::{Mutex, MutexGuard}; use zbus::export::futures_util::StreamExt; use zbus::fdo::Error as ZbErr; @@ -43,9 +42,9 @@ impl CtrlAuraZbus { impl CtrlAuraZbus { /// Return the device type for this Aura keyboard #[zbus(property)] - async fn device_type(&self) -> AuraDevice { + async fn device_type(&self) -> AuraDeviceType { let ctrl = self.0.lock().await; - ctrl.led_prod + ctrl.led_type } /// Return the current LED brightness diff --git a/rog-aura/src/aura_detection.rs b/rog-aura/src/aura_detection.rs index 5f5c2081..d37fc672 100644 --- a/rog-aura/src/aura_detection.rs +++ b/rog-aura/src/aura_detection.rs @@ -5,21 +5,10 @@ use typeshare::typeshare; use zbus::zvariant::{OwnedValue, Type, Value}; use crate::keyboard::AdvancedAuraType; -use crate::usb::AuraDevice; use crate::{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; 8] = [ - AuraDevice::Tuf, - AuraDevice::X1854, - AuraDevice::X1869, - AuraDevice::X1866, - AuraDevice::X18c6, - AuraDevice::X19b6, - AuraDevice::X1a30, - AuraDevice::X1abe, -]; #[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)] pub struct LedSupportFile(Vec); diff --git a/rog-aura/src/keyboard/power.rs b/rog-aura/src/keyboard/power.rs index 755c7416..f1f48d76 100644 --- a/rog-aura/src/keyboard/power.rs +++ b/rog-aura/src/keyboard/power.rs @@ -3,55 +3,14 @@ use std::fmt::Debug; use std::ops::{BitAnd, BitOr}; +use log::warn; use serde::{Deserialize, Serialize}; use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::{OwnedValue, Type, Value}; use crate::aura_detection::{LaptopLedData, PowerZones}; -use crate::usb::AuraDevice; - -// Possible API: -// # Common parts: -// - boot -// - awake -// - sleep -// ## New only -// - shutdown -// -// ## Only only -// - keyboard -// - lightbar -// ## TUF only -// - keyboard -// -// # New has parts: -// - keyboard -// - lightbar -// - logo -// - lid -// - rear_glow - -#[typeshare] -#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub enum LaptopAuraType { - New = 0, - Old = 1, - Tuf = 2, -} - -impl From for LaptopAuraType { - fn from(value: AuraDevice) -> Self { - if value.is_old_style() { - Self::Old - } else if value.is_tuf_style() { - Self::Tuf - } else { - Self::New - } - } -} +use crate::AuraDeviceType; /// Meaning of this struct depends on the laptop generation. /// - 2021+, the struct is a single zone with 4 states @@ -225,45 +184,53 @@ impl LaptopAuraPower { } // TODO: use support data to setup correct zones - pub fn new(aura_type: LaptopAuraType, _support_data: &LaptopLedData) -> Self { + pub fn new(aura_type: AuraDeviceType, support_data: &LaptopLedData) -> Self { match aura_type { - LaptopAuraType::New => { + AuraDeviceType::Unknown | AuraDeviceType::LaptopPost2021 => { let mut states = Vec::new(); - for zone in [ - PowerZones::Keyboard, - PowerZones::Lid, - PowerZones::Lightbar, - PowerZones::Logo, - PowerZones::RearGlow, - ] { - states.push(AuraPowerState::default_for(zone)) + for zone in support_data.power_zones.iter() { + states.push(AuraPowerState::default_for(*zone)) } Self { states } } - LaptopAuraType::Old => Self { - states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)], - }, - LaptopAuraType::Tuf => Self { + AuraDeviceType::LaptopPre2021 => { + if support_data.power_zones.contains(&PowerZones::Lightbar) { + Self { + states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)], + } + } else { + Self { + states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], + } + } + } + AuraDeviceType::LaptopTuf => Self { states: vec![AuraPowerState::default_for(PowerZones::Keyboard)], }, + AuraDeviceType::ScsiExtDisk => todo!(), } } - pub fn to_bytes(&self, aura_type: LaptopAuraType) -> Vec { + pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec { match aura_type { - LaptopAuraType::New => self.new_to_bytes(), - LaptopAuraType::Old => self + AuraDeviceType::LaptopPost2021 => self.new_to_bytes(), + AuraDeviceType::LaptopPre2021 => self .states .first() .cloned() .unwrap_or_default() .old_to_bytes(), - LaptopAuraType::Tuf => self + AuraDeviceType::LaptopTuf => self .states .first() .cloned() .unwrap_or_default() .tuf_to_bytes(), + AuraDeviceType::Unknown => { + warn!("Trying to create bytes for an unknown device"); + self.new_to_bytes() + } + AuraDeviceType::ScsiExtDisk => todo!(), } } } @@ -310,7 +277,8 @@ impl From for u32 { #[cfg(test)] mod test { use crate::aura_detection::{LaptopLedData, PowerZones}; - use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopAuraType}; + use crate::keyboard::{AuraPowerState, LaptopAuraPower}; + use crate::AuraDeviceType; #[test] fn check_0x1866_control_bytes() { @@ -374,7 +342,7 @@ mod test { #[test] fn check_0x19b6_control_bytes_binary_rep() { fn to_binary_string(power: &LaptopAuraPower) -> String { - let bytes = power.to_bytes(LaptopAuraType::New); + let bytes = power.to_bytes(AuraDeviceType::LaptopPost2021); format!( "{:08b}, {:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2], bytes[3] @@ -547,7 +515,7 @@ mod test { assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); // All on - let byte1 = LaptopAuraPower::new(LaptopAuraType::New, &LaptopLedData::default()); + let byte1 = LaptopAuraPower::new(AuraDeviceType::LaptopPost2021, &LaptopLedData::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 3d34a0e9..7b75d618 100644 --- a/rog-aura/src/lib.rs +++ b/rog-aura/src/lib.rs @@ -3,6 +3,13 @@ // TODO: Traits for writing aura_sync // TODO: separate keyboard and laptop parts? +use std::fmt::Debug; + +use serde::{Deserialize, Serialize}; +use typeshare::typeshare; +#[cfg(feature = "dbus")] +use zbus::zvariant::{OwnedValue, Type, Value}; + /// A container of images/grids/gifs/pauses which can be iterated over to /// generate cool effects pub mod effects; @@ -56,3 +63,45 @@ pub const ORANGE: Colour = Colour { b: 0x00, }; pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE]; + +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum AuraDeviceType { + /// Most new laptops + #[default] + LaptopPost2021 = 0, + LaptopPre2021 = 1, + LaptopTuf = 2, + ScsiExtDisk = 3, + Unknown = 255, +} + +impl AuraDeviceType { + pub fn is_old_laptop(&self) -> bool { + *self == Self::LaptopPre2021 + } + + pub fn is_tuf_laptop(&self) -> bool { + *self == Self::LaptopTuf + } + + pub fn is_new_laptop(&self) -> bool { + *self == Self::LaptopPost2021 + } + + pub fn is_scsi(&self) -> bool { + *self == Self::ScsiExtDisk + } +} + +impl From<&str> for AuraDeviceType { + fn from(s: &str) -> Self { + match s.to_lowercase().trim_start_matches("0x") { + "tuf" => AuraDeviceType::LaptopTuf, + "1932" => AuraDeviceType::ScsiExtDisk, + "1866" | "18c6" | "1869" | "1854" => Self::LaptopPre2021, + _ => Self::LaptopPost2021, + } + } +} diff --git a/rog-aura/src/usb.rs b/rog-aura/src/usb.rs index b048ce75..b4582e31 100644 --- a/rog-aura/src/usb.rs +++ b/rog-aura/src/usb.rs @@ -1,10 +1,3 @@ -use std::fmt::Debug; - -use serde::{Deserialize, Serialize}; -use typeshare::typeshare; -#[cfg(feature = "dbus")] -use zbus::zvariant::{OwnedValue, Type, Value}; - // Only these two packets must be 17 bytes pub const LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; pub const LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; @@ -15,92 +8,3 @@ pub const fn aura_brightness_bytes(brightness: u8) -> [u8; 17] { 0x5a, 0xba, 0xc5, 0xc4, brightness, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } - -#[typeshare] -#[cfg_attr( - feature = "dbus", - derive(Type, Value, OwnedValue), - zvariant(signature = "s") -)] -#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] -pub enum AuraDevice { - Tuf = 0, - X1854 = 1, - X1869 = 2, - /// Pre-2020 laptops - X1866 = 3, - /// Z13 lightbar - X18c6 = 4, - /// Most modern laptops - #[default] - X19b6 = 5, - X1a30 = 6, - /// The ROG Ally - X1abe = 7, - Unknown = 99, -} - -impl AuraDevice { - pub fn is_tuf_style(&self) -> bool { - matches!(self, AuraDevice::Tuf) - } - - pub fn is_old_style(&self) -> bool { - matches!( - self, - AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 | AuraDevice::X1abe - ) - } - - pub fn is_new_style(&self) -> bool { - !self.is_old_style() && !self.is_tuf_style() - } -} - -impl From for &str { - fn from(a: AuraDevice) -> Self { - match a { - AuraDevice::Tuf => "tuf", - AuraDevice::X1854 => "1854", - AuraDevice::X1869 => "1869", - AuraDevice::X1866 => "1866", - AuraDevice::X18c6 => "18c6", - AuraDevice::X19b6 => "19b6", - AuraDevice::X1a30 => "1a30", - AuraDevice::X1abe => "1abe", - AuraDevice::Unknown => "unknown", - } - } -} - -impl From<&str> for AuraDevice { - fn from(s: &str) -> Self { - match s.to_lowercase().as_str() { - "tuf" => AuraDevice::Tuf, - "1866" | "0x1866" => AuraDevice::X1866, - "18c6" | "0x18c6" => AuraDevice::X18c6, - "1869" | "0x1869" => AuraDevice::X1869, - "1854" | "0x1854" => AuraDevice::X1854, - "19b6" | "0x19b6" => AuraDevice::X19b6, - "1a30" | "0x1a30" => AuraDevice::X1a30, - "1abe" | "0x1abe" => AuraDevice::X1abe, - _ => AuraDevice::Unknown, - } - } -} - -impl Debug for AuraDevice { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Tuf => write!(f, "Tuf"), - Self::X1854 => write!(f, "0x1854"), - Self::X1869 => write!(f, "0x1869"), - Self::X1866 => write!(f, "0x1866"), - 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/types/aura_types.rs b/rog-control-center/src/types/aura_types.rs index 6a409bc1..33a82384 100644 --- a/rog-control-center/src/types/aura_types.rs +++ b/rog-control-center/src/types/aura_types.rs @@ -1,3 +1,7 @@ +use crate::slint_generatedMainWindow::{ + AuraPowerState as SlintAuraPowerState, LaptopAuraPower as SlintLaptopAuraPower, +}; + impl From for crate::slint_generatedMainWindow::AuraEffect { fn from(m: rog_aura::AuraEffect) -> Self { Self { @@ -47,58 +51,9 @@ impl From for rog_aura::AuraEffect } use rog_aura::aura_detection::PowerZones; -use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower}; -use rog_aura::usb::AuraPowerDev; +use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; use slint::{Model, ModelRc, RgbaColor}; -use crate::slint_generatedMainWindow::AuraDevTuf as SlintAuraDevTuf; -impl From for SlintAuraDevTuf { - fn from(value: LaptopTufAuraPower) -> Self { - match value { - LaptopTufAuraPower::Boot => SlintAuraDevTuf::Boot, - LaptopTufAuraPower::Awake => SlintAuraDevTuf::Awake, - LaptopTufAuraPower::Sleep => SlintAuraDevTuf::Sleep, - LaptopTufAuraPower::Keyboard => SlintAuraDevTuf::Keyboard, - } - } -} - -impl From for LaptopTufAuraPower { - fn from(value: SlintAuraDevTuf) -> Self { - match value { - SlintAuraDevTuf::Boot => LaptopTufAuraPower::Boot, - SlintAuraDevTuf::Awake => LaptopTufAuraPower::Awake, - SlintAuraDevTuf::Sleep => LaptopTufAuraPower::Sleep, - SlintAuraDevTuf::Keyboard => LaptopTufAuraPower::Keyboard, - } - } -} - -use crate::slint_generatedMainWindow::AuraDevRog1 as SlintAuraDevRog1; -impl From for SlintAuraDevRog1 { - fn from(value: LaptopOldAuraPower) -> Self { - match value { - LaptopOldAuraPower::Awake => SlintAuraDevRog1::Awake, - LaptopOldAuraPower::Keyboard => SlintAuraDevRog1::Keyboard, - LaptopOldAuraPower::Lightbar => SlintAuraDevRog1::Lightbar, - LaptopOldAuraPower::Boot => SlintAuraDevRog1::Boot, - LaptopOldAuraPower::Sleep => SlintAuraDevRog1::Sleep, - } - } -} - -impl From for LaptopOldAuraPower { - fn from(value: SlintAuraDevRog1) -> Self { - match value { - SlintAuraDevRog1::Awake => LaptopOldAuraPower::Awake, - SlintAuraDevRog1::Keyboard => LaptopOldAuraPower::Keyboard, - SlintAuraDevRog1::Lightbar => LaptopOldAuraPower::Lightbar, - SlintAuraDevRog1::Boot => LaptopOldAuraPower::Boot, - SlintAuraDevRog1::Sleep => LaptopOldAuraPower::Sleep, - } - } -} - use crate::slint_generatedMainWindow::PowerZones as SlintPowerZones; impl From for SlintPowerZones { fn from(value: rog_aura::aura_detection::PowerZones) -> Self { @@ -121,117 +76,72 @@ impl From for rog_aura::aura_detection::PowerZones { 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 + } } } } -use crate::slint_generatedMainWindow::{ - AuraPower as SlintAuraPower, KbAuraPowerState as SlintKbAuraPowerState, -}; -impl From for SlintAuraPower { - fn from(value: rog_aura::keyboard::LaptopAuraPower) -> Self { +impl From for AuraPowerState { + fn from(value: SlintAuraPowerState) -> Self { Self { - keyboard: SlintKbAuraPowerState { - awake: value.keyboard.awake, - boot: value.keyboard.boot, - shutdown: value.keyboard.shutdown, - sleep: value.keyboard.sleep, - }, - lid: SlintKbAuraPowerState { - awake: value.lid.awake, - boot: value.lid.boot, - shutdown: value.lid.shutdown, - sleep: value.lid.sleep, - }, - lightbar: SlintKbAuraPowerState { - awake: value.lightbar.awake, - boot: value.lightbar.boot, - shutdown: value.lightbar.shutdown, - sleep: value.lightbar.sleep, - }, - logo: SlintKbAuraPowerState { - awake: value.logo.awake, - boot: value.logo.boot, - shutdown: value.logo.shutdown, - sleep: value.logo.sleep, - }, - rear_glow: SlintKbAuraPowerState { - awake: value.rear_glow.awake, - boot: value.rear_glow.boot, - shutdown: value.rear_glow.shutdown, - sleep: value.rear_glow.sleep, - }, + zone: value.zone.into(), + boot: value.boot.into(), + awake: value.awake.into(), + sleep: value.sleep.into(), + shutdown: value.shutdown.into(), } } } -impl From for rog_aura::keyboard::LaptopAuraPower { - fn from(value: SlintAuraPower) -> Self { - Self { - keyboard: AuraPowerState { - awake: value.keyboard.awake, - boot: value.keyboard.boot, - shutdown: value.keyboard.shutdown, - sleep: value.keyboard.sleep, - }, - lid: AuraPowerState { - awake: value.lid.awake, - boot: value.lid.boot, - shutdown: value.lid.shutdown, - sleep: value.lid.sleep, - }, - lightbar: AuraPowerState { - awake: value.lightbar.awake, - boot: value.lightbar.boot, - shutdown: value.lightbar.shutdown, - sleep: value.lightbar.sleep, - }, - logo: AuraPowerState { - awake: value.logo.awake, - boot: value.logo.boot, - shutdown: value.logo.shutdown, - sleep: value.logo.sleep, - }, - rear_glow: AuraPowerState { - awake: value.rear_glow.awake, - boot: value.rear_glow.boot, - shutdown: value.rear_glow.shutdown, - sleep: value.rear_glow.sleep, - }, +impl From for SlintAuraPowerState { + fn from(value: AuraPowerState) -> Self { + let zone = value.zone.into(); + SlintAuraPowerState { + boot: value.boot.into(), + awake: value.awake.into(), + sleep: value.sleep.into(), + shutdown: value.shutdown.into(), + zone, + zone_name_idx: zone as i32, } } } -use crate::slint_generatedMainWindow::AuraPowerDev as SlintAuraPowerDev; -impl From for SlintAuraPowerDev { - fn from(value: AuraPowerDev) -> Self { - let tuf: Vec = value - .tuf +impl From<&AuraPowerState> for SlintAuraPowerState { + fn from(value: &AuraPowerState) -> Self { + let zone = value.zone.into(); + SlintAuraPowerState { + boot: value.boot.into(), + awake: value.awake.into(), + sleep: value.sleep.into(), + shutdown: value.shutdown.into(), + zone, + zone_name_idx: zone as i32, + } + } +} + +impl From for rog_aura::keyboard::LaptopAuraPower { + fn from(value: SlintLaptopAuraPower) -> Self { + let mut states = Vec::new(); + for state in value.states.iter() { + states.push(state.into()); + } + Self { states } + } +} + +impl From for SlintLaptopAuraPower { + fn from(value: LaptopAuraPower) -> Self { + let converted: Vec = value + .states .iter() - .map(|n| SlintAuraDevTuf::from(*n)) - .collect(); - let old_rog: Vec = value - .old_rog - .iter() - .map(|n| SlintAuraDevRog1::from(*n)) + .map(|s| SlintAuraPowerState::from(s)) .collect(); Self { - tuf: ModelRc::from(tuf.as_slice()), - old_rog: ModelRc::from(old_rog.as_slice()), - rog: value.rog.into(), - } - } -} - -impl From for AuraPowerDev { - fn from(value: SlintAuraPowerDev) -> Self { - let tuf: Vec = value.tuf.iter().map(LaptopTufAuraPower::from).collect(); - let old_rog: Vec = - value.old_rog.iter().map(LaptopOldAuraPower::from).collect(); - Self { - tuf, - old_rog, - rog: value.rog.into(), + states: ModelRc::from(converted.as_slice()), } } } diff --git a/rog-control-center/src/ui/setup_aura.rs b/rog-control-center/src/ui/setup_aura.rs index 8489f598..21b170e1 100644 --- a/rog-control-center/src/ui/setup_aura.rs +++ b/rog-control-center/src/ui/setup_aura.rs @@ -169,8 +169,8 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc>) { let power: LaptopAuraPower = power.into(); tokio::spawn(async move { show_toast( - "Anime builtin animations changed".into(), - "Failed to set Anime builtin animations".into(), + "Aura power settings changed".into(), + "Failed to set Aura power settings".into(), handle_copy, proxy_copy.set_led_power(power).await, ); diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 852d111f..d556000f 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-08 09:19+0000\n" +"POT-Creation-Date: 2024-04-09 06:25+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -12,6 +12,46 @@ msgstr "" "Language: \n" "Plural-Forms: nplurals=1; plural=0;\n" +#: rog-control-center/ui/main_window.slint:50 +msgctxt "MainWindow" +msgid "ROG" +msgstr "" + +#: rog-control-center/ui/main_window.slint:52 +msgctxt "Menu1" +msgid "System Control" +msgstr "" + +#: rog-control-center/ui/main_window.slint:53 +msgctxt "Menu2" +msgid "Keyboard Aura" +msgstr "" + +#: rog-control-center/ui/main_window.slint:54 +msgctxt "Menu3" +msgid "AniMe Matrix" +msgstr "" + +#: rog-control-center/ui/main_window.slint:55 +msgctxt "Menu4" +msgid "Fan Curves" +msgstr "" + +#: rog-control-center/ui/main_window.slint:56 +msgctxt "Menu5" +msgid "App Settings" +msgstr "" + +#: rog-control-center/ui/main_window.slint:57 +msgctxt "Menu6" +msgid "About" +msgstr "" + +#: rog-control-center/ui/main_window.slint:69 +msgctxt "MainWindow" +msgid "Quit" +msgstr "" + #: rog-control-center/ui/pages/anime.slint:6 msgctxt "Anime Brightness" msgid "Off" @@ -157,6 +197,51 @@ msgctxt "PageAppSettings" msgid "Enable change notifications" msgstr "" +#: rog-control-center/ui/pages/aura.slint:27 +msgctxt "PageAura" +msgid "Brightness" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:38 +msgctxt "PageAura" +msgid "Aura mode" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:56 +msgctxt "PageAura" +msgid "Colour 1" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:82 +msgctxt "PageAura" +msgid "Colour 2" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:114 +msgctxt "PageAura" +msgid "Zone" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:137 +msgctxt "PageAura" +msgid "Direction" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:159 +msgctxt "PageAura" +msgid "Speed" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:180 +msgctxt "PageAura" +msgid "Power Settings" +msgstr "" + +#: rog-control-center/ui/pages/aura.slint:211 +msgctxt "PageAura" +msgid "Keyboard" +msgstr "" + #: rog-control-center/ui/pages/fans.slint:27 msgctxt "FanTab" msgid "This fan is not avilable on this machine" @@ -362,89 +447,164 @@ msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" -#: rog-control-center/ui/pages/aura.slint:27 -msgctxt "PageAura" -msgid "Brightness" +#: rog-control-center/ui/types/aura_types.slint:45 +msgctxt "Aura brightness" +msgid "Off" msgstr "" -#: rog-control-center/ui/pages/aura.slint:38 -msgctxt "PageAura" -msgid "Aura mode" +#: rog-control-center/ui/types/aura_types.slint:46 +msgctxt "Aura brightness" +msgid "Low" msgstr "" -#: rog-control-center/ui/pages/aura.slint:56 -msgctxt "PageAura" -msgid "Colour 1" +#: rog-control-center/ui/types/aura_types.slint:47 +msgctxt "Aura brightness" +msgid "Med" msgstr "" -#: rog-control-center/ui/pages/aura.slint:82 -msgctxt "PageAura" -msgid "Colour 2" +#: rog-control-center/ui/types/aura_types.slint:48 +msgctxt "Aura brightness" +msgid "High" msgstr "" -#: rog-control-center/ui/pages/aura.slint:114 -msgctxt "PageAura" -msgid "Zone" +#: rog-control-center/ui/types/aura_types.slint:53 rog-control-center/ui/types/aura_types.slint:68 +msgctxt "Basic aura mode" +msgid "Static" msgstr "" -#: rog-control-center/ui/pages/aura.slint:137 -msgctxt "PageAura" -msgid "Direction" +#: rog-control-center/ui/types/aura_types.slint:54 rog-control-center/ui/types/aura_types.slint:69 +msgctxt "Basic aura mode" +msgid "Breathe" msgstr "" -#: rog-control-center/ui/pages/aura.slint:159 -msgctxt "PageAura" -msgid "Speed" +#: rog-control-center/ui/types/aura_types.slint:55 rog-control-center/ui/types/aura_types.slint:70 +msgctxt "Basic aura mode" +msgid "Strobe" msgstr "" -#: rog-control-center/ui/pages/aura.slint:180 -msgctxt "PageAura" -msgid "Power Settings" +#: rog-control-center/ui/types/aura_types.slint:56 +msgctxt "Basic aura mode" +msgid "Rainbow" msgstr "" -#: rog-control-center/ui/pages/aura.slint:211 rog-control-center/ui/pages/aura.slint:369 rog-control-center/ui/pages/aura.slint:434 -msgctxt "PageAura" -msgid "Keyboard" +#: rog-control-center/ui/types/aura_types.slint:57 +msgctxt "Basic aura mode" +msgid "Star" msgstr "" -#: rog-control-center/ui/pages/aura.slint:235 -msgctxt "PageAura" -msgid "Lid Logo" +#: rog-control-center/ui/types/aura_types.slint:58 +msgctxt "Basic aura mode" +msgid "Rain" msgstr "" -#: rog-control-center/ui/pages/aura.slint:259 -msgctxt "PageAura" -msgid "Lightbar" +#: rog-control-center/ui/types/aura_types.slint:59 +msgctxt "Basic aura mode" +msgid "Highlight" msgstr "" -#: rog-control-center/ui/pages/aura.slint:283 -msgctxt "PageAura" -msgid "Lid Zone" +#: rog-control-center/ui/types/aura_types.slint:60 +msgctxt "Basic aura mode" +msgid "Laser" msgstr "" -#: rog-control-center/ui/pages/aura.slint:307 -msgctxt "PageAura" -msgid "Rear Glow" +#: rog-control-center/ui/types/aura_types.slint:61 +msgctxt "Basic aura mode" +msgid "Ripple" msgstr "" -#: rog-control-center/ui/pages/aura.slint:375 rog-control-center/ui/pages/aura.slint:440 -msgctxt "PageAura" -msgid "Boot" +#: rog-control-center/ui/types/aura_types.slint:62 +msgctxt "Basic aura mode" +msgid "Nothing" msgstr "" -#: rog-control-center/ui/pages/aura.slint:380 rog-control-center/ui/pages/aura.slint:445 -msgctxt "PageAura" -msgid "Awake" +#: rog-control-center/ui/types/aura_types.slint:63 +msgctxt "Basic aura mode" +msgid "Pulse" msgstr "" -#: rog-control-center/ui/pages/aura.slint:385 rog-control-center/ui/pages/aura.slint:450 -msgctxt "PageAura" -msgid "Sleep" +#: rog-control-center/ui/types/aura_types.slint:64 +msgctxt "Basic aura mode" +msgid "Comet" msgstr "" -#: rog-control-center/ui/pages/aura.slint:390 rog-control-center/ui/pages/aura.slint:455 -msgctxt "PageAura" -msgid "Shutdown" +#: rog-control-center/ui/types/aura_types.slint:65 +msgctxt "Basic aura mode" +msgid "Flash" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:77 +msgctxt "Aura zone" +msgid "None" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:78 +msgctxt "Aura zone" +msgid "Key1" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:79 +msgctxt "Aura zone" +msgid "Key2" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:80 +msgctxt "Aura zone" +msgid "Key3" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:81 +msgctxt "Aura zone" +msgid "Key4" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:82 +msgctxt "Aura zone" +msgid "Logo" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:83 +msgctxt "Aura zone" +msgid "Lightbar Left" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:84 +msgctxt "Aura zone" +msgid "Lightbar Right" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:88 +msgctxt "Aura direction" +msgid "Right" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:89 +msgctxt "Aura direction" +msgid "Left" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:90 +msgctxt "Aura direction" +msgid "Up" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:91 +msgctxt "Aura direction" +msgid "Down" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:95 +msgctxt "Aura speed" +msgid "Low" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:96 +msgctxt "Aura speed" +msgid "Medium" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:97 +msgctxt "Aura speed" +msgid "High" msgstr "" #: rog-control-center/ui/widgets/aura_power.slint:32 @@ -467,203 +627,3 @@ msgctxt "AuraPowerGroup" msgid "Shutdown" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:68 -msgctxt "Aura brightness" -msgid "Off" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:69 -msgctxt "Aura brightness" -msgid "Low" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:70 -msgctxt "Aura brightness" -msgid "Med" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:71 -msgctxt "Aura brightness" -msgid "High" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:76 rog-control-center/ui/types/aura_types.slint:91 -msgctxt "Basic aura mode" -msgid "Static" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92 -msgctxt "Basic aura mode" -msgid "Breathe" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93 -msgctxt "Basic aura mode" -msgid "Strobe" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:79 -msgctxt "Basic aura mode" -msgid "Rainbow" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:80 -msgctxt "Basic aura mode" -msgid "Star" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:81 -msgctxt "Basic aura mode" -msgid "Rain" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:82 -msgctxt "Basic aura mode" -msgid "Highlight" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:83 -msgctxt "Basic aura mode" -msgid "Laser" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:84 -msgctxt "Basic aura mode" -msgid "Ripple" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:85 -msgctxt "Basic aura mode" -msgid "Nothing" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:86 -msgctxt "Basic aura mode" -msgid "Pulse" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:87 -msgctxt "Basic aura mode" -msgid "Comet" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:88 -msgctxt "Basic aura mode" -msgid "Flash" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:100 -msgctxt "Aura zone" -msgid "None" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:101 -msgctxt "Aura zone" -msgid "Key1" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:102 -msgctxt "Aura zone" -msgid "Key2" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:103 -msgctxt "Aura zone" -msgid "Key3" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:104 -msgctxt "Aura zone" -msgid "Key4" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:105 -msgctxt "Aura zone" -msgid "Logo" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:106 -msgctxt "Aura zone" -msgid "Lightbar Left" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:107 -msgctxt "Aura zone" -msgid "Lightbar Right" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:111 -msgctxt "Aura direction" -msgid "Right" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:112 -msgctxt "Aura direction" -msgid "Left" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:113 -msgctxt "Aura direction" -msgid "Up" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:114 -msgctxt "Aura direction" -msgid "Down" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:118 -msgctxt "Aura speed" -msgid "Low" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:119 -msgctxt "Aura speed" -msgid "Medium" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:120 -msgctxt "Aura speed" -msgid "High" -msgstr "" - -#: rog-control-center/ui/main_window.slint:50 -msgctxt "MainWindow" -msgid "ROG" -msgstr "" - -#: rog-control-center/ui/main_window.slint:52 -msgctxt "Menu1" -msgid "System Control" -msgstr "" - -#: rog-control-center/ui/main_window.slint:53 -msgctxt "Menu2" -msgid "Keyboard Aura" -msgstr "" - -#: rog-control-center/ui/main_window.slint:54 -msgctxt "Menu3" -msgid "AniMe Matrix" -msgstr "" - -#: rog-control-center/ui/main_window.slint:55 -msgctxt "Menu4" -msgid "Fan Curves" -msgstr "" - -#: rog-control-center/ui/main_window.slint:56 -msgctxt "Menu5" -msgid "App Settings" -msgstr "" - -#: rog-control-center/ui/main_window.slint:57 -msgctxt "Menu6" -msgid "About" -msgstr "" - -#: rog-control-center/ui/main_window.slint:69 -msgctxt "MainWindow" -msgid "Quit" -msgstr "" - diff --git a/rog-control-center/ui/main_window.slint b/rog-control-center/ui/main_window.slint index a85d1218..ca3ea77c 100644 --- a/rog-control-center/ui/main_window.slint +++ b/rog-control-center/ui/main_window.slint @@ -10,8 +10,8 @@ import { Node } from "widgets/graph.slint"; export { Node } import { FanPageData, FanType, Profile } from "types/fan_types.slint"; export { FanPageData, FanType, Profile } -import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "types/aura_types.slint"; -export { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } +import { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } from "types/aura_types.slint"; +export { AuraPageData, AuraDevType, LaptopAuraPower, AuraPowerState, PowerZones, AuraEffect } import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint"; export { AppSize, AvailableSystemProperties, SystemPageData, AnimePageData, AppSettingsPageData } diff --git a/rog-control-center/ui/pages/aura.slint b/rog-control-center/ui/pages/aura.slint index e7e9e240..daf34fb9 100644 --- a/rog-control-center/ui/pages/aura.slint +++ b/rog-control-center/ui/pages/aura.slint @@ -2,7 +2,7 @@ import { SystemDropdown, RogItem, SystemToggle, SystemToggleVert } from "../widg import { Palette, Button, ComboBox, VerticalBox, GroupBox } from "std-widgets.slint"; import { StyleMetrics, Slider, HorizontalBox, TextEdit, SpinBox, LineEdit, ScrollView } from "std-widgets.slint"; import { ColourSlider } from "../widgets/colour_picker.slint"; -import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "../types/aura_types.slint"; +import { AuraPageData, AuraDevType, PowerZones, LaptopAuraPower, AuraEffect } from "../types/aura_types.slint"; import { AuraPowerGroup } from "../widgets/aura_power.slint"; export component PageAura inherits Rectangle { @@ -206,268 +206,42 @@ export component PageAura inherits Rectangle { padding: 30px; padding-top: 10px; spacing: 10px; - for power in AuraPageData.supported_power_zones: gr := HorizontalLayout { - if power == PowerZones.Keyboard: zone1 := AuraPowerGroup { - group-title: @tr("Keyboard"); - boot_checked: AuraPageData.led_power.rog.keyboard.boot; - boot_toggled => { - AuraPageData.led_power.rog.keyboard.boot = zone1.boot_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - awake_checked: AuraPageData.led_power.rog.keyboard.awake; - awake_toggled => { - AuraPageData.led_power.rog.keyboard.awake = zone1.awake_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - sleep_checked: AuraPageData.led_power.rog.keyboard.sleep; - sleep_toggled => { - AuraPageData.led_power.rog.keyboard.sleep = zone1.sleep_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - shutdown_checked: AuraPageData.led_power.rog.keyboard.shutdown; - shutdown_toggled => { - AuraPageData.led_power.rog.keyboard.shutdown = zone1.shutdown_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - } - if power == PowerZones.Logo: zone2 := AuraPowerGroup { - group-title: @tr("Lid Logo"); - boot_checked: AuraPageData.led_power.rog.logo.boot; - boot_toggled => { - AuraPageData.led_power.rog.logo.boot = zone2.boot_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - awake_checked: AuraPageData.led_power.rog.logo.awake; - awake_toggled => { - AuraPageData.led_power.rog.logo.awake = zone2.awake_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - sleep_checked: AuraPageData.led_power.rog.logo.sleep; - sleep_toggled => { - AuraPageData.led_power.rog.logo.sleep = zone2.sleep_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - shutdown_checked: AuraPageData.led_power.rog.logo.shutdown; - shutdown_toggled => { - AuraPageData.led_power.rog.logo.shutdown = zone2.shutdown_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } + for state[idx] in AuraPageData.led_power.states: zone := AuraPowerGroup { + group-title: AuraPageData.power_zone_names[state.zone_name_idx]; + // TODO: use the zone name + boot_checked: state.boot; + boot_toggled => { + AuraPageData.led_power.states[idx].boot = zone.boot_checked; + AuraPageData.set_led_power(AuraPageData.led_power); } - - if power == PowerZones.Lightbar: zone3 := AuraPowerGroup { - group-title: @tr("Lightbar"); - boot_checked: AuraPageData.led_power.rog.lightbar.boot; - boot_toggled => { - AuraPageData.led_power.rog.lightbar.boot = zone3.boot_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - awake_checked: AuraPageData.led_power.rog.lightbar.awake; - awake_toggled => { - AuraPageData.led_power.rog.lightbar.awake = zone3.awake_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - sleep_checked: AuraPageData.led_power.rog.lightbar.sleep; - sleep_toggled => { - AuraPageData.led_power.rog.lightbar.sleep = zone3.sleep_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - shutdown_checked: AuraPageData.led_power.rog.lightbar.shutdown; - shutdown_toggled => { - AuraPageData.led_power.rog.lightbar.shutdown = zone3.shutdown_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } + awake_checked: state.awake; + awake_toggled => { + AuraPageData.led_power.states[idx].awake = zone.awake_checked; + AuraPageData.set_led_power(AuraPageData.led_power); } - - if power == PowerZones.Lid: zone4 := AuraPowerGroup { - group-title: @tr("Lid Zone"); - boot_checked: AuraPageData.led_power.rog.lid.boot; - boot_toggled => { - AuraPageData.led_power.rog.lid.boot = zone4.boot_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - awake_checked: AuraPageData.led_power.rog.lid.awake; - awake_toggled => { - AuraPageData.led_power.rog.lid.awake = zone4.awake_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - sleep_checked: AuraPageData.led_power.rog.lid.sleep; - sleep_toggled => { - AuraPageData.led_power.rog.lid.sleep = zone4.sleep_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - shutdown_checked: AuraPageData.led_power.rog.lid.shutdown; - shutdown_toggled => { - AuraPageData.led_power.rog.lid.shutdown = zone4.shutdown_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } + sleep_checked: state.sleep; + sleep_toggled => { + AuraPageData.led_power.states[idx].sleep = zone.sleep_checked; + AuraPageData.set_led_power(AuraPageData.led_power); } - - if power == PowerZones.RearGlow: zone5 := AuraPowerGroup { - group-title: @tr("Rear Glow"); - boot_checked: AuraPageData.led_power.rog.rear-glow.boot; - boot_toggled => { - AuraPageData.led_power.rog.rear-glow.boot = zone5.boot_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - awake_checked: AuraPageData.led_power.rog.rear-glow.awake; - awake_toggled => { - AuraPageData.led_power.rog.rear-glow.awake = zone5.awake_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - sleep_checked: AuraPageData.led_power.rog.rear-glow.sleep; - sleep_toggled => { - AuraPageData.led_power.rog.rear-glow.sleep = zone5.sleep_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } - shutdown_checked: AuraPageData.led_power.rog.rear-glow.shutdown; - shutdown_toggled => { - AuraPageData.led_power.rog.rear-glow.shutdown = zone5.shutdown_checked; - AuraPageData.set_led_power(AuraPageData.led_power); - } + shutdown_checked: state.shutdown; + shutdown_toggled => { + AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked; + AuraPageData.set_led_power(AuraPageData.led_power); } } } - } - Button { - x: root.width - self.width - 6px; - y: 6px; - text: "X"; - height: 40px; - clicked => { - root.show_aura_power = false; - root.show_fade_cover = false; - } - } - } - - if root.show_aura_power && AuraPageData.aura_type == AuraDevType.Old: Rectangle { - width: 100%; - height: 100%; - opacity: 1; - ScrollView { - VerticalLayout { - padding: 30px; - padding-top: 10px; - spacing: 10px; - - Text { - text: "WIP: this is not complete and won't change keyboard state"; + Button { + x: root.width - self.width - 6px; + y: 6px; + text: "X"; + height: 40px; + clicked => { + root.show_aura_power = false; + root.show_fade_cover = false; } - - Rectangle { - border-radius: 20px; - background: Palette.control-background; - VerticalBox { - spacing: 10px; - alignment: LayoutAlignment.start; - Text { - font-size: 18px; - color: Palette.control-foreground; - horizontal-alignment: TextHorizontalAlignment.center; - text: @tr("Keyboard"); - } - - HorizontalBox { - SystemToggleVert { - max-height: 42px; - text: @tr("Boot"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Awake"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Sleep"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Shutdown"); - } - } - } - } - } - } - - Button { - x: root.width - self.width - 6px; - y: 6px; - text: "X"; - height: 40px; - clicked => { - root.show_aura_power = false; - root.show_fade_cover = false; - } - } - } - - if root.show_aura_power && AuraPageData.aura_type == AuraDevType.Tuf: Rectangle { - width: 100%; - height: 100%; - opacity: 1; - ScrollView { - VerticalLayout { - padding: 30px; - padding-top: 10px; - spacing: 10px; - - Text { - text: "WIP: this is not complete and won't change keyboard state"; - } - - Rectangle { - border-radius: 20px; - background: Palette.control-background; - VerticalBox { - spacing: 10px; - alignment: LayoutAlignment.start; - Text { - font-size: 18px; - color: Palette.control-foreground; - horizontal-alignment: TextHorizontalAlignment.center; - text: @tr("Keyboard"); - } - - HorizontalBox { - SystemToggleVert { - max-height: 42px; - text: @tr("Boot"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Awake"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Sleep"); - } - - SystemToggleVert { - max-height: 42px; - text: @tr("Shutdown"); - } - } - } - } - } - } - - Button { - x: root.width - self.width - 6px; - y: 6px; - text: "X"; - height: 40px; - clicked => { - root.show_aura_power = false; - root.show_fade_cover = false; } } } diff --git a/rog-control-center/ui/types/aura_types.slint b/rog-control-center/ui/types/aura_types.slint index 623bb31e..b12746a2 100644 --- a/rog-control-center/ui/types/aura_types.slint +++ b/rog-control-center/ui/types/aura_types.slint @@ -1,7 +1,7 @@ export enum AuraDevType { - Tuf, - Old, New, + Old, + Tuf, } export struct AuraEffect { @@ -19,51 +19,37 @@ export struct AuraEffect { direction: int, } -export enum AuraDevTuf { - Boot, - Awake, - Sleep, - Keyboard, -} - -export enum AuraDevRog1 { - Awake, - Keyboard, - Lightbar, - Boot, - Sleep, -} - export enum PowerZones { Logo, Keyboard, Lightbar, Lid, RearGlow, + KeyboardAndLightbar } -export struct KbAuraPowerState { +export struct AuraPowerState { + zone: PowerZones, + zone_name_idx: int, boot: bool, awake: bool, sleep: bool, shutdown: bool, } -export struct AuraPower { - keyboard: KbAuraPowerState, - logo: KbAuraPowerState, - lightbar: KbAuraPowerState, - lid: KbAuraPowerState, - rear_glow: KbAuraPowerState, -} - -export struct AuraPowerDev { - tuf: [AuraDevTuf], - old_rog: [AuraDevRog1], - rog: AuraPower, +export struct LaptopAuraPower { + states: [AuraPowerState], } export global AuraPageData { + in-out property <[string]> power_zone_names: [ + @tr("Aura power zone" => "Logo"), + @tr("Aura power zone" => "Keyboard"), + @tr("Aura power zone" => "Lightbar"), + @tr("Aura power zone" => "Lid"), + @tr("Aura power zone" => "Rear Glow"), + @tr("Aura power zone" => "Keyboard and Lightbar"), + ]; in-out property <[string]> brightness_names: [ @tr("Aura brightness" => "Off"), @tr("Aura brightness" => "Low"), @@ -157,6 +143,14 @@ export global AuraPageData { PowerZones.Lightbar, PowerZones.Logo ]; - in-out property led_power; - callback set_led_power(AuraPowerDev); + in-out property led_power: { + states: [{ + zone: PowerZones.Keyboard, + boot: true, + awake: true, + sleep: true, + shutdown: true, + }] + }; + callback set_led_power(LaptopAuraPower); } diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index 92497728..a203b542 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -24,8 +24,7 @@ use std::collections::BTreeMap; use rog_aura::aura_detection::PowerZones; use rog_aura::keyboard::{LaptopAuraPower, UsbPackets}; -use rog_aura::usb::AuraDevice; -use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness}; +use rog_aura::{AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, LedBrightness}; use zbus::blocking::Connection; use zbus::{proxy, Result}; @@ -51,7 +50,7 @@ trait Aura { /// DeviceType property #[zbus(property)] - fn device_type(&self) -> zbus::Result; + fn device_type(&self) -> zbus::Result; /// LedMode property #[zbus(property)] diff --git a/rog-platform/examples/ally-gamepad-calibration.rs b/rog-platform/examples/ally-gamepad-calibration.rs index c70ed9f2..b716cdf6 100644 --- a/rog-platform/examples/ally-gamepad-calibration.rs +++ b/rog-platform/examples/ally-gamepad-calibration.rs @@ -1,23 +1,16 @@ use std::error::Error; -use rog_aura::usb::AuraDevice; use rog_platform::hid_raw::HidRaw; pub fn main() -> Result<(), Box> { let mut usb_node = None; - let prod = AuraDevice::X1abe; - match HidRaw::new(prod.into()) { + match HidRaw::new("1abe") { Ok(node) => { + let id = node.prod_id().to_owned(); usb_node = Some(node); - println!( - "Looked for keyboard controller 0x{}: Found", - <&str>::from(prod) - ); + println!("Looked for keyboard controller 0x{}: Found", id); } - Err(err) => println!( - "Looked for keyboard controller 0x{}: {err}", - <&str>::from(prod) - ), + Err(err) => println!("Looked for keyboard controller: {err}"), } if usb_node.is_none() { diff --git a/rog-platform/examples/ally-gamepad-mode-changes.rs b/rog-platform/examples/ally-gamepad-mode-changes.rs index 112e71b5..f8eb3bc7 100644 --- a/rog-platform/examples/ally-gamepad-mode-changes.rs +++ b/rog-platform/examples/ally-gamepad-mode-changes.rs @@ -2,24 +2,17 @@ use std::error::Error; use std::thread::sleep; use std::time::Duration; -use rog_aura::usb::AuraDevice; use rog_platform::hid_raw::HidRaw; pub fn main() -> Result<(), Box> { let mut usb_node = None; - let prod = AuraDevice::X1abe; - match HidRaw::new(prod.into()) { + match HidRaw::new("1abe") { Ok(node) => { + let id = node.prod_id().to_owned(); usb_node = Some(node); - println!( - "Looked for keyboard controller 0x{}: Found", - <&str>::from(prod) - ); + println!("Looked for keyboard controller 0x{}: Found", id); } - Err(err) => println!( - "Looked for keyboard controller 0x{}: {err}", - <&str>::from(prod) - ), + Err(err) => println!("Looked for keyboard controller: {err}"), } if usb_node.is_none() { diff --git a/rog-platform/examples/ally-set-qam-secondary.rs b/rog-platform/examples/ally-set-qam-secondary.rs index c3365ea8..66bb89dd 100644 --- a/rog-platform/examples/ally-set-qam-secondary.rs +++ b/rog-platform/examples/ally-set-qam-secondary.rs @@ -1,23 +1,16 @@ use std::error::Error; -use rog_aura::usb::AuraDevice; use rog_platform::hid_raw::HidRaw; pub fn main() -> Result<(), Box> { let mut usb_node = None; - let prod = AuraDevice::X1abe; - match HidRaw::new(prod.into()) { + match HidRaw::new("1abe") { Ok(node) => { + let id = node.prod_id().to_owned(); usb_node = Some(node); - println!( - "Looked for keyboard controller 0x{}: Found", - <&str>::from(prod) - ); + println!("Looked for keyboard controller 0x{}: Found", id); } - Err(err) => println!( - "Looked for keyboard controller 0x{}: {err}", - <&str>::from(prod) - ), + Err(err) => println!("Looked for keyboard controller: {err}"), } if usb_node.is_none() { From be7686bb46667e6760389b9ab983d9af5a4c66db Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 9 Apr 2024 21:23:44 +1200 Subject: [PATCH 12/12] Dump deps and version --- Cargo.lock | 42 ++++---- Cargo.toml | 2 +- .../translations/en/rog-control-center.po | 101 +++++++++++------- 3 files changed, 85 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cd5b9ed..dbc659a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" [[package]] name = "asusctl" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "asusd", "cargo-husky", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "asusd" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "concat-idents", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "asusd-user" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "config-traits", @@ -590,9 +590,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "by_address" @@ -666,9 +666,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" [[package]] name = "cc" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -840,7 +840,7 @@ dependencies = [ [[package]] name = "config-traits" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "log", @@ -950,7 +950,7 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpuctl" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" [[package]] name = "cpufeatures" @@ -1160,7 +1160,7 @@ dependencies = [ [[package]] name = "dmi_id" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "log", "udev 0.8.0", @@ -1695,9 +1695,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06fddc2749e0528d2813f95e050e87e52c8cbbae56223b9babf73b3e53b0cc6" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -3437,7 +3437,7 @@ dependencies = [ [[package]] name = "rog-control-center" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "asusd", "betrayer", @@ -3476,7 +3476,7 @@ dependencies = [ [[package]] name = "rog_anime" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "dmi_id", @@ -3493,7 +3493,7 @@ dependencies = [ [[package]] name = "rog_aura" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "dmi_id", @@ -3507,7 +3507,7 @@ dependencies = [ [[package]] name = "rog_dbus" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "asusd", "cargo-husky", @@ -3520,7 +3520,7 @@ dependencies = [ [[package]] name = "rog_platform" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "concat-idents", @@ -3537,7 +3537,7 @@ dependencies = [ [[package]] name = "rog_profiles" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "cargo-husky", "log", @@ -3551,7 +3551,7 @@ dependencies = [ [[package]] name = "rog_simulators" -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" dependencies = [ "glam", "log", @@ -3795,9 +3795,9 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index b32d7d22..5b828836 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default-members = [ resolver = "2" [workspace.package] -version = "6.0.0-alpha2" +version = "6.0.0-alpha3" rust-version = "1.76" [workspace.dependencies] diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index d556000f..e6e3a203 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-09 06:25+0000\n" +"POT-Creation-Date: 2024-04-09 09:23+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -237,11 +237,6 @@ msgctxt "PageAura" msgid "Power Settings" msgstr "" -#: rog-control-center/ui/pages/aura.slint:211 -msgctxt "PageAura" -msgid "Keyboard" -msgstr "" - #: rog-control-center/ui/pages/fans.slint:27 msgctxt "FanTab" msgid "This fan is not avilable on this machine" @@ -447,162 +442,192 @@ msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:45 +#: rog-control-center/ui/types/aura_types.slint:46 +msgctxt "Aura power zone" +msgid "Logo" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:47 +msgctxt "Aura power zone" +msgid "Keyboard" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:48 +msgctxt "Aura power zone" +msgid "Lightbar" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:49 +msgctxt "Aura power zone" +msgid "Lid" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:50 +msgctxt "Aura power zone" +msgid "Rear Glow" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:51 +msgctxt "Aura power zone" +msgid "Keyboard and Lightbar" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:54 msgctxt "Aura brightness" msgid "Off" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:46 +#: rog-control-center/ui/types/aura_types.slint:55 msgctxt "Aura brightness" msgid "Low" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:47 +#: rog-control-center/ui/types/aura_types.slint:56 msgctxt "Aura brightness" msgid "Med" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:48 +#: rog-control-center/ui/types/aura_types.slint:57 msgctxt "Aura brightness" msgid "High" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:53 rog-control-center/ui/types/aura_types.slint:68 +#: rog-control-center/ui/types/aura_types.slint:62 rog-control-center/ui/types/aura_types.slint:77 msgctxt "Basic aura mode" msgid "Static" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:54 rog-control-center/ui/types/aura_types.slint:69 +#: rog-control-center/ui/types/aura_types.slint:63 rog-control-center/ui/types/aura_types.slint:78 msgctxt "Basic aura mode" msgid "Breathe" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:55 rog-control-center/ui/types/aura_types.slint:70 +#: rog-control-center/ui/types/aura_types.slint:64 rog-control-center/ui/types/aura_types.slint:79 msgctxt "Basic aura mode" msgid "Strobe" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:56 +#: rog-control-center/ui/types/aura_types.slint:65 msgctxt "Basic aura mode" msgid "Rainbow" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:57 +#: rog-control-center/ui/types/aura_types.slint:66 msgctxt "Basic aura mode" msgid "Star" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:58 +#: rog-control-center/ui/types/aura_types.slint:67 msgctxt "Basic aura mode" msgid "Rain" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:59 +#: rog-control-center/ui/types/aura_types.slint:68 msgctxt "Basic aura mode" msgid "Highlight" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:60 +#: rog-control-center/ui/types/aura_types.slint:69 msgctxt "Basic aura mode" msgid "Laser" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:61 +#: rog-control-center/ui/types/aura_types.slint:70 msgctxt "Basic aura mode" msgid "Ripple" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:62 +#: rog-control-center/ui/types/aura_types.slint:71 msgctxt "Basic aura mode" msgid "Nothing" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:63 +#: rog-control-center/ui/types/aura_types.slint:72 msgctxt "Basic aura mode" msgid "Pulse" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:64 +#: rog-control-center/ui/types/aura_types.slint:73 msgctxt "Basic aura mode" msgid "Comet" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:65 +#: rog-control-center/ui/types/aura_types.slint:74 msgctxt "Basic aura mode" msgid "Flash" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:77 +#: rog-control-center/ui/types/aura_types.slint:86 msgctxt "Aura zone" msgid "None" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:78 +#: rog-control-center/ui/types/aura_types.slint:87 msgctxt "Aura zone" msgid "Key1" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:79 +#: rog-control-center/ui/types/aura_types.slint:88 msgctxt "Aura zone" msgid "Key2" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:80 +#: rog-control-center/ui/types/aura_types.slint:89 msgctxt "Aura zone" msgid "Key3" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:81 +#: rog-control-center/ui/types/aura_types.slint:90 msgctxt "Aura zone" msgid "Key4" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:82 +#: rog-control-center/ui/types/aura_types.slint:91 msgctxt "Aura zone" msgid "Logo" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:83 +#: rog-control-center/ui/types/aura_types.slint:92 msgctxt "Aura zone" msgid "Lightbar Left" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:84 +#: rog-control-center/ui/types/aura_types.slint:93 msgctxt "Aura zone" msgid "Lightbar Right" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:88 +#: rog-control-center/ui/types/aura_types.slint:97 msgctxt "Aura direction" msgid "Right" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:89 +#: rog-control-center/ui/types/aura_types.slint:98 msgctxt "Aura direction" msgid "Left" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:90 +#: rog-control-center/ui/types/aura_types.slint:99 msgctxt "Aura direction" msgid "Up" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:91 +#: rog-control-center/ui/types/aura_types.slint:100 msgctxt "Aura direction" msgid "Down" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:95 +#: rog-control-center/ui/types/aura_types.slint:104 msgctxt "Aura speed" msgid "Low" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:96 +#: rog-control-center/ui/types/aura_types.slint:105 msgctxt "Aura speed" msgid "Medium" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:97 +#: rog-control-center/ui/types/aura_types.slint:106 msgctxt "Aura speed" msgid "High" msgstr ""