Fixes to slash merge

This commit is contained in:
Luke D. Jones
2024-04-10 09:13:26 +12:00
parent a737d240be
commit 564992719e
15 changed files with 194 additions and 174 deletions

5
Cargo.lock generated
View File

@@ -3517,6 +3517,7 @@ dependencies = [
"rog_aura", "rog_aura",
"rog_platform", "rog_platform",
"rog_profiles", "rog_profiles",
"rog_slash",
"zbus 4.1.2", "zbus 4.1.2",
] ]
@@ -3564,7 +3565,7 @@ dependencies = [
[[package]] [[package]]
name = "rog_slash" name = "rog_slash"
version = "6.0.0-alpha1" version = "6.0.0-alpha3"
dependencies = [ dependencies = [
"cargo-husky", "cargo-husky",
"dmi_id", "dmi_id",
@@ -3576,7 +3577,7 @@ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
"typeshare", "typeshare",
"zbus 4.0.1", "zbus 4.1.2",
] ]
[[package]] [[package]]

View File

@@ -19,6 +19,7 @@ use rog_dbus::zbus_anime::AnimeProxyBlocking;
use rog_dbus::zbus_aura::AuraProxyBlocking; use rog_dbus::zbus_aura::AuraProxyBlocking;
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking;
use rog_dbus::zbus_slash::SlashProxyBlocking;
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_slash::SlashMode; use rog_slash::SlashMode;
@@ -26,7 +27,7 @@ use zbus::blocking::Connection;
use crate::aura_cli::{AuraPowerStates, LedBrightness}; use crate::aura_cli::{AuraPowerStates, LedBrightness};
use crate::cli_opts::*; use crate::cli_opts::*;
use crate::slash_cli::{SlashCommand}; use crate::slash_cli::SlashCommand;
mod anime_cli; mod anime_cli;
mod aura_cli; mod aura_cli;
@@ -486,38 +487,35 @@ fn verify_brightness(brightness: f32) {
} }
} }
fn handle_slash( fn handle_slash(conn: &Connection, cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
dbus: &RogDbusClientBlocking<'_>, if (cmd.brightness.is_none()
cmd: &SlashCommand, && cmd.interval.is_none()
) -> Result<(), Box<dyn std::error::Error>> { && cmd.slash_mode.is_none()
if ( && !cmd.list
cmd.brightness.is_none() && && !cmd.enable
cmd.interval.is_none() && && !cmd.disable)
cmd.slash_mode.is_none() && || cmd.help
!cmd.list &&
!cmd.enable &&
!cmd.disable
) || cmd.help
{ {
println!("Missing arg or command\n\n{}", cmd.self_usage()); println!("Missing arg or command\n\n{}", cmd.self_usage());
if let Some(lst) = cmd.self_command_list() { if let Some(lst) = cmd.self_command_list() {
println!("\n{}", lst); println!("\n{}", lst);
} }
} }
let proxy = SlashProxyBlocking::new(conn)?;
if cmd.enable { if cmd.enable {
dbus.proxies().slash().set_enabled(true)?; proxy.set_enabled(true)?;
} }
if cmd.disable { if cmd.disable {
dbus.proxies().slash().set_enabled(false)?; proxy.set_enabled(false)?;
} }
if let Some(brightness) = cmd.brightness { if let Some(brightness) = cmd.brightness {
dbus.proxies().slash().set_brightness(brightness)?; proxy.set_brightness(brightness)?;
} }
if let Some(interval) = cmd.interval { if let Some(interval) = cmd.interval {
dbus.proxies().slash().set_interval(interval)?; proxy.set_interval(interval)?;
} }
if let Some(slash_mode) = cmd.slash_mode { if let Some(slash_mode) = cmd.slash_mode {
dbus.proxies().slash().set_slash_mode(slash_mode)?; proxy.set_slash_mode(slash_mode)?;
} }
if cmd.list { if cmd.list {
let res = SlashMode::list(); let res = SlashMode::list();

View File

@@ -17,4 +17,4 @@ pub struct SlashCommand {
pub slash_mode: Option<SlashMode>, pub slash_mode: Option<SlashMode>,
#[options(help = "list available animations")] #[options(help = "list available animations")]
pub list: bool, pub list: bool,
} }

View File

@@ -15,9 +15,9 @@ use crate::config::Config;
use crate::ctrl_anime::trait_impls::{CtrlAnimeZbus, ANIME_ZBUS_NAME, ANIME_ZBUS_PATH}; use crate::ctrl_anime::trait_impls::{CtrlAnimeZbus, ANIME_ZBUS_NAME, ANIME_ZBUS_PATH};
use crate::ctrl_aura::trait_impls::{CtrlAuraZbus, AURA_ZBUS_NAME, AURA_ZBUS_PATH}; 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::ctrl_fancurves::{CtrlFanCurveZbus, FAN_CURVE_ZBUS_NAME, FAN_CURVE_ZBUS_PATH};
use crate::ctrl_slash::trait_impls::{CtrlSlashZbus, SLASH_ZBUS_NAME, SLASH_ZBUS_PATH};
use crate::error::RogError; use crate::error::RogError;
use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify}; 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_NAME: &str = "Platform";
const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux"; const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux";

View File

@@ -1,6 +1,6 @@
use serde_derive::{Deserialize, Serialize};
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use rog_slash::{DeviceState, SlashMode}; use rog_slash::{DeviceState, SlashMode};
use serde_derive::{Deserialize, Serialize};
const CONFIG_FILE: &str = "slash.ron"; const CONFIG_FILE: &str = "slash.ron";
@@ -48,4 +48,4 @@ impl From<&SlashConfig> for DeviceState {
slash_mode: config.slash_mode, slash_mode: config.slash_mode,
} }
} }
} }

View File

@@ -3,9 +3,10 @@ pub mod trait_impls;
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use rog_slash::{SlashMode, SlashType};
use rog_slash::error::SlashError; use rog_slash::error::SlashError;
use rog_slash::usb::{get_slash_type, pkt_set_mode, pkt_set_options, pkts_for_init}; use rog_slash::usb::{get_slash_type, pkt_set_mode, pkt_set_options, pkts_for_init};
use rog_slash::{SlashMode, SlashType};
use crate::ctrl_slash::config::SlashConfig; use crate::ctrl_slash::config::SlashConfig;
use crate::error::RogError; use crate::error::RogError;
@@ -54,7 +55,7 @@ impl CtrlSlash {
}; };
let slash_type = get_slash_type()?; let slash_type = get_slash_type()?;
if slash_type == SlashType::Unknown { if slash_type == SlashType::Unknown {
return Err(RogError::Slash(SlashError::NoDevice)); return Err(RogError::Slash(SlashError::NoDevice));
} }
@@ -71,13 +72,16 @@ impl CtrlSlash {
} }
fn do_initialization(&self) -> Result<(), RogError> { fn do_initialization(&self) -> Result<(), RogError> {
let init_packets = pkts_for_init(); let init_packets = pkts_for_init();
self.node.write_bytes(&init_packets[0])?; self.node.write_bytes(&init_packets[0])?;
self.node.write_bytes(&init_packets[1])?; self.node.write_bytes(&init_packets[1])?;
// Apply config upon initialization // Apply config upon initialization
let option_packets = pkt_set_options(self.config.slash_enabled, self.config.slash_brightness, self.config.slash_interval); let option_packets = pkt_set_options(
self.config.slash_enabled,
self.config.slash_brightness,
self.config.slash_interval,
);
self.node.write_bytes(&option_packets)?; self.node.write_bytes(&option_packets)?;
let mode_packets = pkt_set_mode(self.config.slash_mode); let mode_packets = pkt_set_mode(self.config.slash_mode);
@@ -99,4 +103,4 @@ impl CtrlSlash {
self.node.write_bytes(&command_packets[1])?; self.node.write_bytes(&command_packets[1])?;
Ok(()) Ok(())
} }
} }

View File

@@ -1,14 +1,15 @@
use std::sync::Arc; use std::sync::Arc;
use log::warn;
use zbus::{Connection, interface, SignalContext};
use zbus::export::futures_util::lock::Mutex;
use config_traits::StdConfig; use config_traits::StdConfig;
use rog_slash::{DeviceState, SlashMode}; use log::warn;
use rog_slash::usb::{pkt_set_mode, pkt_set_options}; use rog_slash::usb::{pkt_set_mode, pkt_set_options};
use rog_slash::{DeviceState, SlashMode};
use zbus::export::futures_util::lock::Mutex;
use zbus::{interface, Connection, SignalContext};
use crate::ctrl_slash::CtrlSlash; use crate::ctrl_slash::CtrlSlash;
use crate::error::RogError; use crate::error::RogError;
pub const SLASH_ZBUS_NAME: &str = "Slash"; pub const SLASH_ZBUS_NAME: &str = "Slash";
pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux"; pub const SLASH_ZBUS_PATH: &str = "/org/asuslinux";
@@ -24,7 +25,6 @@ impl crate::ZbusRun for CtrlSlashZbus {
#[interface(name = "org.asuslinux.Slash")] #[interface(name = "org.asuslinux.Slash")]
impl CtrlSlashZbus { impl CtrlSlashZbus {
/// Get enabled or not /// Get enabled or not
#[zbus(property)] #[zbus(property)]
async fn enabled(&self) -> bool { async fn enabled(&self) -> bool {
@@ -35,9 +35,17 @@ impl CtrlSlashZbus {
/// Set enabled true or false /// Set enabled true or false
async fn set_enabled(&self, enabled: bool) { async fn set_enabled(&self, enabled: bool) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
let brightness = if enabled && lock.config.slash_brightness == 0 { 0x88 } else { lock.config.slash_brightness }; let brightness = if enabled && lock.config.slash_brightness == 0 {
0x88
} else {
lock.config.slash_brightness
};
lock.node lock.node
.write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) .write_bytes(&pkt_set_options(
enabled,
brightness,
lock.config.slash_interval,
))
.map_err(|err| { .map_err(|err| {
warn!("ctrl_slash::set_options {}", err); warn!("ctrl_slash::set_options {}", err);
}) })
@@ -60,7 +68,11 @@ impl CtrlSlashZbus {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
let enabled = brightness > 0; let enabled = brightness > 0;
lock.node lock.node
.write_bytes(&pkt_set_options(enabled, brightness, lock.config.slash_interval)) .write_bytes(&pkt_set_options(
enabled,
brightness,
lock.config.slash_interval,
))
.map_err(|err| { .map_err(|err| {
warn!("ctrl_slash::set_options {}", err); warn!("ctrl_slash::set_options {}", err);
}) })
@@ -81,7 +93,11 @@ impl CtrlSlashZbus {
async fn set_interval(&self, interval: u8) { async fn set_interval(&self, interval: u8) {
let mut lock = self.0.lock().await; let mut lock = self.0.lock().await;
lock.node lock.node
.write_bytes(&pkt_set_options(lock.config.slash_enabled, lock.config.slash_brightness, interval)) .write_bytes(&pkt_set_options(
lock.config.slash_enabled,
lock.config.slash_brightness,
interval,
))
.map_err(|err| { .map_err(|err| {
warn!("ctrl_slash::set_options {}", err); warn!("ctrl_slash::set_options {}", err);
}) })
@@ -142,4 +158,4 @@ impl crate::Reloadable for CtrlSlashZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
Ok(()) Ok(())
} }
} }

View File

@@ -11,13 +11,13 @@ use asusd::ctrl_anime::CtrlAnime;
use asusd::ctrl_aura::manager::AuraManager; use asusd::ctrl_aura::manager::AuraManager;
use asusd::ctrl_fancurves::CtrlFanCurveZbus; use asusd::ctrl_fancurves::CtrlFanCurveZbus;
use asusd::ctrl_platform::CtrlPlatform; use asusd::ctrl_platform::CtrlPlatform;
use asusd::ctrl_slash::config::SlashConfig;
use asusd::ctrl_slash::trait_impls::CtrlSlashZbus;
use asusd::ctrl_slash::CtrlSlash;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2, StdConfigLoad3}; use config_traits::{StdConfig, StdConfigLoad, StdConfigLoad2, StdConfigLoad3};
use log::{error, info}; use log::{error, info};
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
use asusd::ctrl_slash::config::SlashConfig;
use asusd::ctrl_slash::CtrlSlash;
use asusd::ctrl_slash::trait_impls::CtrlSlashZbus;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -114,7 +114,8 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl))); let zbus = CtrlSlashZbus(Arc::new(Mutex::new(ctrl)));
// Currently, the Slash has no need for a loop watching power events, however, // 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 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) // (It has a built-in power on animation which plays when u plug in the power
// supply)
let sig_ctx = CtrlSlashZbus::signal_context(&connection)?; let sig_ctx = CtrlSlashZbus::signal_context(&connection)?;
start_tasks(zbus, &mut connection, sig_ctx).await?; start_tasks(zbus, &mut connection, sig_ctx).await?;
} }

View File

@@ -3,14 +3,14 @@
pub mod config; pub mod config;
/// Control of anime matrix display /// Control of anime matrix display
pub mod ctrl_anime; pub mod ctrl_anime;
/// Control of Slash led bar
pub mod ctrl_slash;
/// Keyboard LED brightness control, RGB, and LED display modes /// Keyboard LED brightness control, RGB, and LED display modes
pub mod ctrl_aura; pub mod ctrl_aura;
/// Control platform profiles + fan-curves if available /// Control platform profiles + fan-curves if available
pub mod ctrl_fancurves; pub mod ctrl_fancurves;
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode /// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
pub mod ctrl_platform; pub mod ctrl_platform;
/// Control of Slash led bar
pub mod ctrl_slash;
pub mod error; pub mod error;
@@ -146,8 +146,7 @@ pub trait ReloadAndNotify {
} }
pub trait ZbusRun { pub trait ZbusRun {
fn add_to_server(self, server: &mut Connection) fn add_to_server(self, server: &mut Connection) -> impl Future<Output = ()> + Send;
-> impl Future<Output = ()> + Send;
fn add_to_server_helper( fn add_to_server_helper(
iface: impl zbus::Interface, iface: impl zbus::Interface,
@@ -318,4 +317,4 @@ where
zbus_clone.create_tasks(signal_ctx).await.ok(); zbus_clone.create_tasks(signal_ctx).await.ok();
Ok(()) Ok(())
} }

View File

@@ -41,13 +41,17 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name; let board_name = dmi.board_name;
let prod_family = dmi.product_family; let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}"); info!("Running on {board_name}, product: {prod_family}");
// let is_rog_ally = prod_family == "RC71L"; let is_rog_ally = prod_family == "RC71L";
// tmp-dir must live to the end of program life // tmp-dir must live to the end of program life
let _tmp_dir = tempfile::Builder::new() let _tmp_dir = match tempfile::Builder::new()
.prefix("rog-gui") .prefix("rog-gui")
.rand_bytes(0) .rand_bytes(0)
.tempdir().unwrap_or_else(|_| on_tmp_dir_exists().unwrap()); .tempdir()
{
Ok(tmp) => tmp,
Err(_) => on_tmp_dir_exists().unwrap(),
};
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -80,7 +84,8 @@ async fn main() -> Result<()> {
Err(_e) => { Err(_e) => {
// TODO: show an error window // TODO: show an error window
Vec::default() Vec::default()
}); }
};
// Startup // Startup
let mut config = Config::new().load(); let mut config = Config::new().load();
@@ -122,8 +127,7 @@ async fn main() -> Result<()> {
init_tray(supported_properties, states.clone(), config.clone()); init_tray(supported_properties, states.clone(), config.clone());
} }
thread_local! { pub static UI: std::cell::RefCell<Option<MainWindow>> = Default::default()} thread_local! { pub static UI: std::cell::RefCell<Option<MainWindow>> = Default::default()};
;
i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); i_slint_backend_selector::with_platform(|_| Ok(())).unwrap();
let mut do_once = !startup_in_background; let mut do_once = !startup_in_background;
@@ -180,7 +184,7 @@ async fn main() -> Result<()> {
} }
}); });
}) })
.unwrap(); .unwrap();
} else { } else {
if buf[1] == QUIT_APP { if buf[1] == QUIT_APP {
slint::quit_event_loop().unwrap(); slint::quit_event_loop().unwrap();
@@ -202,7 +206,7 @@ async fn main() -> Result<()> {
} }
}); });
}) })
.unwrap(); .unwrap();
} }
} }
} }

View File

@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-04-09 09:23+0000\n" "POT-Creation-Date: 2024-04-09 21:13+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,46 +12,6 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
#: rog-control-center/ui/main_window.slint:50
msgctxt "MainWindow"
msgid "ROG"
msgstr ""
#: rog-control-center/ui/main_window.slint:52
msgctxt "Menu1"
msgid "System Control"
msgstr ""
#: rog-control-center/ui/main_window.slint:53
msgctxt "Menu2"
msgid "Keyboard Aura"
msgstr ""
#: rog-control-center/ui/main_window.slint:54
msgctxt "Menu3"
msgid "AniMe Matrix"
msgstr ""
#: rog-control-center/ui/main_window.slint:55
msgctxt "Menu4"
msgid "Fan Curves"
msgstr ""
#: rog-control-center/ui/main_window.slint:56
msgctxt "Menu5"
msgid "App Settings"
msgstr ""
#: rog-control-center/ui/main_window.slint:57
msgctxt "Menu6"
msgid "About"
msgstr ""
#: rog-control-center/ui/main_window.slint:69
msgctxt "MainWindow"
msgid "Quit"
msgstr ""
#: rog-control-center/ui/pages/anime.slint:6 #: rog-control-center/ui/pages/anime.slint:6
msgctxt "Anime Brightness" msgctxt "Anime Brightness"
msgid "Off" msgid "Off"
@@ -197,46 +157,6 @@ msgctxt "PageAppSettings"
msgid "Enable change notifications" msgid "Enable change notifications"
msgstr "" 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/fans.slint:27 #: rog-control-center/ui/pages/fans.slint:27
msgctxt "FanTab" msgctxt "FanTab"
msgid "This fan is not avilable on this machine" msgid "This fan is not avilable on this machine"
@@ -442,6 +362,46 @@ msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" 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/types/aura_types.slint:46 #: rog-control-center/ui/types/aura_types.slint:46
msgctxt "Aura power zone" msgctxt "Aura power zone"
msgid "Logo" msgid "Logo"
@@ -652,3 +612,43 @@ msgctxt "AuraPowerGroup"
msgid "Shutdown" msgid "Shutdown"
msgstr "" 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 ""

View File

@@ -1,5 +1,5 @@
use zbus::proxy;
use rog_slash::SlashMode; use rog_slash::SlashMode;
use zbus::proxy;
#[proxy( #[proxy(
interface = "org.asuslinux.Slash", interface = "org.asuslinux.Slash",
@@ -10,25 +10,24 @@ trait Slash {
/// EnableDisplay property /// EnableDisplay property
#[zbus(property)] #[zbus(property)]
fn enabled(&self) -> zbus::Result<bool>; fn enabled(&self) -> zbus::Result<bool>;
// #[zbus(property)] #[zbus(property)]
fn set_enabled(&self, value: bool) -> zbus::Result<()>; fn set_enabled(&self, value: bool) -> zbus::Result<()>;
/// Brightness property /// Brightness property
#[zbus(property)] #[zbus(property)]
fn brightness(&self) -> zbus::Result<u8>; fn brightness(&self) -> zbus::Result<u8>;
// #[zbus(property)] #[zbus(property)]
fn set_brightness(&self, value: u8) -> zbus::Result<()>; fn set_brightness(&self, value: u8) -> zbus::Result<()>;
/// Interval property /// Interval property
#[zbus(property)] #[zbus(property)]
fn interval(&self) -> zbus::Result<u8>; fn interval(&self) -> zbus::Result<u8>;
// #[zbus(property)] #[zbus(property)]
fn set_interval(&self, value: u8) -> zbus::Result<()>; fn set_interval(&self, value: u8) -> zbus::Result<()>;
/// Slash modes property /// Slash modes property
#[zbus(property)] #[zbus(property)]
fn slash_mode(&self) -> zbus::Result<SlashMode>; fn slash_mode(&self) -> zbus::Result<SlashMode>;
// #[zbus(property)] #[zbus(property)]
fn set_slash_mode(&self, value: SlashMode) -> zbus::Result<()>; fn set_slash_mode(&self, value: SlashMode) -> zbus::Result<()>;
} }

View File

@@ -17,6 +17,7 @@ pub enum SlashType {
impl FromStr for SlashType { impl FromStr for SlashType {
type Err = SlashError; type Err = SlashError;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(match s { Ok(match s {
"ga403" | "GA403" => Self::GA403, "ga403" | "GA403" => Self::GA403,
@@ -32,8 +33,8 @@ pub enum SlashMode {
Bounce = 0x10, Bounce = 0x10,
Slash = 0x12, Slash = 0x12,
Loading = 0x13, Loading = 0x13,
BitStream = 0x1D, BitStream = 0x1d,
Transmission = 0x1A, Transmission = 0x1a,
Flow = 0x19, Flow = 0x19,
Flux = 0x25, Flux = 0x25,
Phantom = 0x24, Phantom = 0x24,
@@ -77,7 +78,6 @@ impl FromStr for SlashMode {
} }
} }
impl Display for SlashMode { impl Display for SlashMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match &self { let str = match &self {
@@ -102,7 +102,6 @@ impl Display for SlashMode {
} }
impl SlashMode { impl SlashMode {
pub fn list() -> [String; 15] { pub fn list() -> [String; 15] {
[ [
SlashMode::Bounce.to_string(), SlashMode::Bounce.to_string(),
@@ -134,4 +133,3 @@ pub struct DeviceState {
pub slash_interval: u8, pub slash_interval: u8,
pub slash_mode: SlashMode, pub slash_mode: SlashMode,
} }

View File

@@ -9,4 +9,4 @@ pub mod error;
/// Provides const methods to create the USB HID control packets /// Provides const methods to create the USB HID control packets
pub mod usb; pub mod usb;
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");

View File

@@ -9,18 +9,18 @@
//! Step 1 needs to be applied only on fresh system boot. //! Step 1 needs to be applied only on fresh system boot.
use dmi_id::DMIID; use dmi_id::DMIID;
#[cfg(feature = "dbus")] #[cfg(feature = "dbus")]
use crate::error::SlashError; use crate::error::SlashError;
use crate::{SlashMode, SlashType}; use crate::{SlashMode, SlashType};
const PACKET_SIZE: usize = 128; const PACKET_SIZE: usize = 128;
const DEV_PAGE: u8 = 0x5e; const DEV_PAGE: u8 = 0x5e;
pub const VENDOR_ID: u16 = 0x0B05; pub const VENDOR_ID: u16 = 0x0b05;
pub const PROD_ID: u16 = 0x193B; pub const PROD_ID: u16 = 0x193b;
pub const PROD_ID_STR: &str = "193B"; pub const PROD_ID_STR: &str = "193B";
pub type SlashUsbPacket = [u8;PACKET_SIZE]; pub type SlashUsbPacket = [u8; PACKET_SIZE];
/// `get_anime_type` is very broad, matching on part of the laptop board name /// `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 /// only. For this reason `find_node()` must be used also to verify if the USB
@@ -43,53 +43,53 @@ pub fn get_slash_type() -> Result<SlashType, SlashError> {
/// start after the laptop boots. /// start after the laptop boots.
#[inline] #[inline]
pub const fn pkts_for_init() -> [SlashUsbPacket; 2] { pub const fn pkts_for_init() -> [SlashUsbPacket; 2] {
let mut pkt1 = [0;PACKET_SIZE]; let mut pkt1 = [0; PACKET_SIZE];
pkt1[0] = DEV_PAGE; pkt1[0] = DEV_PAGE;
pkt1[1] = 0xD7; pkt1[1] = 0xd7;
pkt1[2] = 0x00; pkt1[2] = 0x00;
pkt1[3] = 0x00; pkt1[3] = 0x00;
pkt1[4] = 0x01; pkt1[4] = 0x01;
pkt1[5] = 0xAC; pkt1[5] = 0xac;
let mut pkt2 = [0;PACKET_SIZE]; let mut pkt2 = [0; PACKET_SIZE];
pkt2[0] = DEV_PAGE; pkt2[0] = DEV_PAGE;
pkt2[1] = 0xD2; pkt2[1] = 0xd2;
pkt2[2] = 0x02; pkt2[2] = 0x02;
pkt2[3] = 0x01; pkt2[3] = 0x01;
pkt2[4] = 0x08; pkt2[4] = 0x08;
pkt2[5] = 0xAB; pkt2[5] = 0xab;
[pkt1, pkt2] [pkt1, pkt2]
} }
#[inline] #[inline]
pub const fn pkt_save() -> SlashUsbPacket { pub const fn pkt_save() -> SlashUsbPacket {
let mut pkt = [0;PACKET_SIZE]; let mut pkt = [0; PACKET_SIZE];
pkt[0] = DEV_PAGE; pkt[0] = DEV_PAGE;
pkt[1] = 0xD4; pkt[1] = 0xd4;
pkt[2] = 0x00; pkt[2] = 0x00;
pkt[3] = 0x00; pkt[3] = 0x00;
pkt[4] = 0x01; pkt[4] = 0x01;
pkt[5] = 0xAB; pkt[5] = 0xab;
pkt pkt
} }
#[inline] #[inline]
pub const fn pkt_set_mode(mode: SlashMode) -> [SlashUsbPacket; 2] { pub const fn pkt_set_mode(mode: SlashMode) -> [SlashUsbPacket; 2] {
let mut pkt1 = [0;PACKET_SIZE]; let mut pkt1 = [0; PACKET_SIZE];
pkt1[0] = DEV_PAGE; pkt1[0] = DEV_PAGE;
pkt1[1] = 0x02; pkt1[1] = 0x02;
pkt1[2] = 0x03; pkt1[2] = 0x03;
pkt1[3] = 0x00; pkt1[3] = 0x00;
pkt1[4] = 0x0C; pkt1[4] = 0x0c;
let mut pkt2 = [0;PACKET_SIZE]; let mut pkt2 = [0; PACKET_SIZE];
pkt2[0] = DEV_PAGE; pkt2[0] = DEV_PAGE;
pkt2[1] = 0xD3; pkt2[1] = 0xd3;
pkt2[2] = 0x04; pkt2[2] = 0x04;
pkt2[3] = 0x00; pkt2[3] = 0x00;
pkt2[4] = 0x0C; pkt2[4] = 0x0c;
pkt2[5] = 0x01; pkt2[5] = 0x01;
pkt2[6] = mode as u8; pkt2[6] = mode as u8;
pkt2[7] = 0x02; pkt2[7] = 0x02;
@@ -110,19 +110,19 @@ pub const fn pkt_set_mode(mode: SlashMode) -> [SlashUsbPacket; 2] {
pub const fn pkt_set_options(enabled: bool, brightness: u8, interval: u8) -> SlashUsbPacket { pub const fn pkt_set_options(enabled: bool, brightness: u8, interval: u8) -> SlashUsbPacket {
let status_byte = if enabled { 0x01 } else { 0x00 }; let status_byte = if enabled { 0x01 } else { 0x00 };
let mut pkt = [0;PACKET_SIZE]; let mut pkt = [0; PACKET_SIZE];
pkt[0] = DEV_PAGE; pkt[0] = DEV_PAGE;
pkt[1] = 0xD3; pkt[1] = 0xd3;
pkt[2] = 0x03; pkt[2] = 0x03;
pkt[3] = 0x01; pkt[3] = 0x01;
pkt[4] = 0x08; pkt[4] = 0x08;
pkt[5] = 0xAB; pkt[5] = 0xab;
pkt[6] = 0xFF; pkt[6] = 0xff;
pkt[7] = 0x01; pkt[7] = 0x01;
pkt[8] = status_byte; pkt[8] = status_byte;
pkt[9] = 0x06; pkt[9] = 0x06;
pkt[10] = brightness; pkt[10] = brightness;
pkt[11] = 0xFF; pkt[11] = 0xff;
pkt[12] = interval; pkt[12] = interval;
pkt pkt