Added working implementation of the G14 Slash ledstrip

This commit is contained in:
jochen@g14
2024-03-30 18:41:31 +01:00
parent cdc9ca7b58
commit 8cdc9773c9
20 changed files with 663 additions and 746 deletions

13
Cargo.lock generated
View File

@@ -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"

View File

@@ -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",

View File

@@ -467,12 +467,10 @@ fn handle_slash(
cmd: &SlashCommand,
) -> Result<(), Box<dyn std::error::Error>> {
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();

View File

@@ -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<bool>,
pub enabled: Option<bool>,
#[options(meta = "", help = "set brightness value <0-255>")]
pub brightness: Option<u8>,
#[options(meta = "", help = "set interval value <0-255>")]
pub interval: Option<u8>,
#[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<SlashMode>,
#[options(help = "list available animations")]
pub list: bool,
}

View File

@@ -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
}

View File

@@ -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,
}
}
}

View File

@@ -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<AtomicBool>,
// // 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(())

View File

@@ -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<Mutex<CtrlSlash>>);
/// 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();
}
@@ -92,3 +127,19 @@ impl CtrlSlashZbus {
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(())
}
}

View File

@@ -110,11 +110,15 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
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);
}
}

View File

@@ -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<AnimeError> for RogError {
}
}
impl From<SlashError> for RogError {
fn from(err: SlashError) -> Self {
RogError::Slash(err)
}
}
impl From<PlatformError> for RogError {
fn from(err: PlatformError) -> Self {
RogError::Platform(err)

View File

@@ -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<Output = Result<(), RogError>> + Send;
fn reload(&mut self) -> impl Future<Output = Result<(), RogError>> + Send;
}
pub trait ReloadAndNotify {
@@ -142,18 +142,18 @@ pub trait ReloadAndNotify {
&mut self,
signal_context: &SignalContext<'static>,
data: Self::Data,
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
) -> impl Future<Output = Result<(), RogError>> + Send;
}
pub trait ZbusRun {
fn add_to_server(self, server: &mut Connection)
-> impl std::future::Future<Output = ()> + Send;
-> impl Future<Output = ()> + Send;
fn add_to_server_helper(
iface: impl zbus::Interface,
path: &str,
server: &mut Connection,
) -> impl std::future::Future<Output = ()> + Send {
) -> impl Future<Output = ()> + Send {
async move {
server
.object_server()
@@ -182,7 +182,7 @@ pub trait CtrlTask {
fn create_tasks(
&self,
signal: SignalContext<'static>,
) -> impl std::future::Future<Output = Result<(), RogError>> + Send;
) -> impl Future<Output = Result<(), RogError>> + 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<Output = ()> + Send
) -> impl Future<Output = ()> + Send
where
F1: FnMut(bool) -> Fut1,
F2: FnMut(bool) -> Fut2,
@@ -309,13 +309,13 @@ pub async fn start_tasks<T>(
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(())
}

View File

@@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

View File

@@ -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> {

View File

@@ -1,13 +1,17 @@
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<bool>;
#[zbus(property)]
fn set_enabled(&self, value: bool) -> zbus::Result<()>;
/// Brightness property
#[zbus(property)]
@@ -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<u8>;
fn slash_mode(&self) -> zbus::Result<SlashMode>;
#[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<bool>;
#[zbus(property)]
fn set_enable_display(&self, value: bool) -> zbus::Result<()>;
}

View File

@@ -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
{
@@ -68,6 +73,28 @@ impl SlashMode {
}
}
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] {
[
SlashMode::Bounce.to_string(),
@@ -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,
}

View File

@@ -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;

View File

@@ -1,18 +0,0 @@
[package]
name = "slashctl"
license = "MPL-2.0"
version.workspace = true
authors = ["Luke <luke@ljones.dev>"]
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

View File

@@ -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<AtomicBool>,
// // Set to false when the thread exits
// thread_running: Arc<AtomicBool>,
}
impl CtrlSlash {
#[inline]
pub fn new() -> Result<CtrlSlash, SlashCtlError> {
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(())
}
}

View File

@@ -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<SlashError> for SlashCtlError {
fn from(err: SlashError) -> Self {
SlashCtlError::Slash(err)
}
}

View File

@@ -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<String> = 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(())
}