From 1366422d96afe58229168bd88aa90622846ca1d2 Mon Sep 17 00:00:00 2001 From: "Jochen@Jinbe" Date: Fri, 22 Mar 2024 22:05:27 +0100 Subject: [PATCH 01/13] Play around and add rog-slash --- Cargo.lock | 14 +- Cargo.toml | 1 + Makefile | 9 +- asusctl/examples/slash-steady.rs | 38 ++ asusd/src/lib.rs | 2 +- .../dbus-xml/org-asuslinux-19b6-4-4-4.xml | 105 ++++++ .../dbus-xml/org-asuslinux-platform-4.xml | 284 ++++++++++++-- rog-aura/data/aura_support.ron | 8 + rog-aura/src/builtin_modes.rs | 2 +- rog-dbus/src/zbus_aura.rs | 2 +- rog-slash/Cargo.toml | 29 ++ rog-slash/src/lib.rs | 3 + rog-slash/src/usb.rs | 345 ++++++++++++++++++ squashfs-root/.DirIcon | 1 + 14 files changed, 794 insertions(+), 49 deletions(-) create mode 100644 asusctl/examples/slash-steady.rs create mode 100644 bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml create mode 100644 rog-slash/Cargo.toml create mode 100644 rog-slash/src/lib.rs create mode 100644 rog-slash/src/usb.rs create mode 100644 squashfs-root/.DirIcon diff --git a/Cargo.lock b/Cargo.lock index ff4a4df8..bdebc464 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3907,7 +3907,7 @@ dependencies = [ "i-slint-compiler", "spin_on", "thiserror", - "toml_edit 0.22.8", + "toml_edit 0.22.9", ] [[package]] @@ -3932,9 +3932,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smithay-client-toolkit" @@ -4112,7 +4112,7 @@ dependencies = [ [[package]] name = "supergfxctl" version = "5.2.2" -source = "git+https://gitlab.com/asus-linux/supergfxctl.git#f3465681ac147821bbd2d50aff2bced2d92d529e" +source = "git+https://gitlab.com/asus-linux/supergfxctl.git#68c12374d2cc20e5503b7694168afa2bf52af705" dependencies = [ "log", "logind-zbus", @@ -4377,7 +4377,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.8", + "toml_edit 0.22.9", ] [[package]] @@ -4413,9 +4413,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.8" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12219811e0c1ba077867254e5ad62ee2c9c190b0d957110750ac0cda1ae96cd" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ "indexmap", "serde", diff --git a/Cargo.toml b/Cargo.toml index c25d3efc..e72dafa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ tokio = { version = "^1.23.0", default-features = false, features = [ "sync", "time", "rt", + "rt-multi-thread" ] } concat-idents = "^1.1" dirs = "^4.0" diff --git a/Makefile b/Makefile index 8acce3b6..f5f7a967 100644 --- a/Makefile +++ b/Makefile @@ -124,10 +124,11 @@ bindings: typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts introspect: - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/FanCurves -x > bindings/dbus-xml/org-asuslinux-fan-curves-4.xml +# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml +# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml +# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux -x > bindings/dbus-xml/org-asuslinux-platform-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/19b6_4_4 -x > bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Introspectable"]' bindings/dbus-xml/org-asuslinux-* 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-* diff --git a/asusctl/examples/slash-steady.rs b/asusctl/examples/slash-steady.rs new file mode 100644 index 00000000..874689d8 --- /dev/null +++ b/asusctl/examples/slash-steady.rs @@ -0,0 +1,38 @@ +use std::thread::sleep; +use std::time::Duration; + +use rog_anime::usb::get_anime_type; +use rog_anime::{AnimeDiagonal, AnimeType}; +use rog_dbus::RogDbusClientBlocking; + +// In usable data: +// Top row start at 1, ends at 32 + +// 74w x 36h diagonal used by the windows app + +fn main() { + let (client, _) = RogDbusClientBlocking::new().unwrap(); + + for step in (2..50).rev() { + let mut matrix = AnimeDiagonal::new(AnimeType::GA401, None); + for c in (0..60).step_by(step) { + for i in matrix.get_mut().iter_mut() { + i[c] = 50; + } + } + + for c in (0..35).step_by(step) { + for i in &mut matrix.get_mut()[c] { + *i = 50; + } + } + + let anime_type = get_anime_type().unwrap(); + client + .proxies() + .anime() + .write(matrix.into_data_buffer(anime_type).unwrap()) + .unwrap(); + sleep(Duration::from_millis(300)); + } +} diff --git a/asusd/src/lib.rs b/asusd/src/lib.rs index db784d39..aaeff5fc 100644 --- a/asusd/src/lib.rs +++ b/asusd/src/lib.rs @@ -50,7 +50,7 @@ pub static DBUS_IFACE: &str = "org.asuslinux.Daemon"; /// task_watch_item!(panel_od platform); /// task_watch_item!(gpu_mux_mode platform); /// } -/// ``` +/// ```\ /// // TODO: this is kind of useless if it can't trigger some action #[macro_export] macro_rules! task_watch_item { diff --git a/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml b/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml new file mode 100644 index 00000000..a04d6fab --- /dev/null +++ b/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bindings/dbus-xml/org-asuslinux-platform-4.xml b/bindings/dbus-xml/org-asuslinux-platform-4.xml index a8708bd5..682f0441 100644 --- a/bindings/dbus-xml/org-asuslinux-platform-4.xml +++ b/bindings/dbus-xml/org-asuslinux-platform-4.xml @@ -2,7 +2,100 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -18,6 +111,11 @@ --> + + @@ -42,10 +140,6 @@ internal config also. --> - - + + - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rog-aura/data/aura_support.ron b/rog-aura/data/aura_support.ron index 39f39241..a2775043 100644 --- a/rog-aura/data/aura_support.ron +++ b/rog-aura/data/aura_support.ron @@ -727,4 +727,12 @@ advanced_type: None, power_zones: [Keyboard], ), + ( + board_name: "GA403UI", + layout_name: "ga401q", + basic_modes: [Static, Breathe, Pulse], + basic_zones: [], + advanced_type: None, + power_zones: [Keyboard], + ), ]) diff --git a/rog-aura/src/builtin_modes.rs b/rog-aura/src/builtin_modes.rs index d955c74c..f5c729a9 100644 --- a/rog-aura/src/builtin_modes.rs +++ b/rog-aura/src/builtin_modes.rs @@ -486,7 +486,7 @@ impl Default for AuraEffect { Self { mode: AuraModeNum::Static, zone: AuraZone::None, - colour1: Colour { r: 166, g: 0, b: 0 }, + colour1: Colour { r: 166, g: 166, b: 166 }, colour2: Colour { r: 0, g: 0, b: 0 }, speed: Speed::Med, direction: Direction::Right, diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index f1e5e221..040bb9b5 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -34,7 +34,7 @@ const BLOCKING_TIME: u64 = 33; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 F #[proxy( interface = "org.asuslinux.Aura", default_service = "org.asuslinux.Daemon", - default_path = "/org/asuslinux/Aura" + default_path = "/org/asuslinux/19b6_4_4" )] trait Aura { /// AllModeData method diff --git a/rog-slash/Cargo.toml b/rog-slash/Cargo.toml new file mode 100644 index 00000000..4f5864a2 --- /dev/null +++ b/rog-slash/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "rog_slash" +license = "MPL-2.0" +version.workspace = true +readme = "README.md" +authors = ["Luke "] +repository = "https://gitlab.com/asus-linux/asus-nb-ctrl" +homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl" +documentation = "https://docs.rs/rog-anime" +description = "ASUS Slash display" +keywords = ["ROG", "ASUS", "AniMe", "Slash"] +edition = "2024" +exclude = ["data"] + +[dependencies] +log.workspace = true +serde.workspace = true +serde_derive.workspace = true +zbus.workspace = true +concat-idents.workspace = true +udev.workspace = true +inotify.workspace = true +typeshare.workspace = true + +rusb.workspace = true + +[dev-dependencies] +cargo-husky.workspace = true +rog_aura = { path = "../rog-aura" } \ No newline at end of file diff --git a/rog-slash/src/lib.rs b/rog-slash/src/lib.rs new file mode 100644 index 00000000..ffb4a0c5 --- /dev/null +++ b/rog-slash/src/lib.rs @@ -0,0 +1,3 @@ + +/// Provides const methods to create the USB HID control packets +pub mod usb; \ No newline at end of file diff --git a/rog-slash/src/usb.rs b/rog-slash/src/usb.rs new file mode 100644 index 00000000..d0dcc9ca --- /dev/null +++ b/rog-slash/src/usb.rs @@ -0,0 +1,345 @@ +//! Utils for writing to the `AniMe` USB device +//! +//! Use of the device requires a few steps: +//! 1. Initialise the device by writing the two packets from +//! `get_init_packets()` 2. Write data from `AnimePacketType` +//! 3. Write the packet from `get_flush_packet()`, which tells the device to +//! display the data from step 2 +//! +//! Step 1 need to applied only on fresh system boot. + +use std::str::FromStr; + +use dmi_id::DMIID; +use serde_derive::{Deserialize, Serialize}; +use typeshare::typeshare; +#[cfg(feature = "dbus")] +use zbus::zvariant::{OwnedValue, Type, Value}; + +use crate::error::AnimeError; +use crate::AnimeType; + +const PACKET_SIZE: usize = 640; +const DEV_PAGE: u8 = 0x5e; +pub const VENDOR_ID: u16 = 0x0b05; +pub const PROD_ID: u16 = 0x193b; + +#[cfg_attr( +feature = "dbus", +derive(Type, Value, OwnedValue), +zvariant(signature = "u") +)] +#[typeshare] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +/// Base LED brightness of the display +pub enum Brightness { + Off = 0, + Low = 1, + #[default] + Med = 2, + High = 3, +} + +impl FromStr for Brightness { + type Err = AnimeError; + + fn from_str(s: &str) -> Result { + Ok(match s { + "Off" | "off" => Brightness::Off, + "Low" | "low" => Brightness::Low, + "Med" | "med" => Brightness::Med, + "High" | "high" => Brightness::High, + _ => Brightness::Med, + }) + } +} + +impl From for Brightness { + fn from(v: u8) -> Brightness { + match v { + 0 => Brightness::Off, + 1 => Brightness::Low, + 3 => Brightness::High, + _ => Brightness::Med, + } + } +} + +impl From for Brightness { + fn from(v: i32) -> Brightness { + (v as u8).into() + } +} + +impl From for i32 { + fn from(v: Brightness) -> i32 { + v as i32 + } +} + +#[cfg_attr( +feature = "dbus", +derive(Type, Value, OwnedValue), +zvariant(signature = "s") +)] +#[typeshare] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +pub enum AnimBooting { + #[default] + GlitchConstruction = 0, + StaticEmergence = 1, +} + +impl FromStr for AnimBooting { + type Err = AnimeError; + + fn from_str(s: &str) -> Result { + match s { + "GlitchConstruction" => Ok(Self::GlitchConstruction), + "StaticEmergence" => Ok(Self::StaticEmergence), + _ => Err(AnimeError::ParseError(s.to_owned())), + } + } +} + +impl From for AnimBooting { + fn from(value: i32) -> Self { + match value { + 0 => Self::GlitchConstruction, + 1 => Self::StaticEmergence, + _ => Self::default(), + } + } +} + +impl From for i32 { + fn from(value: AnimBooting) -> Self { + value as i32 + } +} + +#[cfg_attr( +feature = "dbus", +derive(Type, Value, OwnedValue), +zvariant(signature = "s") +)] +#[typeshare] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +pub enum AnimAwake { + #[default] + BinaryBannerScroll = 0, + RogLogoGlitch = 1, +} + +impl FromStr for AnimAwake { + type Err = AnimeError; + + fn from_str(s: &str) -> Result { + match s { + "BinaryBannerScroll" => Ok(Self::BinaryBannerScroll), + "RogLogoGlitch" => Ok(Self::RogLogoGlitch), + _ => Err(AnimeError::ParseError(s.to_owned())), + } + } +} + +impl From for AnimAwake { + fn from(value: i32) -> Self { + match value { + 0 => Self::BinaryBannerScroll, + 1 => Self::RogLogoGlitch, + _ => Self::default(), + } + } +} + +impl From for i32 { + fn from(value: AnimAwake) -> Self { + value as i32 + } +} + +#[cfg_attr( +feature = "dbus", +derive(Type, Value, OwnedValue), +zvariant(signature = "s") +)] +#[typeshare] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +pub enum AnimSleeping { + #[default] + BannerSwipe = 0, + Starfield = 1, +} + +impl FromStr for AnimSleeping { + type Err = AnimeError; + + fn from_str(s: &str) -> Result { + match s { + "BannerSwipe" => Ok(Self::BannerSwipe), + "Starfield" => Ok(Self::Starfield), + _ => Err(AnimeError::ParseError(s.to_owned())), + } + } +} + +impl From for AnimSleeping { + fn from(value: i32) -> Self { + match value { + 0 => Self::BannerSwipe, + 1 => Self::Starfield, + _ => Self::default(), + } + } +} + +impl From for i32 { + fn from(value: AnimSleeping) -> Self { + value as i32 + } +} + +#[cfg_attr( +feature = "dbus", +derive(Type, Value, OwnedValue), +zvariant(signature = "s") +)] +#[typeshare] +#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +pub enum AnimShutdown { + #[default] + GlitchOut = 0, + SeeYa = 1, +} + +impl FromStr for AnimShutdown { + type Err = AnimeError; + + fn from_str(s: &str) -> Result { + match s { + "GlitchOut" => Ok(Self::GlitchOut), + "SeeYa" => Ok(Self::SeeYa), + _ => Err(AnimeError::ParseError(s.to_owned())), + } + } +} + +impl From for AnimShutdown { + fn from(value: i32) -> Self { + match value { + 0 => Self::GlitchOut, + 1 => Self::SeeYa, + _ => Self::default(), + } + } +} + +impl From for i32 { + fn from(value: AnimShutdown) -> Self { + value as i32 + } +} + +/// `get_anime_type` is very broad, matching on part of the laptop board name +/// only. For this reason `find_node()` must be used also to verify if the USB +/// device is available. +/// +/// The currently known USB device is `19b6`. +#[inline] +pub fn get_anime_type() -> Result { + let dmi = DMIID::new().map_err(|_| AnimeError::NoDevice)?; // TODO: better error + let board_name = dmi.board_name; + + if board_name.contains("GA401I") || board_name.contains("GA401Q") { + return Ok(AnimeType::GA401); + } else if board_name.contains("GA402R") { + return Ok(AnimeType::GA402); + } else if board_name.contains("GU604V") { + return Ok(AnimeType::GU604); + } + log::warn!("AniMe Matrix device found but not yet supported, will default to a GA402 layout"); + Ok(AnimeType::Unknown) +} + +/// Get the two device initialization packets. These are required for device +/// start after the laptop boots. +#[inline] +pub const fn pkts_for_init() -> [[u8; PACKET_SIZE]; 2] { + let mut packets = [[0; PACKET_SIZE]; 2]; + packets[0][0] = DEV_PAGE; // This is the USB page we're using throughout + let mut count = 0; + // TODO: memcpy or slice copy + let bytes = "ASUS Tech.Inc.".as_bytes(); + while count < bytes.len() { + packets[0][count + 1] = bytes[count]; + count += 1; + } + // + packets[1][0] = DEV_PAGE; + packets[1][1] = 0xc2; + packets +} + +/// Should be written to the device after writing the two main data packets that +/// make up the display data packet +#[inline] +pub const fn pkt_flush() -> [u8; PACKET_SIZE] { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xc0; + pkt[2] = 0x03; + pkt +} + +/// Packet for setting the brightness (0-3). Requires +/// `pkt_for_apply()` to be written after. +#[inline] +pub const fn pkt_set_brightness(brightness: Brightness) -> [u8; PACKET_SIZE] { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xc0; + pkt[2] = 0x04; + pkt[3] = brightness as u8; + pkt +} + +/// Enable the display? +#[inline] +pub const fn pkt_set_enable_display(status: bool) -> [u8; PACKET_SIZE] { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xc3; + pkt[2] = 0x01; + pkt[3] = if status { 0x00 } else { 0x80 }; + pkt +} + +/// Enable builtin animations? +#[inline] +pub const fn pkt_set_enable_powersave_anim(status: bool) -> [u8; PACKET_SIZE] { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xc4; + pkt[2] = 0x01; + pkt[3] = if status { 0x00 } else { 0x80 }; + pkt +} + +/// Set which animations are shown for each stage +#[inline] +pub const fn pkt_set_builtin_animations( + boot: AnimBooting, + awake: AnimAwake, + sleep: AnimSleeping, + shutdown: AnimShutdown, +) -> [u8; PACKET_SIZE] { + let mut pkt = [0; PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xc5; + pkt[2] = (awake as u8) + | ((sleep as u8) << 0x01) + | ((shutdown as u8) << 0x02) + | ((boot as u8) << 0x03); + pkt +} diff --git a/squashfs-root/.DirIcon b/squashfs-root/.DirIcon new file mode 100644 index 00000000..94e6adba --- /dev/null +++ b/squashfs-root/.DirIcon @@ -0,0 +1 @@ +ToolBox_trayIcon_colour_32-01 \ No newline at end of file From cdc9ca7b588a60b9388f3c5175707be13520ccef Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Mon, 25 Mar 2024 01:54:05 +0100 Subject: [PATCH 02/13] Try to implement slash bar functionality - part 1 --- Cargo.lock | 33 +++ Cargo.toml | 3 + Makefile | 4 + asusctl/Cargo.toml | 1 + asusctl/src/aura_cli.rs | 7 +- asusctl/src/cli_opts.rs | 3 + asusctl/src/main.rs | 47 ++++ asusctl/src/slash_cli.rs | 19 ++ asusd/Cargo.toml | 1 + asusd/src/config.rs | 8 +- asusd/src/ctrl_anime/config.rs | 8 +- asusd/src/ctrl_aura/config.rs | 8 +- asusd/src/ctrl_aura/controller.rs | 4 +- asusd/src/ctrl_slash/config.rs | 52 ++++ asusd/src/ctrl_slash/mod.rs | 100 +++++++ asusd/src/ctrl_slash/trait_impls.rs | 94 +++++++ asusd/src/daemon.rs | 16 +- asusd/src/lib.rs | 2 + rog-control-center/src/config.rs | 8 +- rog-control-center/src/main.rs | 19 +- rog-dbus/Cargo.toml | 1 + rog-dbus/src/lib.rs | 11 +- rog-dbus/src/zbus_slash.rs | 35 +++ rog-platform/src/usb_raw.rs | 23 +- rog-slash/Cargo.toml | 31 ++- rog-slash/src/data.rs | 105 ++++++++ rog-slash/src/error.rs | 39 +++ rog-slash/src/lib.rs | 11 +- rog-slash/src/usb.rs | 404 +++++++--------------------- slashctl/Cargo.toml | 18 ++ slashctl/src/ctrl_slash/mod.rs | 94 +++++++ slashctl/src/error.rs | 30 +++ slashctl/src/main.rs | 15 ++ 33 files changed, 887 insertions(+), 367 deletions(-) create mode 100644 asusctl/src/slash_cli.rs create mode 100644 asusd/src/ctrl_slash/config.rs create mode 100644 asusd/src/ctrl_slash/mod.rs create mode 100644 asusd/src/ctrl_slash/trait_impls.rs create mode 100644 rog-dbus/src/zbus_slash.rs create mode 100644 rog-slash/src/data.rs create mode 100644 rog-slash/src/error.rs create mode 100644 slashctl/Cargo.toml create mode 100644 slashctl/src/ctrl_slash/mod.rs create mode 100644 slashctl/src/error.rs create mode 100644 slashctl/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index bdebc464..53cad718 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,7 @@ dependencies = [ "rog_dbus", "rog_platform", "rog_profiles", + "rog_slash", "tinybmp", "tokio", "toml 0.5.11", @@ -160,6 +161,7 @@ dependencies = [ "rog_aura", "rog_platform", "rog_profiles", + "rog_slash", "serde", "serde_derive", "systemd-zbus", @@ -3500,6 +3502,7 @@ dependencies = [ "rog_aura", "rog_platform", "rog_profiles", + "rog_slash", "zbus 4.0.1", ] @@ -3545,6 +3548,23 @@ dependencies = [ "uhid-virt", ] +[[package]] +name = "rog_slash" +version = "6.0.0-alpha1" +dependencies = [ + "cargo-husky", + "dmi_id", + "gif 0.12.0", + "glam", + "log", + "pix", + "png_pong", + "serde", + "serde_derive", + "typeshare", + "zbus 4.0.1", +] + [[package]] name = "ron" version = "0.8.1" @@ -3883,6 +3903,19 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slashctl" +version = "6.0.0-alpha1" +dependencies = [ + "dmi_id", + "futures-lite 1.13.0", + "inotify", + "rog_platform", + "rog_profiles", + "rog_slash", + "udev 0.8.0", +] + [[package]] name = "slint" version = "1.5.1" diff --git a/Cargo.toml b/Cargo.toml index e72dafa6..683a12dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "asusctl", + "slashctl", "asusd", "asusd-user", "config-traits", @@ -12,10 +13,12 @@ members = [ "rog-aura", "rog-profiles", "rog-control-center", + "rog-slash", "simulators", ] default-members = [ "asusctl", + "slashctl", "asusd", "asusd-user", "cpuctl", diff --git a/Makefile b/Makefile index f5f7a967..5cc825c9 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ zshcpl = $(datarootdir)/zsh/site-functions BIN_ROG := rog-control-center BIN_C := asusctl +BIN_S := slashctl BIN_D := asusd BIN_U := asusd-user LEDCFG := aura_support.ron @@ -47,6 +48,7 @@ install-program: $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_ROG)" "$(DESTDIR)$(bindir)/$(BIN_ROG)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_C)" "$(DESTDIR)$(bindir)/$(BIN_C)" + $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_S)" "$(DESTDIR)$(bindir)/$(BIN_S)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_D)" "$(DESTDIR)$(bindir)/$(BIN_D)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_U)" "$(DESTDIR)$(bindir)/$(BIN_U)" @@ -86,6 +88,7 @@ uninstall: rm -r "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/$(BIN_ROG).png" rm -f "$(DESTDIR)$(bindir)/$(BIN_C)" + rm -f "$(DESTDIR)$(bindir)/$(BIN_S)" rm -f "$(DESTDIR)$(bindir)/$(BIN_D)" rm -f "$(DESTDIR)$(libdir)/udev/rules.d/99-$(BIN_D).rules" rm -f "$(DESTDIR)/etc/asusd/$(LEDCFG)" @@ -142,6 +145,7 @@ endif cargo build $(ARGS) ifneq ($(STRIP_BINARIES),0) strip -s ./target/$(TARGET)/$(BIN_C) + strip -s ./target/$(TARGET)/$(BIN_S) strip -s ./target/$(TARGET)/$(BIN_D) strip -s ./target/$(TARGET)/$(BIN_U) strip -s ./target/$(TARGET)/$(BIN_ROG) diff --git a/asusctl/Cargo.toml b/asusctl/Cargo.toml index ead75c5b..d905f92f 100644 --- a/asusctl/Cargo.toml +++ b/asusctl/Cargo.toml @@ -7,6 +7,7 @@ version.workspace = true [dependencies] rog_anime = { path = "../rog-anime" } +rog_slash = { path = "../rog-slash" } rog_aura = { path = "../rog-aura" } rog_dbus = { path = "../rog-dbus" } rog_profiles = { path = "../rog-profiles" } diff --git a/asusctl/src/aura_cli.rs b/asusctl/src/aura_cli.rs index 28cc3b89..b30cffb9 100644 --- a/asusctl/src/aura_cli.rs +++ b/asusctl/src/aura_cli.rs @@ -1,3 +1,4 @@ +use std::fmt::Display; use std::str::FromStr; use gumdrop::Options; @@ -87,15 +88,15 @@ impl FromStr for LedBrightness { } } } -impl ToString for LedBrightness { - fn to_string(&self) -> String { +impl Display for LedBrightness { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let s = match self.level { Some(0x00) => "low", Some(0x01) => "med", Some(0x02) => "high", _ => "unknown", }; - s.to_owned() + write!(f, "{}", s.to_owned()) } } diff --git a/asusctl/src/cli_opts.rs b/asusctl/src/cli_opts.rs index ba248371..3ff98aa2 100644 --- a/asusctl/src/cli_opts.rs +++ b/asusctl/src/cli_opts.rs @@ -4,6 +4,7 @@ use rog_platform::platform::ThrottlePolicy; use crate::anime_cli::AnimeCommand; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::fan_curve_cli::FanCurveCommand; +use crate::slash_cli::SlashCommand; #[derive(Default, Options)] pub struct CliStart { @@ -41,6 +42,8 @@ pub enum CliCommand { Graphics(GraphicsCommand), #[options(name = "anime", help = "Manage AniMe Matrix")] Anime(AnimeCommand), + #[options(name = "slash", help = "Manage Slash Ledbar")] + Slash(SlashCommand), #[options(help = "Change bios settings")] Bios(BiosCommand), } diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 2ed66005..0555325c 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -19,14 +19,17 @@ use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::RogDbusClientBlocking; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_profiles::error::ProfileError; +use rog_slash::SlashMode; use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::cli_opts::*; +use crate::slash_cli::{SlashCommand}; mod anime_cli; mod aura_cli; mod cli_opts; mod fan_curve_cli; +mod slash_cli; fn main() { let args: Vec = args().skip(1).collect(); @@ -149,6 +152,7 @@ fn do_parsed( } Some(CliCommand::Graphics(_)) => do_gfx(), Some(CliCommand::Anime(cmd)) => handle_anime(dbus, cmd)?, + Some(CliCommand::Slash(cmd)) => handle_slash(dbus, cmd)?, Some(CliCommand::Bios(cmd)) => handle_platform_properties(dbus, supported_properties, cmd)?, None => { if (!parsed.show_supported @@ -458,6 +462,49 @@ fn verify_brightness(brightness: f32) { } } +fn handle_slash( + dbus: &RogDbusClientBlocking<'_>, + cmd: &SlashCommand, +) -> Result<(), Box> { + if ( + cmd.enable_display.is_none() && + cmd.brightness.is_none() && + cmd.interval.is_none() && + !cmd.list && + !cmd.next && + !cmd.prev + ) || cmd.help + { + println!("Missing arg or command\n\n{}", cmd.self_usage()); + if let Some(lst) = cmd.self_command_list() { + println!("\n{}", lst); + } + } + if let Some(enable) = cmd.enable_display { + dbus.proxies().slash().set_enable_display(enable)?; + } + if let Some(brightness) = cmd.brightness { + dbus.proxies().slash().set_brightness(brightness)?; + } + if let Some(interval) = cmd.interval { + dbus.proxies().slash().set_interval(interval)?; + } + if cmd.next { + dbus.proxies().slash().set_current_mode(SlashMode::Bounce as u8)?; + } + if cmd.prev { + dbus.proxies().slash().set_current_mode(SlashMode::Flow as u8)?; + } + if cmd.list { + let res = SlashMode::list(); + for p in &res { + println!("{:?}", p); + } + } + + Ok(()) +} + fn handle_led_mode( aura: &AuraProxyBlocking, mode: &LedModeCommand, diff --git a/asusctl/src/slash_cli.rs b/asusctl/src/slash_cli.rs new file mode 100644 index 00000000..65ba1c45 --- /dev/null +++ b/asusctl/src/slash_cli.rs @@ -0,0 +1,19 @@ +use gumdrop::Options; + +#[derive(Options)] +pub struct SlashCommand { + #[options(help = "print help message")] + pub help: bool, + #[options(meta = "", help = "enable/disable the display")] + pub enable_display: Option, + #[options(meta = "", help = "set brightness value <0-255>")] + pub brightness: Option, + #[options(meta = "", help = "set interval value <0-255>")] + pub interval: Option, + #[options(help = "toggle to next animation in list")] + pub next: bool, + #[options(help = "toggle to previous animation in list")] + pub prev: bool, + #[options(help = "list available animations")] + pub list: bool, +} \ No newline at end of file diff --git a/asusd/Cargo.toml b/asusd/Cargo.toml index 2e5abfba..83f73571 100644 --- a/asusd/Cargo.toml +++ b/asusd/Cargo.toml @@ -16,6 +16,7 @@ path = "src/daemon.rs" [dependencies] config-traits = { path = "../config-traits" } rog_anime = { path = "../rog-anime", features = ["dbus"] } +rog_slash = { path = "../rog-slash", features = ["dbus"] } rog_aura = { path = "../rog-aura", features = ["dbus"] } rog_platform = { path = "../rog-platform" } rog_profiles = { path = "../rog-profiles" } diff --git a/asusd/src/config.rs b/asusd/src/config.rs index f3a2ea95..b42aa83c 100644 --- a/asusd/src/config.rs +++ b/asusd/src/config.rs @@ -90,13 +90,13 @@ impl StdConfig for Config { } } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { CONFIG_FILE.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad3 for Config {} diff --git a/asusd/src/ctrl_anime/config.rs b/asusd/src/ctrl_anime/config.rs index 507f1d21..2fe9a655 100644 --- a/asusd/src/ctrl_anime/config.rs +++ b/asusd/src/ctrl_anime/config.rs @@ -150,13 +150,13 @@ impl StdConfig for AnimeConfig { Self::create_default() } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { CONFIG_FILE.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad2 for AnimeConfig {} diff --git a/asusd/src/ctrl_aura/config.rs b/asusd/src/ctrl_aura/config.rs index 3119124a..d4729448 100644 --- a/asusd/src/ctrl_aura/config.rs +++ b/asusd/src/ctrl_aura/config.rs @@ -127,16 +127,16 @@ impl StdConfig for AuraConfig { panic!("This should not be used"); } - fn config_dir() -> std::path::PathBuf { - std::path::PathBuf::from(crate::CONFIG_PATH_BASE) - } - fn file_name(&self) -> String { if self.config_name.is_empty() { panic!("Config file name should not be empty"); } self.config_name.to_owned() } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } } impl StdConfigLoad for AuraConfig {} diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index a914b924..cfce7100 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -348,7 +348,7 @@ 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("id_product").unwrap().0), supported_data: supported_basic_modes, per_key_mode_active: false, config, @@ -386,7 +386,7 @@ 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("id_product").unwrap().0), supported_data: supported_basic_modes, per_key_mode_active: false, config, diff --git a/asusd/src/ctrl_slash/config.rs b/asusd/src/ctrl_slash/config.rs new file mode 100644 index 00000000..8ea0568f --- /dev/null +++ b/asusd/src/ctrl_slash/config.rs @@ -0,0 +1,52 @@ +use serde_derive::{Deserialize, Serialize}; +use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2}; +use rog_slash::{DeviceState, SlashMode}; +use crate::ctrl_anime::config::{AnimeConfig, AnimeConfigV460, AnimeConfigV472}; + +const CONFIG_FILE: &str = "slash.ron"; + +/// Config for base system actions for the anime display +#[derive(Deserialize, Serialize, Debug)] +pub struct SlashConfig { + pub slash_enabled: bool, + pub slash_brightness: u8, + pub slash_interval: u8, + pub slash_mode: u8, +} + +impl Default for SlashConfig { + fn default() -> Self { + SlashConfig { + slash_enabled: true, + slash_brightness: 255, + slash_interval: 0, + slash_mode: SlashMode::Bounce as u8, + } + } +} +impl StdConfig for SlashConfig { + fn new() -> Self { + Self::default() + } + + fn file_name(&self) -> String { + CONFIG_FILE.to_owned() + } + + fn config_dir() -> std::path::PathBuf { + std::path::PathBuf::from(crate::CONFIG_PATH_BASE) + } +} + +impl StdConfigLoad for SlashConfig {} + +impl From<&SlashConfig> for DeviceState { + fn from(config: &SlashConfig) -> Self { + DeviceState { + slash_enabled: config.slash_enabled, + slash_brightness: config.slash_brightness, + slash_interval: config.slash_interval, + slash_mode: config.slash_mode, + } + } +} \ No newline at end of file diff --git a/asusd/src/ctrl_slash/mod.rs b/asusd/src/ctrl_slash/mod.rs new file mode 100644 index 00000000..c571468e --- /dev/null +++ b/asusd/src/ctrl_slash/mod.rs @@ -0,0 +1,100 @@ +pub mod config; +pub mod trait_impls; + +use rog_platform::hid_raw::HidRaw; +use rog_platform::usb_raw::USBRaw; +use rog_slash::{SlashMode}; +use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; +use crate::ctrl_slash::config::SlashConfig; +use crate::error::RogError; + +enum Node { + Usb(USBRaw), + Hid(HidRaw), +} + +impl Node { + pub fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> { + // TODO: map and pass on errors + match self { + Node::Usb(u) => { + u.write_bytes(message).ok(); + } + Node::Hid(h) => { + h.write_bytes(message).ok(); + } + } + Ok(()) + } + + // pub fn set_builtins_enabled(&self, enabled: bool) -> Result<(), SlashCtlError> { + // self.write_bytes(&pkt_set_enable_powersave_anim(enabled))?; + // self.write_bytes(&pkt_set_enable_display(enabled))?; + // self.write_bytes(&pkt_set_brightness(bright))?; + // self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) + // Ok(()) + // } +} + +#[derive(Clone)] +pub struct CtrlSlash { + // node: HidRaw, + node: Node, + config: SlashConfig, + // slash_type: SlashType, + // // set to force thread to exit + // thread_exit: Arc, + // // Set to false when the thread exits + // thread_running: Arc, +} + +impl CtrlSlash { + #[inline] + pub fn new(config: SlashConfig) -> Result { + let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok(); + let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok(); + let node = if usb.is_some() { + unsafe { Node::Usb(usb.unwrap_unchecked()) } + } else if hid.is_some() { + unsafe { Node::Hid(hid.unwrap_unchecked().0) } + } else { + return Err(RogError::NotSupported); + }; + + // Maybe, detecting the slash-type may become necessary + // let slash_type = get_slash_type()?; + + let ctrl = CtrlSlash { + node, + config, + // slash_type, + // thread_exit: Arc::new(AtomicBool::new(false)), + // thread_running: Arc::new(AtomicBool::new(false)), + }; + ctrl.do_initialization()?; + + Ok(ctrl) + } + + fn do_initialization(&self) -> Result<(), RogError> { + + let init_packets = pkts_for_init(); + self.node.write_bytes(&init_packets[0])?; + self.node.write_bytes(&init_packets[1])?; + + Ok(()) + } + + pub fn set_options(&self, enabled: bool, brightness: u8, interval: u8) -> Result<(), RogError> { + let command_packets = pkt_set_options(enabled, brightness, interval); + self.node.write_bytes(&command_packets)?; + Ok(()) + } + + pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), RogError> { + let command_packets = pkt_set_mode(slash_mode as u8); + self.node.write_bytes(&command_packets[0])?; + self.node.write_bytes(&command_packets[1])?; + Ok(()) + } +} \ No newline at end of file diff --git a/asusd/src/ctrl_slash/trait_impls.rs b/asusd/src/ctrl_slash/trait_impls.rs new file mode 100644 index 00000000..39e7afec --- /dev/null +++ b/asusd/src/ctrl_slash/trait_impls.rs @@ -0,0 +1,94 @@ +use std::sync::Arc; +use log::warn; +use zbus::{Connection, interface}; +use zbus::export::futures_util::lock::Mutex; +use config_traits::StdConfig; +use rog_slash::DeviceState; +use rog_slash::usb::pkt_set_options; +use crate::ctrl_slash::CtrlSlash; + + +pub const SLASH_ZBUS_NAME: &str = "Slash"; +pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux"; + +#[derive(Clone)] +pub struct CtrlSlashZbus(pub Arc>); + + +/// The struct with the main dbus methods requires this trait +impl crate::ZbusRun for CtrlSlashZbus { + async fn add_to_server(self, server: &mut Connection) { + Self::add_to_server_helper(self, SLASH_ZBUS_NAME, server).await; + } +} + + +// None of these calls can be guarnateed to succeed unless we loop until okay +// If the try_lock *does* succeed then any other thread trying to lock will not +// grab it until we finish. +#[interface(name = "org.asuslinux.Slash")] +impl CtrlSlashZbus { + // /// Writes a data stream of length. Will force system thread to exit until + // /// it is restarted + // async fn write(&self, input: AnimeDataBuffer) -> zbus::fdo::Result<()> { + // let lock = self.0.lock().await; + // lock.thread_exit.store(true, Ordering::SeqCst); + // lock.write_data_buffer(input).map_err(|err| { + // warn!("ctrl_anime::run_animation:callback {}", err); + // err + // })?; + // Ok(()) + // } + + /// Set base brightness level + #[zbus(property)] + async fn brightness(&self) -> u8 { + let lock = self.0.lock().await; + lock.config.slash_brightness + } + + /// Set base brightness level + #[zbus(property)] + async fn set_brightness(&self, brightness: u8) { + let mut lock = self.0.lock().await; + let enabled = brightness > 0; + lock.node + .write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_enabled = enabled; + lock.config.slash_brightness = brightness; + lock.config.write(); + } + + #[zbus(property)] + async fn enable_display(&self) -> bool { + let lock = self.0.lock().await; + lock.config.slash_enabled + } + + /// Set whether the AniMe is enabled at all + #[zbus(property)] + async fn set_enable_display(&self, enabled: bool) { + let mut lock = self.0.lock().await; + lock.node + .write_bytes(&pkt_set_options(enabled, lock.config.slash_brightness, lock.config.slash_interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_enabled = enabled; + lock.config.write(); + } + + /// Get the device state as stored by asusd + // #[zbus(property)] + async fn device_state(&self) -> DeviceState { + let lock = self.0.lock().await; + DeviceState::from(&lock.config) + } +} \ No newline at end of file diff --git a/asusd/src/daemon.rs b/asusd/src/daemon.rs index e6d09984..38d485ef 100644 --- a/asusd/src/daemon.rs +++ b/asusd/src/daemon.rs @@ -12,9 +12,12 @@ use asusd::ctrl_aura::manager::AuraManager; use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_platform::CtrlPlatform; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; -use config_traits::{StdConfig, StdConfigLoad2, StdConfigLoad3}; +use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2, StdConfigLoad3}; use log::{error, info}; use zbus::fdo::ObjectManager; +use asusd::ctrl_slash::config::SlashConfig; +use asusd::ctrl_slash::CtrlSlash; +use asusd::ctrl_slash::trait_impls::CtrlSlashZbus; #[tokio::main] async fn main() -> Result<(), Box> { @@ -41,6 +44,7 @@ async fn main() -> Result<(), Box> { info!(" daemon v{}", asusd::VERSION); info!(" rog-anime v{}", rog_anime::VERSION); + info!(" rog-slash v{}", rog_slash::VERSION); info!(" rog-aura v{}", rog_aura::VERSION); info!(" rog-profiles v{}", rog_profiles::VERSION); info!("rog-platform v{}", rog_platform::VERSION); @@ -104,6 +108,16 @@ async fn start_daemon() -> Result<(), Box> { } } + match CtrlSlash::new(SlashConfig::new().load()) { + Ok(ctrl) => { + let sig_ctx = CtrlPlatform::signal_context(&connection)?; + start_tasks(ctrl, &mut connection, sig_ctx).await?; + } + Err(err) => { + info!("Slash control: {}", err); + } + } + let _ = AuraManager::new(connection.clone()).await?; // Request dbus name after finishing initalizing all functions diff --git a/asusd/src/lib.rs b/asusd/src/lib.rs index aaeff5fc..16f21e6f 100644 --- a/asusd/src/lib.rs +++ b/asusd/src/lib.rs @@ -3,6 +3,8 @@ pub mod config; /// Control of anime matrix display pub mod ctrl_anime; +/// Control of anime slash led bar +pub mod ctrl_slash; /// Keyboard LED brightness control, RGB, and LED display modes pub mod ctrl_aura; /// Control platform profiles + fan-curves if available diff --git a/rog-control-center/src/config.rs b/rog-control-center/src/config.rs index c8a52d47..7a39b40b 100644 --- a/rog-control-center/src/config.rs +++ b/rog-control-center/src/config.rs @@ -50,6 +50,10 @@ impl StdConfig for Config { } } + fn file_name(&self) -> String { + CFG_FILE_NAME.to_owned() + } + fn config_dir() -> std::path::PathBuf { let mut path = dirs::config_dir().unwrap_or_default(); @@ -62,10 +66,6 @@ impl StdConfig for Config { } path } - - fn file_name(&self) -> String { - CFG_FILE_NAME.to_owned() - } } impl StdConfigLoad1 for Config {} diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index fbda2320..325c378b 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -35,14 +35,10 @@ fn main() -> Result<()> { let is_rog_ally = prod_family == "RC71L"; // tmp-dir must live to the end of program life - let _tmp_dir = match tempfile::Builder::new() + let _tmp_dir = tempfile::Builder::new() .prefix("rog-gui") .rand_bytes(0) - .tempdir() - { - Ok(tmp) => tmp, - Err(_) => on_tmp_dir_exists().unwrap(), - }; + .tempdir().unwrap_or_else(|_| on_tmp_dir_exists().unwrap()); let args: Vec = args().skip(1).collect(); @@ -76,13 +72,10 @@ fn main() -> Result<()> { }) .unwrap(); - let supported_properties = match dbus.proxies().platform().supported_properties() { - Ok(s) => s, - Err(_e) => { - // TODO: show an error window - Vec::default() - } - }; + let supported_properties = dbus.proxies().platform().supported_properties().unwrap_or_else(|_e| { + // TODO: show an error window + Vec::default() + }); // Startup let mut config = Config::new().load(); diff --git a/rog-dbus/Cargo.toml b/rog-dbus/Cargo.toml index d366edb1..d6f74c7f 100644 --- a/rog-dbus/Cargo.toml +++ b/rog-dbus/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" [dependencies] asusd = { path = "../asusd" } rog_anime = { path = "../rog-anime", features = ["dbus"] } +rog_slash = { path = "../rog-slash", features = ["dbus"] } rog_aura = { path = "../rog-aura" } rog_profiles = { path = "../rog-profiles" } rog_platform = { path = "../rog-platform" } diff --git a/rog-dbus/src/lib.rs b/rog-dbus/src/lib.rs index 0059de43..13e6ccd9 100644 --- a/rog-dbus/src/lib.rs +++ b/rog-dbus/src/lib.rs @@ -1,8 +1,10 @@ pub use asusd::{DBUS_IFACE, DBUS_NAME, DBUS_PATH}; + pub mod zbus_anime; pub mod zbus_aura; pub mod zbus_fan_curves; pub mod zbus_platform; +pub mod zbus_slash; // use rog_anime::AnimePowerStates; // use rog_aura::{AuraEffect, LedPowerStates}; @@ -14,6 +16,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub struct DbusProxiesBlocking<'a> { anime: zbus_anime::AnimeProxyBlocking<'a>, + slash: zbus_slash::SlashProxyBlocking<'a>, led: zbus_aura::AuraProxyBlocking<'a>, profile: zbus_fan_curves::FanCurvesProxyBlocking<'a>, rog_bios: zbus_platform::PlatformProxyBlocking<'a>, @@ -27,6 +30,7 @@ impl<'a> DbusProxiesBlocking<'a> { Ok(( DbusProxiesBlocking { anime: zbus_anime::AnimeProxyBlocking::new(&conn)?, + slash: zbus_slash::SlashProxyBlocking::new(&conn)?, led: zbus_aura::AuraProxyBlocking::new(&conn)?, profile: zbus_fan_curves::FanCurvesProxyBlocking::new(&conn)?, rog_bios: zbus_platform::PlatformProxyBlocking::new(&conn)?, @@ -38,15 +42,13 @@ impl<'a> DbusProxiesBlocking<'a> { pub fn anime(&self) -> &zbus_anime::AnimeProxyBlocking<'a> { &self.anime } - + pub fn slash(&self) -> &zbus_slash::SlashProxyBlocking<'a> { &self.slash } 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 } @@ -71,6 +73,7 @@ impl<'a> RogDbusClientBlocking<'a> { pub struct DbusProxies<'a> { anime: zbus_anime::AnimeProxy<'a>, + slash: zbus_slash::SlashProxy<'a>, led: zbus_aura::AuraProxy<'a>, profile: zbus_fan_curves::FanCurvesProxy<'a>, rog_bios: zbus_platform::PlatformProxy<'a>, @@ -84,6 +87,7 @@ impl<'a> DbusProxies<'a> { Ok(( DbusProxies { anime: zbus_anime::AnimeProxy::new(&conn).await?, + slash: zbus_slash::SlashProxy::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?, @@ -95,6 +99,7 @@ impl<'a> DbusProxies<'a> { pub fn anime(&self) -> &zbus_anime::AnimeProxy<'a> { &self.anime } + pub fn slash(&self) -> &zbus_slash::SlashProxy<'a> { &self.slash } pub fn led(&self) -> &zbus_aura::AuraProxy<'a> { &self.led diff --git a/rog-dbus/src/zbus_slash.rs b/rog-dbus/src/zbus_slash.rs new file mode 100644 index 00000000..f0104a29 --- /dev/null +++ b/rog-dbus/src/zbus_slash.rs @@ -0,0 +1,35 @@ +use zbus::proxy; + +#[proxy( +interface = "org.asuslinux.Slash", +default_service = "org.asuslinux.Daemon", +default_path = "/org/asuslinux" +)] +trait Slash { + /// RunMainLoop method + fn run_main_loop(&self, start: bool) -> zbus::Result<()>; + + /// Brightness property + #[zbus(property)] + fn brightness(&self) -> zbus::Result; + #[zbus(property)] + fn set_brightness(&self, value: u8) -> zbus::Result<()>; + + /// Interval property + #[zbus(property)] + fn interval(&self) -> zbus::Result; + #[zbus(property)] + fn set_interval(&self, value: u8) -> zbus::Result<()>; + + /// BuiltinAnimations property + #[zbus(property)] + fn current_mode(&self) -> zbus::Result; + #[zbus(property)] + fn set_current_mode(&self, value: u8) -> zbus::Result<()>; + + /// EnableDisplay property + #[zbus(property)] + fn enable_display(&self) -> zbus::Result; + #[zbus(property)] + fn set_enable_display(&self, value: bool) -> zbus::Result<()>; +} diff --git a/rog-platform/src/usb_raw.rs b/rog-platform/src/usb_raw.rs index 9670959d..9b853395 100644 --- a/rog-platform/src/usb_raw.rs +++ b/rog-platform/src/usb_raw.rs @@ -11,9 +11,11 @@ impl USBRaw { pub fn new(id_product: u16) -> Result { for device in rusb::devices()?.iter() { let device_desc = device.device_descriptor()?; - if device_desc.vendor_id() == 0x0b05 && device_desc.product_id() == id_product { - let handle = Self::get_dev_handle(&device)?; - return Ok(Self(handle)); + if device_desc.vendor_id() == 0x0b05 { + if device_desc.product_id() == id_product { + let handle = Self::get_dev_handle(&device)?; + return Ok(Self(handle)); + } } } @@ -27,11 +29,16 @@ impl USBRaw { device: &Device, ) -> Result> { // We don't expect this ID to ever change - let mut device = device.open()?; - device.reset()?; - device.set_auto_detach_kernel_driver(true)?; - device.claim_interface(0)?; - Ok(device) + let device_open = device.open(); + if let Err(err) = device_open { + panic!("Could not open device, try running as root: {}", err); + } else { + let mut device = device_open.unwrap(); + device.reset()?; + device.set_auto_detach_kernel_driver(true)?; + device.claim_interface(0)?; + Ok(device) + } } pub fn write_bytes(&self, message: &[u8]) -> Result { diff --git a/rog-slash/Cargo.toml b/rog-slash/Cargo.toml index 4f5864a2..4c2a21b8 100644 --- a/rog-slash/Cargo.toml +++ b/rog-slash/Cargo.toml @@ -2,28 +2,39 @@ name = "rog_slash" license = "MPL-2.0" version.workspace = true -readme = "README.md" authors = ["Luke "] repository = "https://gitlab.com/asus-linux/asus-nb-ctrl" homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl" -documentation = "https://docs.rs/rog-anime" +documentation = "https://docs.rs/rog-slash" description = "ASUS Slash display" keywords = ["ROG", "ASUS", "AniMe", "Slash"] -edition = "2024" +edition = "2021" exclude = ["data"] +[features] +default = ["dbus", "detect"] +dbus = ["zbus"] +detect = ["dmi_id"] + +[lib] +name = "rog_slash" +path = "src/lib.rs" + [dependencies] +png_pong.workspace = true +pix.workspace = true +gif.workspace = true log.workspace = true + serde.workspace = true serde_derive.workspace = true -zbus.workspace = true -concat-idents.workspace = true -udev.workspace = true -inotify.workspace = true + +glam.workspace = true typeshare.workspace = true -rusb.workspace = true +zbus = { workspace = true, optional = true } + +dmi_id = { path = "../dmi-id", optional = true } [dev-dependencies] -cargo-husky.workspace = true -rog_aura = { path = "../rog-aura" } \ No newline at end of file +cargo-husky.workspace = true \ No newline at end of file diff --git a/rog-slash/src/data.rs b/rog-slash/src/data.rs new file mode 100644 index 00000000..19e64da5 --- /dev/null +++ b/rog-slash/src/data.rs @@ -0,0 +1,105 @@ +use std::str::FromStr; + +use serde_derive::{Deserialize, Serialize}; +use typeshare::typeshare; +#[cfg(feature = "dbus")] +use zbus::zvariant::Type; + +use crate::error::SlashError; + +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub enum SlashType { + GA403, + Unknown, +} + +impl FromStr for SlashType { + type Err = SlashError; + fn from_str(s: &str) -> std::result::Result { + Ok(match s { + "ga403" | "GA403" => Self::GA403, + _ => Self::Unknown, + }) + } +} + +#[typeshare] +// #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum SlashMode { + Bounce = 0x10, + Slash = 0x12, + Loading = 0x13, + BitStream = 0x1D, + Transmission = 0x1A, + Flow = 0x19, + Flux = 0x25, + Phantom = 0x24, + Spectrum = 0x26, + Hazard = 0x32, + Interfacing = 0x33, + Ramp = 0x34, + GameOver = 0x42, + Start = 0x43, + Buzzer = 0x44, +} + +impl SlashMode { + pub const fn to_string(&self) -> &str + { + match &self { + SlashMode::Bounce => "Bounce", + SlashMode::Slash => "Slash", + SlashMode::Loading => "Loading", + SlashMode::BitStream => "BitStream", + SlashMode::Transmission => "Transmission", + SlashMode::Flow => "Flow", + SlashMode::Flux => "Flux", + SlashMode::Phantom => "Phantom", + SlashMode::Spectrum => "Spectrum", + SlashMode::Hazard => "Hazard", + SlashMode::Interfacing => "Interfacing", + SlashMode::Ramp => "Ramp", + SlashMode::GameOver => "GameOver", + SlashMode::Start => "Start", + SlashMode::Buzzer => "Buzzer", + } + } + + pub const fn list() -> [&'static str; 15] { + [ + SlashMode::Bounce.to_string(), + SlashMode::Slash.to_string(), + SlashMode::Loading.to_string(), + SlashMode::BitStream.to_string(), + SlashMode::Transmission.to_string(), + SlashMode::Flow.to_string(), + SlashMode::Flux.to_string(), + SlashMode::Phantom.to_string(), + SlashMode::Spectrum.to_string(), + SlashMode::Hazard.to_string(), + SlashMode::Interfacing.to_string(), + SlashMode::Ramp.to_string(), + SlashMode::GameOver.to_string(), + SlashMode::Start.to_string(), + SlashMode::Buzzer.to_string(), + ] + } +} + + + +// TODO: move this out +#[typeshare] +#[cfg_attr(feature = "dbus", derive(Type))] +#[typeshare] +#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] +pub struct DeviceState { + pub slash_enabled: bool, + pub slash_brightness: u8, + pub slash_interval: u8, + pub slash_mode: u8, +} + diff --git a/rog-slash/src/error.rs b/rog-slash/src/error.rs new file mode 100644 index 00000000..af2e0fb6 --- /dev/null +++ b/rog-slash/src/error.rs @@ -0,0 +1,39 @@ +use std::error::Error; +use std::fmt; +pub type Result = std::result::Result; + +#[derive(Debug)] +pub enum SlashError { + Dbus(String), + Udev(String, std::io::Error), + NoDevice, + UnsupportedDevice, + DataBufferLength, + ParseError(String), +} + +impl fmt::Display for SlashError { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + SlashError::ParseError(e) => write!(f, "Could not parse {e}"), + SlashError::Dbus(detail) => write!(f, "{}", detail), + SlashError::Udev(deets, error) => write!(f, "udev {}: {}", deets, error), + SlashError::NoDevice => write!(f, "No Slash device found"), + SlashError::DataBufferLength => write!( + f, + "The data buffer was incorrect length for generating USB packets" + ), + SlashError::UnsupportedDevice => write!(f, "Unsupported Slash device found"), + } + } +} + +impl Error for SlashError {} + +impl From for zbus::fdo::Error { + #[inline] + fn from(err: SlashError) -> Self { + zbus::fdo::Error::Failed(format!("{}", err)) + } +} diff --git a/rog-slash/src/lib.rs b/rog-slash/src/lib.rs index ffb4a0c5..3a50da90 100644 --- a/rog-slash/src/lib.rs +++ b/rog-slash/src/lib.rs @@ -1,3 +1,12 @@ +/// The main data conversion for transfering in shortform over dbus or other, +/// or writing directly to the USB device +mod data; +pub use data::*; + +/// Base errors that are possible +pub mod error; /// Provides const methods to create the USB HID control packets -pub mod usb; \ No newline at end of file +pub mod usb; + +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); \ No newline at end of file diff --git a/rog-slash/src/usb.rs b/rog-slash/src/usb.rs index d0dcc9ca..38aabc49 100644 --- a/rog-slash/src/usb.rs +++ b/rog-slash/src/usb.rs @@ -1,345 +1,129 @@ -//! Utils for writing to the `AniMe` USB device +//! Utils for writing to the `Slash` USB device //! //! Use of the device requires a few steps: //! 1. Initialise the device by writing the two packets from -//! `get_init_packets()` 2. Write data from `AnimePacketType` +//! `get_init_packets()` 2. Write data from `SLashPacketType` //! 3. Write the packet from `get_flush_packet()`, which tells the device to //! display the data from step 2 //! -//! Step 1 need to applied only on fresh system boot. - -use std::str::FromStr; +//! Step 1 needs to be applied only on fresh system boot. use dmi_id::DMIID; -use serde_derive::{Deserialize, Serialize}; -use typeshare::typeshare; #[cfg(feature = "dbus")] -use zbus::zvariant::{OwnedValue, Type, Value}; +use crate::error::SlashError; +use crate::SlashType; -use crate::error::AnimeError; -use crate::AnimeType; - -const PACKET_SIZE: usize = 640; +const PACKET_SIZE: usize = 128; const DEV_PAGE: u8 = 0x5e; -pub const VENDOR_ID: u16 = 0x0b05; -pub const PROD_ID: u16 = 0x193b; +pub const VENDOR_ID: u16 = 0x0B05; +pub const PROD_ID: u16 = 0x193B; +pub const PROD_ID_STR: &str = "193B"; -#[cfg_attr( -feature = "dbus", -derive(Type, Value, OwnedValue), -zvariant(signature = "u") -)] -#[typeshare] -#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] -/// Base LED brightness of the display -pub enum Brightness { - Off = 0, - Low = 1, - #[default] - Med = 2, - High = 3, -} +pub type SlashUsbPacket = [u8;PACKET_SIZE]; -impl FromStr for Brightness { - type Err = AnimeError; - - fn from_str(s: &str) -> Result { - Ok(match s { - "Off" | "off" => Brightness::Off, - "Low" | "low" => Brightness::Low, - "Med" | "med" => Brightness::Med, - "High" | "high" => Brightness::High, - _ => Brightness::Med, - }) - } -} - -impl From for Brightness { - fn from(v: u8) -> Brightness { - match v { - 0 => Brightness::Off, - 1 => Brightness::Low, - 3 => Brightness::High, - _ => Brightness::Med, - } - } -} - -impl From for Brightness { - fn from(v: i32) -> Brightness { - (v as u8).into() - } -} - -impl From for i32 { - fn from(v: Brightness) -> i32 { - v as i32 - } -} - -#[cfg_attr( -feature = "dbus", -derive(Type, Value, OwnedValue), -zvariant(signature = "s") -)] -#[typeshare] -#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] -pub enum AnimBooting { - #[default] - GlitchConstruction = 0, - StaticEmergence = 1, -} - -impl FromStr for AnimBooting { - type Err = AnimeError; - - fn from_str(s: &str) -> Result { - match s { - "GlitchConstruction" => Ok(Self::GlitchConstruction), - "StaticEmergence" => Ok(Self::StaticEmergence), - _ => Err(AnimeError::ParseError(s.to_owned())), - } - } -} - -impl From for AnimBooting { - fn from(value: i32) -> Self { - match value { - 0 => Self::GlitchConstruction, - 1 => Self::StaticEmergence, - _ => Self::default(), - } - } -} - -impl From for i32 { - fn from(value: AnimBooting) -> Self { - value as i32 - } -} - -#[cfg_attr( -feature = "dbus", -derive(Type, Value, OwnedValue), -zvariant(signature = "s") -)] -#[typeshare] -#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] -pub enum AnimAwake { - #[default] - BinaryBannerScroll = 0, - RogLogoGlitch = 1, -} - -impl FromStr for AnimAwake { - type Err = AnimeError; - - fn from_str(s: &str) -> Result { - match s { - "BinaryBannerScroll" => Ok(Self::BinaryBannerScroll), - "RogLogoGlitch" => Ok(Self::RogLogoGlitch), - _ => Err(AnimeError::ParseError(s.to_owned())), - } - } -} - -impl From for AnimAwake { - fn from(value: i32) -> Self { - match value { - 0 => Self::BinaryBannerScroll, - 1 => Self::RogLogoGlitch, - _ => Self::default(), - } - } -} - -impl From for i32 { - fn from(value: AnimAwake) -> Self { - value as i32 - } -} - -#[cfg_attr( -feature = "dbus", -derive(Type, Value, OwnedValue), -zvariant(signature = "s") -)] -#[typeshare] -#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] -pub enum AnimSleeping { - #[default] - BannerSwipe = 0, - Starfield = 1, -} - -impl FromStr for AnimSleeping { - type Err = AnimeError; - - fn from_str(s: &str) -> Result { - match s { - "BannerSwipe" => Ok(Self::BannerSwipe), - "Starfield" => Ok(Self::Starfield), - _ => Err(AnimeError::ParseError(s.to_owned())), - } - } -} - -impl From for AnimSleeping { - fn from(value: i32) -> Self { - match value { - 0 => Self::BannerSwipe, - 1 => Self::Starfield, - _ => Self::default(), - } - } -} - -impl From for i32 { - fn from(value: AnimSleeping) -> Self { - value as i32 - } -} - -#[cfg_attr( -feature = "dbus", -derive(Type, Value, OwnedValue), -zvariant(signature = "s") -)] -#[typeshare] -#[derive(Debug, Default, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] -pub enum AnimShutdown { - #[default] - GlitchOut = 0, - SeeYa = 1, -} - -impl FromStr for AnimShutdown { - type Err = AnimeError; - - fn from_str(s: &str) -> Result { - match s { - "GlitchOut" => Ok(Self::GlitchOut), - "SeeYa" => Ok(Self::SeeYa), - _ => Err(AnimeError::ParseError(s.to_owned())), - } - } -} - -impl From for AnimShutdown { - fn from(value: i32) -> Self { - match value { - 0 => Self::GlitchOut, - 1 => Self::SeeYa, - _ => Self::default(), - } - } -} - -impl From for i32 { - fn from(value: AnimShutdown) -> Self { - value as i32 - } -} /// `get_anime_type` is very broad, matching on part of the laptop board name /// only. For this reason `find_node()` must be used also to verify if the USB /// device is available. /// -/// The currently known USB device is `19b6`. +/// The currently known USB device is `193B`. #[inline] -pub fn get_anime_type() -> Result { - let dmi = DMIID::new().map_err(|_| AnimeError::NoDevice)?; // TODO: better error +pub fn get_slash_type() -> Result { + let dmi = DMIID::new().map_err(|_| SlashError::NoDevice)?; // TODO: better error let board_name = dmi.board_name; - if board_name.contains("GA401I") || board_name.contains("GA401Q") { - return Ok(AnimeType::GA401); - } else if board_name.contains("GA402R") { - return Ok(AnimeType::GA402); - } else if board_name.contains("GU604V") { - return Ok(AnimeType::GU604); + if board_name.contains("GA403") { + return Ok(SlashType::GA403); } - log::warn!("AniMe Matrix device found but not yet supported, will default to a GA402 layout"); - Ok(AnimeType::Unknown) + log::warn!("AniMe Slash device found but not yet supported, will default to a GA403 layout"); + Ok(SlashType::Unknown) } /// Get the two device initialization packets. These are required for device /// start after the laptop boots. #[inline] -pub const fn pkts_for_init() -> [[u8; PACKET_SIZE]; 2] { - let mut packets = [[0; PACKET_SIZE]; 2]; - packets[0][0] = DEV_PAGE; // This is the USB page we're using throughout - let mut count = 0; - // TODO: memcpy or slice copy - let bytes = "ASUS Tech.Inc.".as_bytes(); - while count < bytes.len() { - packets[0][count + 1] = bytes[count]; - count += 1; - } - // - packets[1][0] = DEV_PAGE; - packets[1][1] = 0xc2; - packets +pub const fn pkts_for_init() -> [SlashUsbPacket; 2] { + let mut pkt1 = [0;PACKET_SIZE]; + pkt1[0] = DEV_PAGE; + pkt1[1] = 0xD7; + pkt1[2] = 0x00; + pkt1[3] = 0x00; + pkt1[4] = 0x01; + pkt1[5] = 0xAC; + + let mut pkt2 = [0;PACKET_SIZE]; + pkt2[0] = DEV_PAGE; + pkt2[1] = 0xD2; + pkt2[2] = 0x02; + pkt2[3] = 0x01; + pkt2[4] = 0x08; + pkt2[5] = 0xAB; + + [pkt1, pkt2] } -/// Should be written to the device after writing the two main data packets that -/// make up the display data packet #[inline] -pub const fn pkt_flush() -> [u8; PACKET_SIZE] { - let mut pkt = [0; PACKET_SIZE]; +pub const fn pkt_save() -> SlashUsbPacket { + let mut pkt = [0;PACKET_SIZE]; pkt[0] = DEV_PAGE; - pkt[1] = 0xc0; + pkt[1] = 0xD4; + pkt[2] = 0x00; + pkt[3] = 0x00; + pkt[4] = 0x01; + pkt[5] = 0xAB; + + pkt +} + +#[inline] +pub const fn pkt_set_mode(mode: u8) -> [SlashUsbPacket; 2] { + let mut pkt1 = [0;PACKET_SIZE]; + pkt1[0] = DEV_PAGE; + pkt1[1] = 0x02; + pkt1[2] = 0x03; + pkt1[3] = 0x00; + pkt1[4] = 0x0C; + + let mut pkt2 = [0;PACKET_SIZE]; + pkt2[0] = DEV_PAGE; + pkt2[1] = 0xD3; + pkt2[2] = 0x04; + pkt2[3] = 0x00; + pkt2[4] = 0x0C; + pkt2[5] = 0x01; + pkt2[6] = mode; + pkt2[7] = 0x02; + pkt2[8] = 0x19; + pkt2[9] = 0x03; + pkt2[10] = 0x13; + pkt2[11] = 0x04; + pkt2[12] = 0x11; + pkt2[13] = 0x05; + pkt2[14] = 0x12; + pkt2[15] = 0x06; + pkt2[16] = 0x13; + + [pkt1, pkt2] +} + +#[inline] +pub const fn pkt_set_options(enabled: bool, brightness: u8, interval: u8) -> SlashUsbPacket { + let status_byte = if enabled { 0x01 } else { 0x00 }; + + let mut pkt = [0;PACKET_SIZE]; + pkt[0] = DEV_PAGE; + pkt[1] = 0xD3; pkt[2] = 0x03; - pkt -} + pkt[3] = 0x01; + pkt[4] = 0x08; + pkt[5] = 0xAB; + pkt[6] = 0xFF; + pkt[7] = 0x01; + pkt[8] = status_byte; + pkt[9] = 0x06; + pkt[10] = brightness; + pkt[11] = 0xFF; + pkt[12] = interval; -/// Packet for setting the brightness (0-3). Requires -/// `pkt_for_apply()` to be written after. -#[inline] -pub const fn pkt_set_brightness(brightness: Brightness) -> [u8; PACKET_SIZE] { - let mut pkt = [0; PACKET_SIZE]; - pkt[0] = DEV_PAGE; - pkt[1] = 0xc0; - pkt[2] = 0x04; - pkt[3] = brightness as u8; - pkt -} - -/// Enable the display? -#[inline] -pub const fn pkt_set_enable_display(status: bool) -> [u8; PACKET_SIZE] { - let mut pkt = [0; PACKET_SIZE]; - pkt[0] = DEV_PAGE; - pkt[1] = 0xc3; - pkt[2] = 0x01; - pkt[3] = if status { 0x00 } else { 0x80 }; - pkt -} - -/// Enable builtin animations? -#[inline] -pub const fn pkt_set_enable_powersave_anim(status: bool) -> [u8; PACKET_SIZE] { - let mut pkt = [0; PACKET_SIZE]; - pkt[0] = DEV_PAGE; - pkt[1] = 0xc4; - pkt[2] = 0x01; - pkt[3] = if status { 0x00 } else { 0x80 }; - pkt -} - -/// Set which animations are shown for each stage -#[inline] -pub const fn pkt_set_builtin_animations( - boot: AnimBooting, - awake: AnimAwake, - sleep: AnimSleeping, - shutdown: AnimShutdown, -) -> [u8; PACKET_SIZE] { - let mut pkt = [0; PACKET_SIZE]; - pkt[0] = DEV_PAGE; - pkt[1] = 0xc5; - pkt[2] = (awake as u8) - | ((sleep as u8) << 0x01) - | ((shutdown as u8) << 0x02) - | ((boot as u8) << 0x03); pkt } diff --git a/slashctl/Cargo.toml b/slashctl/Cargo.toml new file mode 100644 index 00000000..fb85f31b --- /dev/null +++ b/slashctl/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "slashctl" +license = "MPL-2.0" +version.workspace = true +authors = ["Luke "] +repository = "https://gitlab.com/asus-linux/asus-nb-ctrl" +homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl" +description = "A ctrl app to control the Asus Slash" +edition = "2021" + +[dependencies] +rog_slash = { path = "../rog-slash" } +rog_platform = { path = "../rog-platform" } +rog_profiles = { path = "../rog-profiles" } +dmi_id = { path = "../dmi-id" } +futures-lite = "*" +udev.workspace = true +inotify.workspace = true \ No newline at end of file diff --git a/slashctl/src/ctrl_slash/mod.rs b/slashctl/src/ctrl_slash/mod.rs new file mode 100644 index 00000000..00c1db97 --- /dev/null +++ b/slashctl/src/ctrl_slash/mod.rs @@ -0,0 +1,94 @@ +use rog_platform::hid_raw::HidRaw; +use rog_platform::usb_raw::USBRaw; +use rog_slash::{SlashMode}; +use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; + +use crate::error::SlashCtlError; + +enum Node { + Usb(USBRaw), + Hid(HidRaw), +} + +impl Node { + pub fn write_bytes(&self, message: &[u8]) -> Result<(), SlashCtlError> { + // TODO: map and pass on errors + match self { + Node::Usb(u) => { + u.write_bytes(message).ok(); + } + Node::Hid(h) => { + h.write_bytes(message).ok(); + } + } + Ok(()) + } + + // pub fn set_builtins_enabled(&self, enabled: bool) -> Result<(), SlashCtlError> { + // self.write_bytes(&pkt_set_enable_powersave_anim(enabled))?; + // self.write_bytes(&pkt_set_enable_display(enabled))?; + // self.write_bytes(&pkt_set_brightness(bright))?; + // self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) + // Ok(()) + // } +} + +pub struct CtrlSlash { + // node: HidRaw, + node: Node, + // slash_type: SlashType, + // // set to force thread to exit + // thread_exit: Arc, + // // Set to false when the thread exits + // thread_running: Arc, +} + +impl CtrlSlash { + #[inline] + pub fn new() -> Result { + let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok(); + let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok(); + let node = if usb.is_some() { + unsafe { Node::Usb(usb.unwrap_unchecked()) } + } else if hid.is_some() { + unsafe { Node::Hid(hid.unwrap_unchecked().0) } + } else { + return Err(SlashCtlError::NotSupported); + }; + + // Maybe, detecting the slash-type may become necessary + // let slash_type = get_slash_type()?; + + let ctrl = CtrlSlash { + node, + // slash_type, + // thread_exit: Arc::new(AtomicBool::new(false)), + // thread_running: Arc::new(AtomicBool::new(false)), + }; + ctrl.do_initialization()?; + + Ok(ctrl) + } + + fn do_initialization(&self) -> Result<(), SlashCtlError> { + + let init_packets = pkts_for_init(); + self.node.write_bytes(&init_packets[0])?; + self.node.write_bytes(&init_packets[1])?; + + Ok(()) + } + + pub fn set_options(&self, enabled: bool, brightness: u8, interval: u8) -> Result<(), SlashCtlError> { + let command_packets = pkt_set_options(enabled, brightness, interval); + self.node.write_bytes(&command_packets)?; + Ok(()) + } + + pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), SlashCtlError> { + let command_packets = pkt_set_mode(slash_mode as u8); + self.node.write_bytes(&command_packets[0])?; + self.node.write_bytes(&command_packets[1])?; + Ok(()) + } +} \ No newline at end of file diff --git a/slashctl/src/error.rs b/slashctl/src/error.rs new file mode 100644 index 00000000..f32cdb14 --- /dev/null +++ b/slashctl/src/error.rs @@ -0,0 +1,30 @@ +use std::fmt; +use std::fmt::{Display}; +use rog_slash::error::SlashError; + +#[derive(Debug)] +pub enum SlashCtlError { + NotSupported, + Slash(SlashError), +} + + +impl Display for SlashCtlError { + // This trait requires `fmt` with this exact signature. + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + SlashCtlError::NotSupported => write!(f, "Not supported"), + SlashCtlError::Slash(err) => write!(f, "Slash error: {}", err), + } + } +} + +impl std::error::Error for SlashCtlError {} + + + +impl From for SlashCtlError { + fn from(err: SlashError) -> Self { + SlashCtlError::Slash(err) + } +} \ No newline at end of file diff --git a/slashctl/src/main.rs b/slashctl/src/main.rs new file mode 100644 index 00000000..cbe682a5 --- /dev/null +++ b/slashctl/src/main.rs @@ -0,0 +1,15 @@ +use crate::ctrl_slash::CtrlSlash; +use crate::error::SlashCtlError; + +mod ctrl_slash; +mod error; + +fn main() -> Result<(), SlashCtlError>{ + // let args: Vec = args().skip(1).collect(); + + let ctrl_slash = CtrlSlash::new()?; + ctrl_slash.set_options(false, 10, 0)?; + // ctrl_slash.set_options(true, 5, 2)?; + // ctrl_slash.set_slash_mode(SlashModes::Flow)?; + Ok(()) +} \ No newline at end of file From 8cdc9773c92f0295984e93b33e38341c30b3e0c4 Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 18:41:31 +0100 Subject: [PATCH 03/13] Added working implementation of the G14 Slash ledstrip --- Cargo.lock | 13 - Cargo.toml | 2 - asusctl/src/main.rs | 17 +- asusctl/src/slash_cli.rs | 9 +- asusd/src/ctrl_platform.rs | 8 + asusd/src/ctrl_slash/config.rs | 7 +- asusd/src/ctrl_slash/mod.rs | 17 +- asusd/src/ctrl_slash/trait_impls.rs | 111 +- asusd/src/daemon.rs | 10 +- asusd/src/error.rs | 9 + asusd/src/lib.rs | 20 +- .../translations/en/rog-control-center.po | 952 +++++++++--------- rog-dbus/src/lib.rs | 4 +- rog-dbus/src/zbus_slash.rs | 27 +- rog-slash/src/data.rs | 40 +- rog-slash/src/usb.rs | 6 +- slashctl/Cargo.toml | 18 - slashctl/src/ctrl_slash/mod.rs | 94 -- slashctl/src/error.rs | 30 - slashctl/src/main.rs | 15 - 20 files changed, 663 insertions(+), 746 deletions(-) delete mode 100644 slashctl/Cargo.toml delete mode 100644 slashctl/src/ctrl_slash/mod.rs delete mode 100644 slashctl/src/error.rs delete mode 100644 slashctl/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 53cad718..c2c0a1b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3903,19 +3903,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slashctl" -version = "6.0.0-alpha1" -dependencies = [ - "dmi_id", - "futures-lite 1.13.0", - "inotify", - "rog_platform", - "rog_profiles", - "rog_slash", - "udev 0.8.0", -] - [[package]] name = "slint" version = "1.5.1" diff --git a/Cargo.toml b/Cargo.toml index 683a12dc..65fa0f39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ [workspace] members = [ "asusctl", - "slashctl", "asusd", "asusd-user", "config-traits", @@ -18,7 +17,6 @@ members = [ ] default-members = [ "asusctl", - "slashctl", "asusd", "asusd-user", "cpuctl", diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 0555325c..5fafaa66 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -467,12 +467,10 @@ fn handle_slash( cmd: &SlashCommand, ) -> Result<(), Box> { if ( - cmd.enable_display.is_none() && + cmd.enabled.is_none() && cmd.brightness.is_none() && cmd.interval.is_none() && - !cmd.list && - !cmd.next && - !cmd.prev + !cmd.list ) || cmd.help { println!("Missing arg or command\n\n{}", cmd.self_usage()); @@ -480,8 +478,8 @@ fn handle_slash( println!("\n{}", lst); } } - if let Some(enable) = cmd.enable_display { - dbus.proxies().slash().set_enable_display(enable)?; + if let Some(enabled) = cmd.enabled { + dbus.proxies().slash().set_enabled(enabled)?; } if let Some(brightness) = cmd.brightness { dbus.proxies().slash().set_brightness(brightness)?; @@ -489,11 +487,8 @@ fn handle_slash( if let Some(interval) = cmd.interval { dbus.proxies().slash().set_interval(interval)?; } - if cmd.next { - dbus.proxies().slash().set_current_mode(SlashMode::Bounce as u8)?; - } - if cmd.prev { - dbus.proxies().slash().set_current_mode(SlashMode::Flow as u8)?; + if let Some(slash_mode) = cmd.slash_mode { + dbus.proxies().slash().set_slash_mode(slash_mode)?; } if cmd.list { let res = SlashMode::list(); diff --git a/asusctl/src/slash_cli.rs b/asusctl/src/slash_cli.rs index 65ba1c45..a2638c47 100644 --- a/asusctl/src/slash_cli.rs +++ b/asusctl/src/slash_cli.rs @@ -1,19 +1,18 @@ use gumdrop::Options; +use rog_slash::SlashMode; #[derive(Options)] pub struct SlashCommand { #[options(help = "print help message")] pub help: bool, #[options(meta = "", help = "enable/disable the display")] - pub enable_display: Option, + pub enabled: Option, #[options(meta = "", help = "set brightness value <0-255>")] pub brightness: Option, #[options(meta = "", help = "set interval value <0-255>")] pub interval: Option, - #[options(help = "toggle to next animation in list")] - pub next: bool, - #[options(help = "toggle to previous animation in list")] - pub prev: bool, + #[options(help = "Set the SlashMode")] + pub slash_mode: Option, #[options(help = "list available animations")] pub list: bool, } \ No newline at end of file diff --git a/asusd/src/ctrl_platform.rs b/asusd/src/ctrl_platform.rs index 0184a8b6..cc67d939 100644 --- a/asusd/src/ctrl_platform.rs +++ b/asusd/src/ctrl_platform.rs @@ -17,6 +17,7 @@ use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH use crate::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH}; use crate::error::RogError; use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify}; +use crate::ctrl_slash::trait_impls::{CtrlSlashZbus, SLASH_ZBUS_NAME, SLASH_ZBUS_PATH}; const PLATFORM_ZBUS_NAME: &str = "Platform"; const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux"; @@ -350,6 +351,13 @@ impl CtrlPlatform { { interfaces.push(PLATFORM_ZBUS_NAME.to_owned()); } + if server + .interface::<_, CtrlSlashZbus>(SLASH_ZBUS_PATH) + .await + .is_ok() + { + interfaces.push(SLASH_ZBUS_NAME.to_owned()); + } interfaces } diff --git a/asusd/src/ctrl_slash/config.rs b/asusd/src/ctrl_slash/config.rs index 8ea0568f..67229247 100644 --- a/asusd/src/ctrl_slash/config.rs +++ b/asusd/src/ctrl_slash/config.rs @@ -1,7 +1,6 @@ use serde_derive::{Deserialize, Serialize}; -use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2}; +use config_traits::{StdConfig, StdConfigLoad}; use rog_slash::{DeviceState, SlashMode}; -use crate::ctrl_anime::config::{AnimeConfig, AnimeConfigV460, AnimeConfigV472}; const CONFIG_FILE: &str = "slash.ron"; @@ -11,7 +10,7 @@ pub struct SlashConfig { pub slash_enabled: bool, pub slash_brightness: u8, pub slash_interval: u8, - pub slash_mode: u8, + pub slash_mode: SlashMode, } impl Default for SlashConfig { @@ -20,7 +19,7 @@ impl Default for SlashConfig { slash_enabled: true, slash_brightness: 255, slash_interval: 0, - slash_mode: SlashMode::Bounce as u8, + slash_mode: SlashMode::Bounce, } } } diff --git a/asusd/src/ctrl_slash/mod.rs b/asusd/src/ctrl_slash/mod.rs index c571468e..f3891a8d 100644 --- a/asusd/src/ctrl_slash/mod.rs +++ b/asusd/src/ctrl_slash/mod.rs @@ -3,8 +3,9 @@ pub mod trait_impls; use rog_platform::hid_raw::HidRaw; use rog_platform::usb_raw::USBRaw; -use rog_slash::{SlashMode}; -use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; +use rog_slash::{SlashMode, SlashType}; +use rog_slash::error::SlashError; +use rog_slash::usb::{get_slash_type, pkt_set_mode, pkt_set_options, pkts_for_init}; use crate::ctrl_slash::config::SlashConfig; use crate::error::RogError; @@ -36,12 +37,11 @@ impl Node { // } } -#[derive(Clone)] pub struct CtrlSlash { // node: HidRaw, node: Node, config: SlashConfig, - // slash_type: SlashType, + slash_type: SlashType, // // set to force thread to exit // thread_exit: Arc, // // Set to false when the thread exits @@ -62,12 +62,15 @@ impl CtrlSlash { }; // Maybe, detecting the slash-type may become necessary - // let slash_type = get_slash_type()?; + let slash_type = get_slash_type()?; + if slash_type == SlashType::Unknown { + return Err(RogError::Slash(SlashError::NoDevice)); + } let ctrl = CtrlSlash { node, config, - // slash_type, + slash_type, // thread_exit: Arc::new(AtomicBool::new(false)), // thread_running: Arc::new(AtomicBool::new(false)), }; @@ -92,7 +95,7 @@ impl CtrlSlash { } pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), RogError> { - let command_packets = pkt_set_mode(slash_mode as u8); + let command_packets = pkt_set_mode(slash_mode); self.node.write_bytes(&command_packets[0])?; self.node.write_bytes(&command_packets[1])?; Ok(()) diff --git a/asusd/src/ctrl_slash/trait_impls.rs b/asusd/src/ctrl_slash/trait_impls.rs index 39e7afec..60903086 100644 --- a/asusd/src/ctrl_slash/trait_impls.rs +++ b/asusd/src/ctrl_slash/trait_impls.rs @@ -1,11 +1,12 @@ use std::sync::Arc; use log::warn; -use zbus::{Connection, interface}; +use zbus::{Connection, interface, SignalContext}; use zbus::export::futures_util::lock::Mutex; use config_traits::StdConfig; -use rog_slash::DeviceState; -use rog_slash::usb::pkt_set_options; +use rog_slash::{DeviceState, SlashMode}; +use rog_slash::usb::{pkt_set_mode, pkt_set_options}; use crate::ctrl_slash::CtrlSlash; +use crate::error::RogError; pub const SLASH_ZBUS_NAME: &str = "Slash"; @@ -14,41 +15,47 @@ pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux"; #[derive(Clone)] pub struct CtrlSlashZbus(pub Arc>); - /// The struct with the main dbus methods requires this trait impl crate::ZbusRun for CtrlSlashZbus { async fn add_to_server(self, server: &mut Connection) { - Self::add_to_server_helper(self, SLASH_ZBUS_NAME, server).await; + Self::add_to_server_helper(self, SLASH_ZBUS_PATH, server).await; } } - -// None of these calls can be guarnateed to succeed unless we loop until okay -// If the try_lock *does* succeed then any other thread trying to lock will not -// grab it until we finish. #[interface(name = "org.asuslinux.Slash")] impl CtrlSlashZbus { - // /// Writes a data stream of length. Will force system thread to exit until - // /// it is restarted - // async fn write(&self, input: AnimeDataBuffer) -> zbus::fdo::Result<()> { - // let lock = self.0.lock().await; - // lock.thread_exit.store(true, Ordering::SeqCst); - // lock.write_data_buffer(input).map_err(|err| { - // warn!("ctrl_anime::run_animation:callback {}", err); - // err - // })?; - // Ok(()) - // } - /// Set base brightness level + /// Get enabled or not + #[zbus(property)] + async fn enabled(&self) -> bool { + let lock = self.0.lock().await; + lock.config.slash_enabled + } + + /// Set enabled true or false + async fn set_enabled(&self, enabled: bool) { + let mut lock = self.0.lock().await; + let brightness = if enabled && lock.config.slash_brightness == 0 { 0x88 } else { lock.config.slash_brightness }; + lock.node + .write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_enabled = enabled; + lock.config.slash_brightness = brightness; + lock.config.write(); + } + + /// Get brightness level #[zbus(property)] async fn brightness(&self) -> u8 { let lock = self.0.lock().await; lock.config.slash_brightness } - /// Set base brightness level - #[zbus(property)] + /// Set brightness level async fn set_brightness(&self, brightness: u8) { let mut lock = self.0.lock().await; let enabled = brightness > 0; @@ -65,23 +72,51 @@ impl CtrlSlashZbus { } #[zbus(property)] - async fn enable_display(&self) -> bool { + async fn interval(&self) -> u8 { let lock = self.0.lock().await; - lock.config.slash_enabled + lock.config.slash_interval } - /// Set whether the AniMe is enabled at all - #[zbus(property)] - async fn set_enable_display(&self, enabled: bool) { + /// Set interval between slash animations (0-255) + async fn set_interval(&self, interval: u8) { let mut lock = self.0.lock().await; lock.node - .write_bytes(&pkt_set_options(enabled, lock.config.slash_brightness, lock.config.slash_interval)) + .write_bytes(&pkt_set_options(lock.config.slash_enabled, lock.config.slash_brightness, interval)) .map_err(|err| { warn!("ctrl_slash::set_options {}", err); }) .ok(); - lock.config.slash_enabled = enabled; + lock.config.slash_interval = interval; + lock.config.write(); + } + + #[zbus(property)] + async fn slash_mode(&self) -> u8 { + let lock = self.0.lock().await; + lock.config.slash_interval + } + + /// Set interval between slash animations (0-255) + async fn set_slash_mode(&self, slash_mode: SlashMode) { + let mut lock = self.0.lock().await; + + let command_packets = pkt_set_mode(slash_mode); + + lock.node + .write_bytes(&command_packets[0]) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + lock.node + .write_bytes(&command_packets[1]) + .map_err(|err| { + warn!("ctrl_slash::set_options {}", err); + }) + .ok(); + + lock.config.slash_mode = slash_mode; lock.config.write(); } @@ -91,4 +126,20 @@ impl CtrlSlashZbus { let lock = self.0.lock().await; DeviceState::from(&lock.config) } +} + +impl crate::CtrlTask for CtrlSlashZbus { + fn zbus_path() -> &'static str { + SLASH_ZBUS_PATH + } + + async fn create_tasks(&self, _: SignalContext<'static>) -> Result<(), RogError> { + Ok(()) + } +} + +impl crate::Reloadable for CtrlSlashZbus { + async fn reload(&mut self) -> Result<(), RogError> { + Ok(()) + } } \ No newline at end of file diff --git a/asusd/src/daemon.rs b/asusd/src/daemon.rs index 38d485ef..72aec6e6 100644 --- a/asusd/src/daemon.rs +++ b/asusd/src/daemon.rs @@ -110,11 +110,15 @@ async fn start_daemon() -> Result<(), Box> { match CtrlSlash::new(SlashConfig::new().load()) { Ok(ctrl) => { - let sig_ctx = CtrlPlatform::signal_context(&connection)?; - start_tasks(ctrl, &mut connection, sig_ctx).await?; + let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl))); + // Currently, the Slash has no need for a loop watching power events, however, + // it could be cool to have the slash do some power-on/off animation + // (It has a built-in power on animation which plays when u plug in the power supply) + let sig_ctx = CtrlSlashZbus::signal_context(&connection)?; + start_tasks(zbus, &mut connection, sig_ctx).await?; } Err(err) => { - info!("Slash control: {}", err); + info!("AniMe control: {}", err); } } diff --git a/asusd/src/error.rs b/asusd/src/error.rs index 64ef8a0f..601aab95 100644 --- a/asusd/src/error.rs +++ b/asusd/src/error.rs @@ -5,6 +5,7 @@ use config_traits::ron; use rog_anime::error::AnimeError; use rog_platform::error::PlatformError; use rog_profiles::error::ProfileError; +use rog_slash::error::SlashError; #[derive(Debug)] pub enum RogError { @@ -31,6 +32,7 @@ pub enum RogError { NoAuraKeyboard, NoAuraNode, Anime(AnimeError), + Slash(SlashError), Platform(PlatformError), SystemdUnitAction(String), SystemdUnitWaitTimeout(String), @@ -72,6 +74,7 @@ impl fmt::Display for RogError { RogError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"), RogError::NoAuraNode => write!(f, "No Aura keyboard node found"), RogError::Anime(deets) => write!(f, "AniMe Matrix error: {}", deets), + RogError::Slash(deets) => write!(f, "Slash error: {}", deets), RogError::Platform(deets) => write!(f, "Asus Platform error: {}", deets), RogError::SystemdUnitAction(action) => { write!(f, "systemd unit action {} failed", action) @@ -103,6 +106,12 @@ impl From for RogError { } } +impl From for RogError { + fn from(err: SlashError) -> Self { + RogError::Slash(err) + } +} + impl From for RogError { fn from(err: PlatformError) -> Self { RogError::Platform(err) diff --git a/asusd/src/lib.rs b/asusd/src/lib.rs index 16f21e6f..0c740bf9 100644 --- a/asusd/src/lib.rs +++ b/asusd/src/lib.rs @@ -3,7 +3,7 @@ pub mod config; /// Control of anime matrix display pub mod ctrl_anime; -/// Control of anime slash led bar +/// Control of Slash led bar pub mod ctrl_slash; /// Keyboard LED brightness control, RGB, and LED display modes pub mod ctrl_aura; @@ -132,7 +132,7 @@ pub fn print_board_info() { } pub trait Reloadable { - fn reload(&mut self) -> impl std::future::Future> + Send; + fn reload(&mut self) -> impl Future> + Send; } pub trait ReloadAndNotify { @@ -142,18 +142,18 @@ pub trait ReloadAndNotify { &mut self, signal_context: &SignalContext<'static>, data: Self::Data, - ) -> impl std::future::Future> + Send; + ) -> impl Future> + Send; } pub trait ZbusRun { fn add_to_server(self, server: &mut Connection) - -> impl std::future::Future + Send; + -> impl Future + Send; fn add_to_server_helper( iface: impl zbus::Interface, path: &str, server: &mut Connection, - ) -> impl std::future::Future + Send { + ) -> impl Future + Send { async move { server .object_server() @@ -182,7 +182,7 @@ pub trait CtrlTask { fn create_tasks( &self, signal: SignalContext<'static>, - ) -> impl std::future::Future> + Send; + ) -> impl Future> + Send; // /// Create a timed repeating task // async fn repeating_task(&self, millis: u64, mut task: impl FnMut() + Send + @@ -215,7 +215,7 @@ pub trait CtrlTask { mut on_prepare_for_shutdown: F2, mut on_lid_change: F3, mut on_external_power_change: F4, - ) -> impl std::future::Future + Send + ) -> impl Future + Send where F1: FnMut(bool) -> Fut1, F2: FnMut(bool) -> Fut2, @@ -309,13 +309,13 @@ pub async fn start_tasks( where T: ZbusRun + Reloadable + CtrlTask + Clone, { - let task = zbus.clone(); + let zbus_clone = zbus.clone(); zbus.reload() .await .unwrap_or_else(|err| warn!("Controller error: {}", err)); zbus.add_to_server(connection).await; - task.create_tasks(signal_ctx).await.ok(); + zbus_clone.create_tasks(signal_ctx).await.ok(); Ok(()) -} +} \ No newline at end of file diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 2e9e2e33..e9605c17 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-14 08:10+0000\n" +"POT-Creation-Date: 2024-03-30 17:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -12,481 +12,6 @@ msgstr "" "Language: \n" "Plural-Forms: nplurals=1; plural=0;\n" -#: rog-control-center/ui/main_window.slint:49 -msgctxt "MainWindow" -msgid "ROG" -msgstr "" - -#: rog-control-center/ui/main_window.slint:51 -msgctxt "Menu1" -msgid "System Control" -msgstr "" - -#: rog-control-center/ui/main_window.slint:52 -msgctxt "Menu2" -msgid "Keyboard Aura" -msgstr "" - -#: rog-control-center/ui/main_window.slint:53 -msgctxt "Menu3" -msgid "AniMe Matrix" -msgstr "" - -#: rog-control-center/ui/main_window.slint:54 -msgctxt "Menu4" -msgid "Fan Curves" -msgstr "" - -#: rog-control-center/ui/main_window.slint:55 -msgctxt "Menu5" -msgid "App Settings" -msgstr "" - -#: rog-control-center/ui/main_window.slint:56 -msgctxt "Menu6" -msgid "About" -msgstr "" - -#: rog-control-center/ui/main_window.slint:68 -msgctxt "MainWindow" -msgid "Quit" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:6 -msgctxt "Anime Brightness" -msgid "Off" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:7 -msgctxt "Anime Brightness" -msgid "Low" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:8 -msgctxt "Anime Brightness" -msgid "Med" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:9 -msgctxt "Anime Brightness" -msgid "High" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:23 -msgctxt "AnimePageData" -msgid "Glitch Construction" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:23 -msgctxt "AnimePageData" -msgid "Static Emergence" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:25 -msgctxt "AnimePageData" -msgid "Binary Banner Scroll" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:25 -msgctxt "AnimePageData" -msgid "Rog Logo Glitch" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:27 -msgctxt "AnimePageData" -msgid "Banner Swipe" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:27 -msgctxt "AnimePageData" -msgid "Starfield" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:29 -msgctxt "AnimePageData" -msgid "Glitch Out" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:29 -msgctxt "AnimePageData" -msgid "See Ya" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:50 -msgctxt "Anime Brightness" -msgid "Brightness" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:66 -msgctxt "PageAnime" -msgid "Enable display" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:74 rog-control-center/ui/pages/anime.slint:97 -msgctxt "PageAnime" -msgid "Advanced" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:89 -msgctxt "PageAnime" -msgid "Use built-in animations" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:146 -msgctxt "PageAnime" -msgid "Set which builtin animations are played" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:150 -msgctxt "Anime built-in selection" -msgid "Boot Animation" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:160 -msgctxt "Anime built-in selection" -msgid "Running Animation" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:170 -msgctxt "Anime built-in selection" -msgid "Sleep Animation" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:180 -msgctxt "Anime built-in selection" -msgid "Shutdown Animation" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:220 -msgctxt "PageAnime" -msgid "Advanced Display Settings" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:225 -msgctxt "PageAnime" -msgid "Off when lid closed" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:234 -msgctxt "PageAnime" -msgid "Off when suspended" -msgstr "" - -#: rog-control-center/ui/pages/anime.slint:243 -msgctxt "PageAnime" -msgid "Off when on battery" -msgstr "" - -#: rog-control-center/ui/pages/app_settings.slint:29 -msgctxt "PageAppSettings" -msgid "Run in background after closing" -msgstr "" - -#: rog-control-center/ui/pages/app_settings.slint:38 -msgctxt "PageAppSettings" -msgid "Start app in background (UI closed)" -msgstr "" - -#: rog-control-center/ui/pages/app_settings.slint:50 -msgctxt "PageAppSettings" -msgid "Enable system tray icon" -msgstr "" - -#: rog-control-center/ui/pages/app_settings.slint:59 -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:364 rog-control-center/ui/pages/aura.slint:424 -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:370 rog-control-center/ui/pages/aura.slint:430 -msgctxt "PageAura" -msgid "Boot" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:375 rog-control-center/ui/pages/aura.slint:435 -msgctxt "PageAura" -msgid "Awake" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:380 rog-control-center/ui/pages/aura.slint:440 -msgctxt "PageAura" -msgid "Sleep" -msgstr "" - -#: rog-control-center/ui/pages/aura.slint:385 rog-control-center/ui/pages/aura.slint:445 -msgctxt "PageAura" -msgid "Shutdown" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:27 -msgctxt "FanTab" -msgid "This fan is not avilable on this machine" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:35 -msgctxt "FanTab" -msgid "Enabled" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:44 -msgctxt "FanTab" -msgid "Apply" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:52 -msgctxt "FanTab" -msgid "Cancel" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:60 -msgctxt "FanTab" -msgid "Factory Default (all fans)" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:73 -msgctxt "PageFans" -msgid "Balanced" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:76 rog-control-center/ui/pages/fans.slint:135 rog-control-center/ui/pages/fans.slint:194 -msgctxt "PageFans" -msgid "CPU" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:94 rog-control-center/ui/pages/fans.slint:153 rog-control-center/ui/pages/fans.slint:212 -msgctxt "PageFans" -msgid "Mid" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:112 rog-control-center/ui/pages/fans.slint:171 rog-control-center/ui/pages/fans.slint:230 -msgctxt "PageFans" -msgid "GPU" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:132 -msgctxt "PageFans" -msgid "Performance" -msgstr "" - -#: rog-control-center/ui/pages/fans.slint:191 -msgctxt "PageFans" -msgid "Quiet" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:26 -msgctxt "SystemPageData" -msgid "Balanced" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30 -msgctxt "SystemPageData" -msgid "Performance" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:26 -msgctxt "SystemPageData" -msgid "Quiet" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:29 -msgctxt "SystemPageData" -msgid "Default" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:31 -msgctxt "SystemPageData" -msgid "BalancePerformance" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:32 -msgctxt "SystemPageData" -msgid "BalancePower" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:33 -msgctxt "SystemPageData" -msgid "Power" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:106 -msgctxt "PageSystem" -msgid "Base system settings" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:111 -msgctxt "PageSystem" -msgid "Charge limit" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:123 -msgctxt "PageSystem" -msgid "Throttle Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:133 -msgctxt "PageSystem" -msgid "Advanced" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:145 -msgctxt "PageSystem" -msgid "Panel Overdrive" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:153 -msgctxt "PageSystem" -msgid "MiniLED Mode" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:161 -msgctxt "PageSystem" -msgid "POST boot sound" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:179 -msgctxt "PageSystem" -msgid "System performance settings" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:184 -msgctxt "ppt_pl1_spl" -msgid "ppt_pl1_spl" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:194 -msgctxt "ppt_pl2_sppt" -msgid "ppt_pl2_sppt" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:204 -msgctxt "ppt_fppt" -msgid "ppt_fppt" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:214 -msgctxt "ppt_apu_sppt" -msgid "ppt_apu_sppt" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:224 -msgctxt "ppt_platform_sppt" -msgid "ppt_platform_sppt" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:234 -msgctxt "nv_dynamic_boost" -msgid "nv_dynamic_boost" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:244 -msgctxt "nv_temp_target" -msgid "nv_temp_target" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:289 -msgctxt "PageSystem" -msgid "Energy Performance Preference linked to Throttle Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:293 -msgctxt "PageSystem" -msgid "Change EPP based on Throttle Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:301 -msgctxt "PageSystem" -msgid "EPP for Balanced Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:311 -msgctxt "PageSystem" -msgid "EPP for Performance Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:321 -msgctxt "PageSystem" -msgid "EPP for Quiet Policy" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:339 -msgctxt "PageSystem" -msgid "Throttle Policy for power state" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:343 -msgctxt "PageSystem" -msgid "Throttle Policy on Battery" -msgstr "" - -#: rog-control-center/ui/pages/system.slint:353 -msgctxt "PageSystem" -msgid "Throttle Policy on AC" -msgstr "" - #: rog-control-center/ui/types/aura_types.slint:69 msgctxt "Aura brightness" msgid "Off" @@ -667,3 +192,478 @@ msgctxt "AuraPowerGroup" msgid "Shutdown" msgstr "" +#: rog-control-center/ui/pages/anime.slint:6 +msgctxt "Anime Brightness" +msgid "Off" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:7 +msgctxt "Anime Brightness" +msgid "Low" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:8 +msgctxt "Anime Brightness" +msgid "Med" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:9 +msgctxt "Anime Brightness" +msgid "High" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:23 +msgctxt "AnimePageData" +msgid "Glitch Construction" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:23 +msgctxt "AnimePageData" +msgid "Static Emergence" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:25 +msgctxt "AnimePageData" +msgid "Binary Banner Scroll" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:25 +msgctxt "AnimePageData" +msgid "Rog Logo Glitch" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:27 +msgctxt "AnimePageData" +msgid "Banner Swipe" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:27 +msgctxt "AnimePageData" +msgid "Starfield" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:29 +msgctxt "AnimePageData" +msgid "Glitch Out" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:29 +msgctxt "AnimePageData" +msgid "See Ya" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:50 +msgctxt "Anime Brightness" +msgid "Brightness" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:66 +msgctxt "PageAnime" +msgid "Enable display" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:74 rog-control-center/ui/pages/anime.slint:97 +msgctxt "PageAnime" +msgid "Advanced" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:89 +msgctxt "PageAnime" +msgid "Use built-in animations" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:146 +msgctxt "PageAnime" +msgid "Set which builtin animations are played" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:150 +msgctxt "Anime built-in selection" +msgid "Boot Animation" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:160 +msgctxt "Anime built-in selection" +msgid "Running Animation" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:170 +msgctxt "Anime built-in selection" +msgid "Sleep Animation" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:180 +msgctxt "Anime built-in selection" +msgid "Shutdown Animation" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:220 +msgctxt "PageAnime" +msgid "Advanced Display Settings" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:225 +msgctxt "PageAnime" +msgid "Off when lid closed" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:234 +msgctxt "PageAnime" +msgid "Off when suspended" +msgstr "" + +#: rog-control-center/ui/pages/anime.slint:243 +msgctxt "PageAnime" +msgid "Off when on battery" +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" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:35 +msgctxt "FanTab" +msgid "Enabled" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:44 +msgctxt "FanTab" +msgid "Apply" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:52 +msgctxt "FanTab" +msgid "Cancel" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:60 +msgctxt "FanTab" +msgid "Factory Default (all fans)" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:73 +msgctxt "PageFans" +msgid "Balanced" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:76 rog-control-center/ui/pages/fans.slint:135 rog-control-center/ui/pages/fans.slint:194 +msgctxt "PageFans" +msgid "CPU" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:94 rog-control-center/ui/pages/fans.slint:153 rog-control-center/ui/pages/fans.slint:212 +msgctxt "PageFans" +msgid "Mid" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:112 rog-control-center/ui/pages/fans.slint:171 rog-control-center/ui/pages/fans.slint:230 +msgctxt "PageFans" +msgid "GPU" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:132 +msgctxt "PageFans" +msgid "Performance" +msgstr "" + +#: rog-control-center/ui/pages/fans.slint:191 +msgctxt "PageFans" +msgid "Quiet" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:26 +msgctxt "SystemPageData" +msgid "Balanced" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:26 rog-control-center/ui/pages/system.slint:30 +msgctxt "SystemPageData" +msgid "Performance" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:26 +msgctxt "SystemPageData" +msgid "Quiet" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:29 +msgctxt "SystemPageData" +msgid "Default" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:31 +msgctxt "SystemPageData" +msgid "BalancePerformance" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:32 +msgctxt "SystemPageData" +msgid "BalancePower" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:33 +msgctxt "SystemPageData" +msgid "Power" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:106 +msgctxt "PageSystem" +msgid "Base system settings" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:111 +msgctxt "PageSystem" +msgid "Charge limit" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:123 +msgctxt "PageSystem" +msgid "Throttle Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:133 +msgctxt "PageSystem" +msgid "Advanced" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:145 +msgctxt "PageSystem" +msgid "Panel Overdrive" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:153 +msgctxt "PageSystem" +msgid "MiniLED Mode" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:161 +msgctxt "PageSystem" +msgid "POST boot sound" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:179 +msgctxt "PageSystem" +msgid "System performance settings" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:184 +msgctxt "ppt_pl1_spl" +msgid "ppt_pl1_spl" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:194 +msgctxt "ppt_pl2_sppt" +msgid "ppt_pl2_sppt" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:204 +msgctxt "ppt_fppt" +msgid "ppt_fppt" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:214 +msgctxt "ppt_apu_sppt" +msgid "ppt_apu_sppt" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:224 +msgctxt "ppt_platform_sppt" +msgid "ppt_platform_sppt" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:234 +msgctxt "nv_dynamic_boost" +msgid "nv_dynamic_boost" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:244 +msgctxt "nv_temp_target" +msgid "nv_temp_target" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:290 +msgctxt "PageSystem" +msgid "Energy Performance Preference linked to Throttle Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:294 +msgctxt "PageSystem" +msgid "Change EPP based on Throttle Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:302 +msgctxt "PageSystem" +msgid "EPP for Balanced Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:312 +msgctxt "PageSystem" +msgid "EPP for Performance Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:322 +msgctxt "PageSystem" +msgid "EPP for Quiet Policy" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:340 +msgctxt "PageSystem" +msgid "Throttle Policy for power state" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:344 +msgctxt "PageSystem" +msgid "Throttle Policy on Battery" +msgstr "" + +#: rog-control-center/ui/pages/system.slint:354 +msgctxt "PageSystem" +msgid "Throttle Policy on AC" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:29 +msgctxt "PageAppSettings" +msgid "Run in background after closing" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:38 +msgctxt "PageAppSettings" +msgid "Start app in background (UI closed)" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:50 +msgctxt "PageAppSettings" +msgid "Enable system tray icon" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:59 +msgctxt "PageAppSettings" +msgid "Enable change notifications" +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-dbus/src/lib.rs b/rog-dbus/src/lib.rs index 13e6ccd9..3a1d4d50 100644 --- a/rog-dbus/src/lib.rs +++ b/rog-dbus/src/lib.rs @@ -96,9 +96,7 @@ impl<'a> DbusProxies<'a> { )) } - pub fn anime(&self) -> &zbus_anime::AnimeProxy<'a> { - &self.anime - } + pub fn anime(&self) -> &zbus_anime::AnimeProxy<'a> { &self.anime } pub fn slash(&self) -> &zbus_slash::SlashProxy<'a> { &self.slash } pub fn led(&self) -> &zbus_aura::AuraProxy<'a> { diff --git a/rog-dbus/src/zbus_slash.rs b/rog-dbus/src/zbus_slash.rs index f0104a29..e58485a3 100644 --- a/rog-dbus/src/zbus_slash.rs +++ b/rog-dbus/src/zbus_slash.rs @@ -1,14 +1,18 @@ use zbus::proxy; +use rog_slash::SlashMode; #[proxy( -interface = "org.asuslinux.Slash", -default_service = "org.asuslinux.Daemon", -default_path = "/org/asuslinux" + interface = "org.asuslinux.Slash", + default_service = "org.asuslinux.Daemon", + default_path = "/org/asuslinux" )] trait Slash { - /// RunMainLoop method - fn run_main_loop(&self, start: bool) -> zbus::Result<()>; - + /// EnableDisplay property + #[zbus(property)] + fn enabled(&self) -> zbus::Result; + #[zbus(property)] + fn set_enabled(&self, value: bool) -> zbus::Result<()>; + /// Brightness property #[zbus(property)] fn brightness(&self) -> zbus::Result; @@ -21,15 +25,10 @@ trait Slash { #[zbus(property)] fn set_interval(&self, value: u8) -> zbus::Result<()>; - /// BuiltinAnimations property + /// Slash modes property #[zbus(property)] - fn current_mode(&self) -> zbus::Result; + fn slash_mode(&self) -> zbus::Result; #[zbus(property)] - fn set_current_mode(&self, value: u8) -> zbus::Result<()>; + fn set_slash_mode(&self, value: SlashMode) -> zbus::Result<()>; - /// EnableDisplay property - #[zbus(property)] - fn enable_display(&self) -> zbus::Result; - #[zbus(property)] - fn set_enable_display(&self, value: bool) -> zbus::Result<()>; } diff --git a/rog-slash/src/data.rs b/rog-slash/src/data.rs index 19e64da5..6249692f 100644 --- a/rog-slash/src/data.rs +++ b/rog-slash/src/data.rs @@ -4,11 +4,10 @@ use serde_derive::{Deserialize, Serialize}; use typeshare::typeshare; #[cfg(feature = "dbus")] use zbus::zvariant::Type; +use zbus::zvariant::{OwnedValue, Value}; use crate::error::SlashError; -#[typeshare] -#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))] #[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] pub enum SlashType { GA403, @@ -26,8 +25,8 @@ impl FromStr for SlashType { } #[typeshare] -// #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] -#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))] +#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)] pub enum SlashMode { Bounce = 0x10, Slash = 0x12, @@ -46,6 +45,12 @@ pub enum SlashMode { Buzzer = 0x44, } +impl Default for SlashMode { + fn default() -> Self { + SlashMode::Flow + } +} + impl SlashMode { pub const fn to_string(&self) -> &str { @@ -67,6 +72,28 @@ impl SlashMode { SlashMode::Buzzer => "Buzzer", } } + + pub fn from_string(value: &str) -> Self + { + match value { + "Bounce" => SlashMode::Bounce, + "Slash" => SlashMode::Slash, + "Loading" => SlashMode::Loading, + "BitStream" => SlashMode::BitStream, + "Transmission" => SlashMode::Transmission, + "Flow" => SlashMode::Flow, + "Flux" => SlashMode::Flux, + "Phantom" => SlashMode::Phantom, + "Spectrum" => SlashMode::Spectrum, + "Hazard" => SlashMode::Hazard, + "Interfacing" => SlashMode::Interfacing, + "Ramp" => SlashMode::Ramp, + "GameOver" => SlashMode::GameOver, + "Start" => SlashMode::Start, + "Buzzer" => SlashMode::Buzzer, + _ => SlashMode::Bounce + } + } pub const fn list() -> [&'static str; 15] { [ @@ -89,9 +116,6 @@ impl SlashMode { } } - - -// TODO: move this out #[typeshare] #[cfg_attr(feature = "dbus", derive(Type))] #[typeshare] @@ -100,6 +124,6 @@ pub struct DeviceState { pub slash_enabled: bool, pub slash_brightness: u8, pub slash_interval: u8, - pub slash_mode: u8, + pub slash_mode: SlashMode, } diff --git a/rog-slash/src/usb.rs b/rog-slash/src/usb.rs index 38aabc49..4aa8aa68 100644 --- a/rog-slash/src/usb.rs +++ b/rog-slash/src/usb.rs @@ -11,7 +11,7 @@ use dmi_id::DMIID; #[cfg(feature = "dbus")] use crate::error::SlashError; -use crate::SlashType; +use crate::{SlashMode, SlashType}; const PACKET_SIZE: usize = 128; const DEV_PAGE: u8 = 0x5e; @@ -76,7 +76,7 @@ pub const fn pkt_save() -> SlashUsbPacket { } #[inline] -pub const fn pkt_set_mode(mode: u8) -> [SlashUsbPacket; 2] { +pub const fn pkt_set_mode(mode: SlashMode) -> [SlashUsbPacket; 2] { let mut pkt1 = [0;PACKET_SIZE]; pkt1[0] = DEV_PAGE; pkt1[1] = 0x02; @@ -91,7 +91,7 @@ pub const fn pkt_set_mode(mode: u8) -> [SlashUsbPacket; 2] { pkt2[3] = 0x00; pkt2[4] = 0x0C; pkt2[5] = 0x01; - pkt2[6] = mode; + pkt2[6] = mode as u8; pkt2[7] = 0x02; pkt2[8] = 0x19; pkt2[9] = 0x03; diff --git a/slashctl/Cargo.toml b/slashctl/Cargo.toml deleted file mode 100644 index fb85f31b..00000000 --- a/slashctl/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "slashctl" -license = "MPL-2.0" -version.workspace = true -authors = ["Luke "] -repository = "https://gitlab.com/asus-linux/asus-nb-ctrl" -homepage = "https://gitlab.com/asus-linux/asus-nb-ctrl" -description = "A ctrl app to control the Asus Slash" -edition = "2021" - -[dependencies] -rog_slash = { path = "../rog-slash" } -rog_platform = { path = "../rog-platform" } -rog_profiles = { path = "../rog-profiles" } -dmi_id = { path = "../dmi-id" } -futures-lite = "*" -udev.workspace = true -inotify.workspace = true \ No newline at end of file diff --git a/slashctl/src/ctrl_slash/mod.rs b/slashctl/src/ctrl_slash/mod.rs deleted file mode 100644 index 00c1db97..00000000 --- a/slashctl/src/ctrl_slash/mod.rs +++ /dev/null @@ -1,94 +0,0 @@ -use rog_platform::hid_raw::HidRaw; -use rog_platform::usb_raw::USBRaw; -use rog_slash::{SlashMode}; -use rog_slash::usb::{pkt_set_mode, pkt_set_options, pkts_for_init}; - -use crate::error::SlashCtlError; - -enum Node { - Usb(USBRaw), - Hid(HidRaw), -} - -impl Node { - pub fn write_bytes(&self, message: &[u8]) -> Result<(), SlashCtlError> { - // TODO: map and pass on errors - match self { - Node::Usb(u) => { - u.write_bytes(message).ok(); - } - Node::Hid(h) => { - h.write_bytes(message).ok(); - } - } - Ok(()) - } - - // pub fn set_builtins_enabled(&self, enabled: bool) -> Result<(), SlashCtlError> { - // self.write_bytes(&pkt_set_enable_powersave_anim(enabled))?; - // self.write_bytes(&pkt_set_enable_display(enabled))?; - // self.write_bytes(&pkt_set_brightness(bright))?; - // self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) - // Ok(()) - // } -} - -pub struct CtrlSlash { - // node: HidRaw, - node: Node, - // slash_type: SlashType, - // // set to force thread to exit - // thread_exit: Arc, - // // Set to false when the thread exits - // thread_running: Arc, -} - -impl CtrlSlash { - #[inline] - pub fn new() -> Result { - let usb = USBRaw::new(rog_slash::usb::PROD_ID).ok(); - let hid = HidRaw::new(rog_slash::usb::PROD_ID_STR).ok(); - let node = if usb.is_some() { - unsafe { Node::Usb(usb.unwrap_unchecked()) } - } else if hid.is_some() { - unsafe { Node::Hid(hid.unwrap_unchecked().0) } - } else { - return Err(SlashCtlError::NotSupported); - }; - - // Maybe, detecting the slash-type may become necessary - // let slash_type = get_slash_type()?; - - let ctrl = CtrlSlash { - node, - // slash_type, - // thread_exit: Arc::new(AtomicBool::new(false)), - // thread_running: Arc::new(AtomicBool::new(false)), - }; - ctrl.do_initialization()?; - - Ok(ctrl) - } - - fn do_initialization(&self) -> Result<(), SlashCtlError> { - - let init_packets = pkts_for_init(); - self.node.write_bytes(&init_packets[0])?; - self.node.write_bytes(&init_packets[1])?; - - Ok(()) - } - - pub fn set_options(&self, enabled: bool, brightness: u8, interval: u8) -> Result<(), SlashCtlError> { - let command_packets = pkt_set_options(enabled, brightness, interval); - self.node.write_bytes(&command_packets)?; - Ok(()) - } - - pub fn set_slash_mode(&self, slash_mode: SlashMode) -> Result<(), SlashCtlError> { - let command_packets = pkt_set_mode(slash_mode as u8); - self.node.write_bytes(&command_packets[0])?; - self.node.write_bytes(&command_packets[1])?; - Ok(()) - } -} \ No newline at end of file diff --git a/slashctl/src/error.rs b/slashctl/src/error.rs deleted file mode 100644 index f32cdb14..00000000 --- a/slashctl/src/error.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::fmt; -use std::fmt::{Display}; -use rog_slash::error::SlashError; - -#[derive(Debug)] -pub enum SlashCtlError { - NotSupported, - Slash(SlashError), -} - - -impl Display for SlashCtlError { - // This trait requires `fmt` with this exact signature. - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - SlashCtlError::NotSupported => write!(f, "Not supported"), - SlashCtlError::Slash(err) => write!(f, "Slash error: {}", err), - } - } -} - -impl std::error::Error for SlashCtlError {} - - - -impl From for SlashCtlError { - fn from(err: SlashError) -> Self { - SlashCtlError::Slash(err) - } -} \ No newline at end of file diff --git a/slashctl/src/main.rs b/slashctl/src/main.rs deleted file mode 100644 index cbe682a5..00000000 --- a/slashctl/src/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::ctrl_slash::CtrlSlash; -use crate::error::SlashCtlError; - -mod ctrl_slash; -mod error; - -fn main() -> Result<(), SlashCtlError>{ - // let args: Vec = args().skip(1).collect(); - - let ctrl_slash = CtrlSlash::new()?; - ctrl_slash.set_options(false, 10, 0)?; - // ctrl_slash.set_options(true, 5, 2)?; - // ctrl_slash.set_slash_mode(SlashModes::Flow)?; - Ok(()) -} \ No newline at end of file From b40812928aee026ac59460324630ea19328e6f1d Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 18:42:42 +0100 Subject: [PATCH 04/13] Imlement Display and FromStr traits for SlashMode --- rog-slash/src/data.rs | 97 +++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/rog-slash/src/data.rs b/rog-slash/src/data.rs index 6249692f..5d1e11f3 100644 --- a/rog-slash/src/data.rs +++ b/rog-slash/src/data.rs @@ -1,3 +1,5 @@ +use std::any::Any; +use std::fmt::Display; use std::str::FromStr; use serde_derive::{Deserialize, Serialize}; @@ -51,51 +53,58 @@ impl Default for SlashMode { } } -impl SlashMode { - pub const fn to_string(&self) -> &str - { - match &self { - SlashMode::Bounce => "Bounce", - SlashMode::Slash => "Slash", - SlashMode::Loading => "Loading", - SlashMode::BitStream => "BitStream", - SlashMode::Transmission => "Transmission", - SlashMode::Flow => "Flow", - SlashMode::Flux => "Flux", - SlashMode::Phantom => "Phantom", - SlashMode::Spectrum => "Spectrum", - SlashMode::Hazard => "Hazard", - SlashMode::Interfacing => "Interfacing", - SlashMode::Ramp => "Ramp", - SlashMode::GameOver => "GameOver", - SlashMode::Start => "Start", - SlashMode::Buzzer => "Buzzer", - } - } - - pub fn from_string(value: &str) -> Self - { - match value { - "Bounce" => SlashMode::Bounce, - "Slash" => SlashMode::Slash, - "Loading" => SlashMode::Loading, - "BitStream" => SlashMode::BitStream, - "Transmission" => SlashMode::Transmission, - "Flow" => SlashMode::Flow, - "Flux" => SlashMode::Flux, - "Phantom" => SlashMode::Phantom, - "Spectrum" => SlashMode::Spectrum, - "Hazard" => SlashMode::Hazard, - "Interfacing" => SlashMode::Interfacing, - "Ramp" => SlashMode::Ramp, - "GameOver" => SlashMode::GameOver, - "Start" => SlashMode::Start, - "Buzzer" => SlashMode::Buzzer, - _ => SlashMode::Bounce - } - } +impl FromStr for SlashMode { + type Err = SlashError; - pub const fn list() -> [&'static str; 15] { + fn from_str(s: &str) -> Result { + match s { + "Bounce" => Ok(SlashMode::Bounce), + "Slash" => Ok(SlashMode::Slash), + "Loading" => Ok(SlashMode::Loading), + "BitStream" => Ok(SlashMode::BitStream), + "Transmission" => Ok(SlashMode::Transmission), + "Flow" => Ok(SlashMode::Flow), + "Flux" => Ok(SlashMode::Flux), + "Phantom" => Ok(SlashMode::Phantom), + "Spectrum" => Ok(SlashMode::Spectrum), + "Hazard" => Ok(SlashMode::Hazard), + "Interfacing" => Ok(SlashMode::Interfacing), + "Ramp" => Ok(SlashMode::Ramp), + "GameOver" => Ok(SlashMode::GameOver), + "Start" => Ok(SlashMode::Start), + "Buzzer" => Ok(SlashMode::Buzzer), + _ => Ok(SlashMode::Bounce), + } + } +} + + +impl Display for SlashMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let str = match &self { + SlashMode::Bounce => String::from("Bounce"), + SlashMode::Slash => String::from("Slash"), + SlashMode::Loading => String::from("Loading"), + SlashMode::BitStream => String::from("BitStream"), + SlashMode::Transmission => String::from("Transmission"), + SlashMode::Flow => String::from("Flow"), + SlashMode::Flux => String::from("Flux"), + SlashMode::Phantom => String::from("Phantom"), + SlashMode::Spectrum => String::from("Spectrum"), + SlashMode::Hazard => String::from("Hazard"), + SlashMode::Interfacing => String::from("Interfacing"), + SlashMode::Ramp => String::from("Ramp"), + SlashMode::GameOver => String::from("GameOver"), + SlashMode::Start => String::from("Start"), + SlashMode::Buzzer => String::from("Buzzer"), + }; + write!(f, "{}", str) + } +} + +impl SlashMode { + + pub fn list() -> [String; 15] { [ SlashMode::Bounce.to_string(), SlashMode::Slash.to_string(), From c20d0a76a01ca95ac28f566c29594dd32bde25a3 Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 19:00:22 +0100 Subject: [PATCH 05/13] Fix build after merge --- asusd/src/ctrl_aura/controller.rs | 4 ++-- asusd/src/ctrl_slash/mod.rs | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/asusd/src/ctrl_aura/controller.rs b/asusd/src/ctrl_aura/controller.rs index 37283ab0..463ff9ad 100644 --- a/asusd/src/ctrl_aura/controller.rs +++ b/asusd/src/ctrl_aura/controller.rs @@ -366,7 +366,7 @@ mod tests { }; let mut controller = CtrlKbdLed { led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap().0), + led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap()), supported_data: supported_basic_modes, per_key_mode_active: false, config, @@ -404,7 +404,7 @@ mod tests { }; let mut controller = CtrlKbdLed { led_prod: AuraDevice::X19b6, - led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap().0), + led_node: LEDNode::Rog(KeyboardLed::default(), HidRaw::new("id_product").unwrap()), supported_data: supported_basic_modes, per_key_mode_active: false, config, diff --git a/asusd/src/ctrl_slash/mod.rs b/asusd/src/ctrl_slash/mod.rs index f3891a8d..65b10983 100644 --- a/asusd/src/ctrl_slash/mod.rs +++ b/asusd/src/ctrl_slash/mod.rs @@ -27,14 +27,6 @@ impl Node { } Ok(()) } - - // pub fn set_builtins_enabled(&self, enabled: bool) -> Result<(), SlashCtlError> { - // self.write_bytes(&pkt_set_enable_powersave_anim(enabled))?; - // self.write_bytes(&pkt_set_enable_display(enabled))?; - // self.write_bytes(&pkt_set_brightness(bright))?; - // self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) - // Ok(()) - // } } pub struct CtrlSlash { @@ -56,7 +48,7 @@ impl CtrlSlash { let node = if usb.is_some() { unsafe { Node::Usb(usb.unwrap_unchecked()) } } else if hid.is_some() { - unsafe { Node::Hid(hid.unwrap_unchecked().0) } + unsafe { Node::Hid(hid.unwrap_unchecked()) } } else { return Err(RogError::NotSupported); }; From 70493d1a9317e5ed492d017e56935209221e5c97 Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 19:39:42 +0100 Subject: [PATCH 06/13] Fix error in makefile --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 5cc825c9..f5f7a967 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ zshcpl = $(datarootdir)/zsh/site-functions BIN_ROG := rog-control-center BIN_C := asusctl -BIN_S := slashctl BIN_D := asusd BIN_U := asusd-user LEDCFG := aura_support.ron @@ -48,7 +47,6 @@ install-program: $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_ROG)" "$(DESTDIR)$(bindir)/$(BIN_ROG)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_C)" "$(DESTDIR)$(bindir)/$(BIN_C)" - $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_S)" "$(DESTDIR)$(bindir)/$(BIN_S)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_D)" "$(DESTDIR)$(bindir)/$(BIN_D)" $(INSTALL_PROGRAM) "./target/$(TARGET)/$(BIN_U)" "$(DESTDIR)$(bindir)/$(BIN_U)" @@ -88,7 +86,6 @@ uninstall: rm -r "$(DESTDIR)$(datarootdir)/icons/hicolor/512x512/apps/$(BIN_ROG).png" rm -f "$(DESTDIR)$(bindir)/$(BIN_C)" - rm -f "$(DESTDIR)$(bindir)/$(BIN_S)" rm -f "$(DESTDIR)$(bindir)/$(BIN_D)" rm -f "$(DESTDIR)$(libdir)/udev/rules.d/99-$(BIN_D).rules" rm -f "$(DESTDIR)/etc/asusd/$(LEDCFG)" @@ -145,7 +142,6 @@ endif cargo build $(ARGS) ifneq ($(STRIP_BINARIES),0) strip -s ./target/$(TARGET)/$(BIN_C) - strip -s ./target/$(TARGET)/$(BIN_S) strip -s ./target/$(TARGET)/$(BIN_D) strip -s ./target/$(TARGET)/$(BIN_U) strip -s ./target/$(TARGET)/$(BIN_ROG) From fde2f3ba153c8db982b2f9856c1d51b1a4e0dfdd Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 21:19:55 +0100 Subject: [PATCH 07/13] Fixed issues with asusctl-slash command --- asusctl/src/main.rs | 1 + rog-dbus/src/zbus_slash.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 1efe0ab7..8cb75df1 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -488,6 +488,7 @@ fn handle_slash( cmd.enabled.is_none() && cmd.brightness.is_none() && cmd.interval.is_none() && + cmd.slash_mode.is_none() && !cmd.list ) || cmd.help { diff --git a/rog-dbus/src/zbus_slash.rs b/rog-dbus/src/zbus_slash.rs index e58485a3..00b96e6d 100644 --- a/rog-dbus/src/zbus_slash.rs +++ b/rog-dbus/src/zbus_slash.rs @@ -10,25 +10,25 @@ trait Slash { /// EnableDisplay property #[zbus(property)] fn enabled(&self) -> zbus::Result; - #[zbus(property)] + // #[zbus(property)] fn set_enabled(&self, value: bool) -> zbus::Result<()>; /// Brightness property #[zbus(property)] fn brightness(&self) -> zbus::Result; - #[zbus(property)] + // #[zbus(property)] fn set_brightness(&self, value: u8) -> zbus::Result<()>; /// Interval property #[zbus(property)] fn interval(&self) -> zbus::Result; - #[zbus(property)] + // #[zbus(property)] fn set_interval(&self, value: u8) -> zbus::Result<()>; /// Slash modes property #[zbus(property)] fn slash_mode(&self) -> zbus::Result; - #[zbus(property)] + // #[zbus(property)] fn set_slash_mode(&self, value: SlashMode) -> zbus::Result<()>; } From 0674e7f61ca12d68ffcbd07766ad2e6c78093a23 Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 23:23:37 +0100 Subject: [PATCH 08/13] Changes after my own PR review --- Cargo.toml | 3 +- Makefile | 6 +- asusctl/src/aura_cli.rs | 6 +- .../dbus-xml/org-asuslinux-19b6-4-4-4.xml | 105 ----- .../dbus-xml/org-asuslinux-platform-4.xml | 290 ++----------- rog-aura/src/builtin_modes.rs | 2 +- rog-control-center/src/main.rs | 19 +- .../translations/en/rog-control-center.po | 402 +++++++++--------- rog-dbus/src/zbus_aura.rs | 2 +- rog-platform/src/usb_raw.rs | 24 +- squashfs-root/.DirIcon | 1 - 11 files changed, 268 insertions(+), 592 deletions(-) delete mode 100644 bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml delete mode 100644 squashfs-root/.DirIcon diff --git a/Cargo.toml b/Cargo.toml index 65fa0f39..ee68fd8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,10 @@ version = "6.0.0-alpha1" rust-version = "1.76" [workspace.dependencies] -tokio = { version = "^1.23.0", default-features = false, features = [ +tokio = { version = "^1.36.0", default-features = false,features = [ "macros", "sync", "time", - "rt", "rt-multi-thread" ] } concat-idents = "^1.1" diff --git a/Makefile b/Makefile index f5f7a967..cb6f84cd 100644 --- a/Makefile +++ b/Makefile @@ -124,9 +124,9 @@ bindings: typeshare ./rog-platform/src/ --lang=typescript --output-file=bindings/ts/platform.ts introspect: -# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml -# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml -# gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux -x > bindings/dbus-xml/org-asuslinux-platform-4.xml gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/19b6_4_4 -x > bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Introspectable"]' bindings/dbus-xml/org-asuslinux-* diff --git a/asusctl/src/aura_cli.rs b/asusctl/src/aura_cli.rs index b30cffb9..eea3af0b 100644 --- a/asusctl/src/aura_cli.rs +++ b/asusctl/src/aura_cli.rs @@ -88,15 +88,15 @@ impl FromStr for LedBrightness { } } } -impl Display for LedBrightness { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl ToString for LedBrightness { + fn to_string(&self) -> String { let s = match self.level { Some(0x00) => "low", Some(0x01) => "med", Some(0x02) => "high", _ => "unknown", }; - write!(f, "{}", s.to_owned()) + s.to_owned() } } diff --git a/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml b/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml deleted file mode 100644 index a04d6fab..00000000 --- a/bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bindings/dbus-xml/org-asuslinux-platform-4.xml b/bindings/dbus-xml/org-asuslinux-platform-4.xml index 682f0441..f22a35cc 100644 --- a/bindings/dbus-xml/org-asuslinux-platform-4.xml +++ b/bindings/dbus-xml/org-asuslinux-platform-4.xml @@ -1,101 +1,8 @@ + "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -111,11 +18,6 @@ --> - - @@ -140,6 +42,10 @@ internal config also. --> + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rog-aura/src/builtin_modes.rs b/rog-aura/src/builtin_modes.rs index f5c729a9..d955c74c 100644 --- a/rog-aura/src/builtin_modes.rs +++ b/rog-aura/src/builtin_modes.rs @@ -486,7 +486,7 @@ impl Default for AuraEffect { Self { mode: AuraModeNum::Static, zone: AuraZone::None, - colour1: Colour { r: 166, g: 166, b: 166 }, + colour1: Colour { r: 166, g: 0, b: 0 }, colour2: Colour { r: 0, g: 0, b: 0 }, speed: Speed::Med, direction: Direction::Right, diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index 325c378b..69589382 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -72,10 +72,14 @@ fn main() -> Result<()> { }) .unwrap(); - let supported_properties = dbus.proxies().platform().supported_properties().unwrap_or_else(|_e| { - // TODO: show an error window - Vec::default() - }); + let supported_properties = dbus + .proxies() + .platform() + .supported_properties() + .unwrap_or_else(|_e| { + // TODO: show an error window + Vec::default() + }); // Startup let mut config = Config::new().load(); @@ -113,7 +117,8 @@ fn main() -> Result<()> { init_tray(supported_properties, states.clone(), config.clone()); } - thread_local! { pub static UI: std::cell::RefCell> = Default::default()}; + thread_local! { pub static UI: std::cell::RefCell> = Default::default()} + ; i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); let mut do_once = !startup_in_background; @@ -170,7 +175,7 @@ fn main() -> Result<()> { } }); }) - .unwrap(); + .unwrap(); } else { if buf[1] == QUIT_APP { slint::quit_event_loop().unwrap(); @@ -192,7 +197,7 @@ fn main() -> Result<()> { } }); }) - .unwrap(); + .unwrap(); } } } diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 7c5d026c..588c7c76 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-30 17:43+0000\n" +"POT-Creation-Date: 2024-03-23 01:29+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -12,184 +12,44 @@ msgstr "" "Language: \n" "Plural-Forms: nplurals=1; plural=0;\n" -#: rog-control-center/ui/types/aura_types.slint:69 -msgctxt "Aura brightness" -msgid "Off" +#: rog-control-center/ui/main_window.slint:50 +msgctxt "MainWindow" +msgid "ROG" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:70 -msgctxt "Aura brightness" -msgid "Low" +#: rog-control-center/ui/main_window.slint:52 +msgctxt "Menu1" +msgid "System Control" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:71 -msgctxt "Aura brightness" -msgid "Med" +#: rog-control-center/ui/main_window.slint:53 +msgctxt "Menu2" +msgid "Keyboard Aura" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:72 -msgctxt "Aura brightness" -msgid "High" +#: rog-control-center/ui/main_window.slint:54 +msgctxt "Menu3" +msgid "AniMe Matrix" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92 -msgctxt "Basic aura mode" -msgid "Static" +#: rog-control-center/ui/main_window.slint:55 +msgctxt "Menu4" +msgid "Fan Curves" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93 -msgctxt "Basic aura mode" -msgid "Breathe" +#: rog-control-center/ui/main_window.slint:56 +msgctxt "Menu5" +msgid "App Settings" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:79 rog-control-center/ui/types/aura_types.slint:94 -msgctxt "Basic aura mode" -msgid "Strobe" +#: rog-control-center/ui/main_window.slint:57 +msgctxt "Menu6" +msgid "About" msgstr "" -#: rog-control-center/ui/types/aura_types.slint:80 -msgctxt "Basic aura mode" -msgid "Rainbow" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:81 -msgctxt "Basic aura mode" -msgid "Star" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:82 -msgctxt "Basic aura mode" -msgid "Rain" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:83 -msgctxt "Basic aura mode" -msgid "Highlight" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:84 -msgctxt "Basic aura mode" -msgid "Laser" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:85 -msgctxt "Basic aura mode" -msgid "Ripple" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:86 -msgctxt "Basic aura mode" -msgid "Nothing" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:87 -msgctxt "Basic aura mode" -msgid "Pulse" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:88 -msgctxt "Basic aura mode" -msgid "Comet" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:89 -msgctxt "Basic aura mode" -msgid "Flash" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:101 -msgctxt "Aura zone" -msgid "None" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:102 -msgctxt "Aura zone" -msgid "Key1" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:103 -msgctxt "Aura zone" -msgid "Key2" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:104 -msgctxt "Aura zone" -msgid "Key3" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:105 -msgctxt "Aura zone" -msgid "Key4" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:106 -msgctxt "Aura zone" -msgid "Logo" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:107 -msgctxt "Aura zone" -msgid "Lightbar Left" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:108 -msgctxt "Aura zone" -msgid "Lightbar Right" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:112 -msgctxt "Aura direction" -msgid "Right" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:113 -msgctxt "Aura direction" -msgid "Left" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:114 -msgctxt "Aura direction" -msgid "Up" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:115 -msgctxt "Aura direction" -msgid "Down" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:119 -msgctxt "Aura speed" -msgid "Low" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:120 -msgctxt "Aura speed" -msgid "Medium" -msgstr "" - -#: rog-control-center/ui/types/aura_types.slint:121 -msgctxt "Aura speed" -msgid "High" -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" +#: rog-control-center/ui/main_window.slint:69 +msgctxt "MainWindow" +msgid "Quit" msgstr "" #: rog-control-center/ui/pages/anime.slint:6 @@ -317,6 +177,26 @@ msgctxt "PageAnime" msgid "Off when on battery" msgstr "" +#: rog-control-center/ui/pages/app_settings.slint:29 +msgctxt "PageAppSettings" +msgid "Run in background after closing" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:38 +msgctxt "PageAppSettings" +msgid "Start app in background (UI closed)" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:50 +msgctxt "PageAppSettings" +msgid "Enable system tray icon" +msgstr "" + +#: rog-control-center/ui/pages/app_settings.slint:59 +msgctxt "PageAppSettings" +msgid "Enable change notifications" +msgstr "" + #: rog-control-center/ui/pages/aura.slint:27 msgctxt "PageAura" msgid "Brightness" @@ -607,63 +487,183 @@ msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" -#: rog-control-center/ui/pages/app_settings.slint:29 -msgctxt "PageAppSettings" -msgid "Run in background after closing" +#: rog-control-center/ui/types/aura_types.slint:69 +msgctxt "Aura brightness" +msgid "Off" msgstr "" -#: rog-control-center/ui/pages/app_settings.slint:38 -msgctxt "PageAppSettings" -msgid "Start app in background (UI closed)" +#: rog-control-center/ui/types/aura_types.slint:70 +msgctxt "Aura brightness" +msgid "Low" msgstr "" -#: rog-control-center/ui/pages/app_settings.slint:50 -msgctxt "PageAppSettings" -msgid "Enable system tray icon" +#: rog-control-center/ui/types/aura_types.slint:71 +msgctxt "Aura brightness" +msgid "Med" msgstr "" -#: rog-control-center/ui/pages/app_settings.slint:59 -msgctxt "PageAppSettings" -msgid "Enable change notifications" +#: rog-control-center/ui/types/aura_types.slint:72 +msgctxt "Aura brightness" +msgid "High" msgstr "" -#: rog-control-center/ui/main_window.slint:50 -msgctxt "MainWindow" -msgid "ROG" +#: rog-control-center/ui/types/aura_types.slint:77 rog-control-center/ui/types/aura_types.slint:92 +msgctxt "Basic aura mode" +msgid "Static" msgstr "" -#: rog-control-center/ui/main_window.slint:52 -msgctxt "Menu1" -msgid "System Control" +#: rog-control-center/ui/types/aura_types.slint:78 rog-control-center/ui/types/aura_types.slint:93 +msgctxt "Basic aura mode" +msgid "Breathe" msgstr "" -#: rog-control-center/ui/main_window.slint:53 -msgctxt "Menu2" -msgid "Keyboard Aura" +#: rog-control-center/ui/types/aura_types.slint:79 rog-control-center/ui/types/aura_types.slint:94 +msgctxt "Basic aura mode" +msgid "Strobe" msgstr "" -#: rog-control-center/ui/main_window.slint:54 -msgctxt "Menu3" -msgid "AniMe Matrix" +#: rog-control-center/ui/types/aura_types.slint:80 +msgctxt "Basic aura mode" +msgid "Rainbow" msgstr "" -#: rog-control-center/ui/main_window.slint:55 -msgctxt "Menu4" -msgid "Fan Curves" +#: rog-control-center/ui/types/aura_types.slint:81 +msgctxt "Basic aura mode" +msgid "Star" msgstr "" -#: rog-control-center/ui/main_window.slint:56 -msgctxt "Menu5" -msgid "App Settings" +#: rog-control-center/ui/types/aura_types.slint:82 +msgctxt "Basic aura mode" +msgid "Rain" msgstr "" -#: rog-control-center/ui/main_window.slint:57 -msgctxt "Menu6" -msgid "About" +#: rog-control-center/ui/types/aura_types.slint:83 +msgctxt "Basic aura mode" +msgid "Highlight" msgstr "" -#: rog-control-center/ui/main_window.slint:69 -msgctxt "MainWindow" -msgid "Quit" +#: rog-control-center/ui/types/aura_types.slint:84 +msgctxt "Basic aura mode" +msgid "Laser" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:85 +msgctxt "Basic aura mode" +msgid "Ripple" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:86 +msgctxt "Basic aura mode" +msgid "Nothing" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:87 +msgctxt "Basic aura mode" +msgid "Pulse" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:88 +msgctxt "Basic aura mode" +msgid "Comet" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:89 +msgctxt "Basic aura mode" +msgid "Flash" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:101 +msgctxt "Aura zone" +msgid "None" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:102 +msgctxt "Aura zone" +msgid "Key1" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:103 +msgctxt "Aura zone" +msgid "Key2" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:104 +msgctxt "Aura zone" +msgid "Key3" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:105 +msgctxt "Aura zone" +msgid "Key4" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:106 +msgctxt "Aura zone" +msgid "Logo" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:107 +msgctxt "Aura zone" +msgid "Lightbar Left" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:108 +msgctxt "Aura zone" +msgid "Lightbar Right" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:112 +msgctxt "Aura direction" +msgid "Right" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:113 +msgctxt "Aura direction" +msgid "Left" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:114 +msgctxt "Aura direction" +msgid "Up" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:115 +msgctxt "Aura direction" +msgid "Down" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:119 +msgctxt "Aura speed" +msgid "Low" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:120 +msgctxt "Aura speed" +msgid "Medium" +msgstr "" + +#: rog-control-center/ui/types/aura_types.slint:121 +msgctxt "Aura speed" +msgid "High" +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 "" diff --git a/rog-dbus/src/zbus_aura.rs b/rog-dbus/src/zbus_aura.rs index 040bb9b5..f1e5e221 100644 --- a/rog-dbus/src/zbus_aura.rs +++ b/rog-dbus/src/zbus_aura.rs @@ -34,7 +34,7 @@ const BLOCKING_TIME: u64 = 33; // 100ms = 10 FPS, max 50ms = 20 FPS, 40ms = 25 F #[proxy( interface = "org.asuslinux.Aura", default_service = "org.asuslinux.Daemon", - default_path = "/org/asuslinux/19b6_4_4" + default_path = "/org/asuslinux/Aura" )] trait Aura { /// AllModeData method diff --git a/rog-platform/src/usb_raw.rs b/rog-platform/src/usb_raw.rs index 9b853395..fce8ecbc 100644 --- a/rog-platform/src/usb_raw.rs +++ b/rog-platform/src/usb_raw.rs @@ -11,11 +11,9 @@ impl USBRaw { pub fn new(id_product: u16) -> Result { for device in rusb::devices()?.iter() { let device_desc = device.device_descriptor()?; - if device_desc.vendor_id() == 0x0b05 { - if device_desc.product_id() == id_product { - let handle = Self::get_dev_handle(&device)?; - return Ok(Self(handle)); - } + if device_desc.vendor_id() == 0x0b05 && device_desc.product_id() == id_product { + let handle = Self::get_dev_handle(&device)?; + return Ok(Self(handle)); } } @@ -28,17 +26,11 @@ impl USBRaw { fn get_dev_handle( device: &Device, ) -> Result> { - // We don't expect this ID to ever change - let device_open = device.open(); - if let Err(err) = device_open { - panic!("Could not open device, try running as root: {}", err); - } else { - let mut device = device_open.unwrap(); - device.reset()?; - device.set_auto_detach_kernel_driver(true)?; - device.claim_interface(0)?; - Ok(device) - } + let mut device = device.open()?; + device.reset()?; + device.set_auto_detach_kernel_driver(true)?; + device.claim_interface(0)?; + Ok(device) } pub fn write_bytes(&self, message: &[u8]) -> Result { diff --git a/squashfs-root/.DirIcon b/squashfs-root/.DirIcon deleted file mode 100644 index 94e6adba..00000000 --- a/squashfs-root/.DirIcon +++ /dev/null @@ -1 +0,0 @@ -ToolBox_trayIcon_colour_32-01 \ No newline at end of file From 6d8f85c15491d3f78ea66c4b67697c0b8f30570f Mon Sep 17 00:00:00 2001 From: "jochen@g14" Date: Sat, 30 Mar 2024 23:27:33 +0100 Subject: [PATCH 09/13] Minor changes to reflect original files --- Cargo.toml | 5 +++-- Makefile | 3 +-- bindings/dbus-xml/org-asuslinux-platform-4.xml | 3 +-- rog-platform/src/usb_raw.rs | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee68fd8e..3ca598ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,12 @@ version = "6.0.0-alpha1" rust-version = "1.76" [workspace.dependencies] -tokio = { version = "^1.36.0", default-features = false,features = [ +tokio = { version = "^1.36.0", default-features = false, +features = [ "macros", "sync", "time", - "rt-multi-thread" + "rt-multi-thread", ] } concat-idents = "^1.1" dirs = "^4.0" diff --git a/Makefile b/Makefile index cb6f84cd..8acce3b6 100644 --- a/Makefile +++ b/Makefile @@ -127,8 +127,7 @@ introspect: gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Platform -x > bindings/dbus-xml/org-asuslinux-platform-4.xml gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Aura -x > bindings/dbus-xml/org-asuslinux-aura-4.xml gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/Anime -x > bindings/dbus-xml/org-asuslinux-anime-4.xml - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux -x > bindings/dbus-xml/org-asuslinux-platform-4.xml - gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/19b6_4_4 -x > bindings/dbus-xml/org-asuslinux-19b6-4-4-4.xml + gdbus introspect --system -d org.asuslinux.Daemon -o /org/asuslinux/FanCurves -x > bindings/dbus-xml/org-asuslinux-fan-curves-4.xml xmlstarlet ed -L -O -d '//interface[@name="org.freedesktop.DBus.Introspectable"]' bindings/dbus-xml/org-asuslinux-* 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-* diff --git a/bindings/dbus-xml/org-asuslinux-platform-4.xml b/bindings/dbus-xml/org-asuslinux-platform-4.xml index f22a35cc..d4cf9925 100644 --- a/bindings/dbus-xml/org-asuslinux-platform-4.xml +++ b/bindings/dbus-xml/org-asuslinux-platform-4.xml @@ -1,6 +1,5 @@ - +