Compare commits

...

5 Commits

Author SHA1 Message Date
Luke Jones ae8ce83583 Fix slash enable 2025-02-17 11:38:29 +13:00
Luke Jones 5c3348a9f5 Add small env fixes for Ally
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-16 23:18:58 +13:00
Luke Jones f299ffeb6e Disable skia again, new release 2025-02-16 21:46:04 +13:00
Luke Jones 21c468cf02 Update supergfx
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-16 11:50:56 +13:00
Luke Jones 7f12f62ad5 Temp 2025-02-16 09:38:33 +13:00
22 changed files with 628 additions and 315 deletions
+16
View File
@@ -2,6 +2,22 @@
## [Unreleased]
## [v6.1.7]
### Changed
- Fix Slash display enable
## [v6.1.6]
### Changed
- Disable skia bindings for UI again. It causes failures in build pipelines and requires extra dependencies.
## [v6.1.5]
### Changed
- Update dependencies
- Fix fan-curve proxy type signatures
## [v6.1.4]
### Changed
Generated
+395 -194
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -1,5 +1,5 @@
[workspace.package]
version = "6.1.4"
version = "6.1.7"
rust-version = "1.82"
license = "MPL-2.0"
readme = "README.md"
@@ -44,8 +44,8 @@ smol = "^2.0"
mio = "0.8.11"
futures-util = "0.3.31"
zbus = "5.1.1"
logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] }
zbus = "5.5.0"
logind-zbus = { version = "5.2.0" } #, default-features = false, features = ["non_blocking"] }
serde = { version = "^1.0", features = ["serde_derive"] }
ron = "*"
@@ -66,7 +66,7 @@ gif = "^0.12.0"
versions = "6.2"
notify-rust = { version = "4.11.4", features = ["z", "async"] }
notify-rust = { version = "4.11.5", features = ["z", "async"] }
sg = { git = "https://github.com/flukejones/sg-rs.git" }
+3 -3
View File
@@ -48,7 +48,7 @@ The LED controller (e.g, aura) enables setting many of the factory modes availab
#### Supported laptops
There are over 60 supported laptops as of 01-01-2023. Please see [the rog-aura crate readme for further details](/rog-aura/README.md).
There are over 80 supported laptops as of 01-01-2023. Please see [the rog-aura crate readme for further details](/rog-aura/README.md).
### Charge control
@@ -420,13 +420,13 @@ To switch to next/previous Aura modes you will need to bind both the aura keys (
**Next**
```
asusctl led-mode -n
asusctl aura -n
```
**Previous**
```
asusctl led-mode -p
asusctl aura -p
```
To switch Fan/Thermal profiles you need to bind the Fn+F5 key to `asusctl profile -n`.
+4
View File
@@ -575,6 +575,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
&& cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none()
// && cmd.show_on_lid_closed.is_none()
&& cmd.mode.is_none()
&& !cmd.list
&& !cmd.enable
@@ -620,6 +621,9 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?;
}
// if let Some(show) = cmd.show_on_lid_closed {
// proxy.set_show_on_lid_closed(show)?;
// }
}
if cmd.list {
let res = SlashMode::list();
+2
View File
@@ -26,6 +26,8 @@ pub struct SlashCommand {
pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>,
// #[options(short = "L", meta = "", help = "Show the animation on lid closed")]
// pub show_on_lid_closed: Option<bool>,
#[options(
short = "w",
meta = "",
+2
View File
@@ -18,6 +18,7 @@ pub struct SlashConfig {
pub show_on_sleep: bool,
pub show_on_battery: bool,
pub show_battery_warning: bool,
pub show_on_lid_closed: bool,
}
impl Default for SlashConfig {
@@ -33,6 +34,7 @@ impl Default for SlashConfig {
show_on_sleep: true,
show_on_battery: true,
show_battery_warning: true,
show_on_lid_closed: true,
}
}
}
+7 -8
View File
@@ -4,8 +4,7 @@ use config::SlashConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
use rog_slash::SlashType;
use rog_slash::usb::{slash_pkt_enable, slash_pkt_init, slash_pkt_options, slash_pkt_set_mode};
use crate::error::RogError;
@@ -46,14 +45,14 @@ impl Slash {
pub async fn do_initialization(&self) -> Result<(), RogError> {
// Don't try to initialise these models as the asus drivers already did
let config = self.config.lock().await;
if !matches!(config.slash_type, SlashType::GA605 | SlashType::GU605) {
for pkt in &pkts_for_init(config.slash_type) {
self.write_bytes(pkt).await?;
}
for pkt in &slash_pkt_init(config.slash_type) {
self.write_bytes(pkt).await?;
}
self.write_bytes(&slash_pkt_enable(config.slash_type, config.enabled))
.await?;
// Apply config upon initialization
let option_packets = get_options_packet(
let option_packets = slash_pkt_options(
config.slash_type,
config.enabled,
config.brightness,
@@ -61,7 +60,7 @@ impl Slash {
);
self.write_bytes(&option_packets).await?;
let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
let mode_packets = slash_pkt_set_mode(config.slash_type, config.display_mode);
// self.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?;
+48 -18
View File
@@ -1,8 +1,9 @@
use config_traits::StdConfig;
use log::{debug, error, warn};
use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode,
slash_pkt_battery_saver, slash_pkt_boot, slash_pkt_enable, slash_pkt_lid_closed,
slash_pkt_low_battery, slash_pkt_options, slash_pkt_save, slash_pkt_set_mode,
slash_pkt_shutdown, slash_pkt_sleep,
};
use rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath;
@@ -58,7 +59,14 @@ impl SlashZbus {
config.brightness
};
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_enable(config.slash_type, enabled))
.await
.map_err(|err| {
warn!("ctrl_slash::enable {}", err);
})
.ok();
self.0
.write_bytes(&slash_pkt_options(
config.slash_type,
enabled,
brightness,
@@ -88,7 +96,7 @@ impl SlashZbus {
let mut config = self.0.lock_config().await;
let enabled = brightness > 0;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type,
enabled,
brightness,
@@ -116,7 +124,7 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type, config.enabled, config.brightness, interval,
))
.await
@@ -140,10 +148,12 @@ impl SlashZbus {
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
let command_packets = pkt_set_mode(config.slash_type, mode);
let command_packets = slash_pkt_set_mode(config.slash_type, mode);
// self.node.write_bytes(&command_packets[0])?;
self.0.write_bytes(&command_packets[1]).await?;
self.0.write_bytes(&pkt_save(config.slash_type)).await?;
self.0
.write_bytes(&slash_pkt_save(config.slash_type))
.await?;
config.display_mode = mode;
config.write();
@@ -167,7 +177,7 @@ impl SlashZbus {
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_boot_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_boot(config.slash_type, enable))
.await?;
config.show_on_boot = enable;
config.write();
@@ -184,7 +194,7 @@ impl SlashZbus {
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_sleep(config.slash_type, enable))
.await?;
config.show_on_sleep = enable;
config.write();
@@ -201,7 +211,7 @@ impl SlashZbus {
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_shutdown(config.slash_type, enable))
.await?;
config.show_on_shutdown = enable;
config.write();
@@ -218,7 +228,7 @@ impl SlashZbus {
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_battery_saver(config.slash_type, enable))
.await?;
config.show_on_battery = enable;
config.write();
@@ -235,12 +245,32 @@ impl SlashZbus {
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
.write_bytes(&slash_pkt_low_battery(config.slash_type, enable))
.await?;
config.show_battery_warning = enable;
config.write();
Ok(())
}
#[zbus(property)]
async fn show_on_lid_closed(&self) -> zbus::fdo::Result<bool> {
let config = self.0.lock_config().await;
Ok(config.show_on_lid_closed)
}
#[zbus(property)]
async fn set_show_on_lid_closed(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await;
self.0
.write_bytes(&slash_pkt_lid_closed(config.slash_type, enable))
.await?;
self.0
.write_bytes(&slash_pkt_save(config.slash_type))
.await?;
config.show_on_lid_closed = enable;
config.write();
Ok(())
}
}
impl Reloadable for SlashZbus {
@@ -248,7 +278,7 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings");
let config = self.0.lock_config().await;
self.0
.write_bytes(&get_options_packet(
.write_bytes(&slash_pkt_options(
config.slash_type,
config.enabled,
config.brightness,
@@ -272,12 +302,12 @@ impl Reloadable for SlashZbus {
};
}
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
write_bytes_with_warning!(slash_pkt_boot, show_on_boot, "show_on_boot");
write_bytes_with_warning!(slash_pkt_sleep, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(slash_pkt_shutdown, show_on_shutdown, "show_on_shutdown");
write_bytes_with_warning!(slash_pkt_battery_saver, show_on_battery, "show_on_battery");
write_bytes_with_warning!(
get_low_battery_packet,
slash_pkt_low_battery,
show_battery_warning,
"show_battery_warning"
);
+1 -1
View File
@@ -107,7 +107,7 @@ macro_rules! task_watch_item_notify {
&self,
signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt;
use futures_util::StreamExt;
let ctrl = self.clone();
concat_idents::concat_idents!(watch_fn = monitor_, $name {
+2 -2
View File
@@ -38,7 +38,7 @@
(
device_name: "FA617NS",
product_id: "",
layout_name: "fa617ns",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
@@ -872,4 +872,4 @@
advanced_type: None,
power_zones: [Ally],
),
])
])
+3 -2
View File
@@ -49,10 +49,11 @@ versions.workspace = true
git = "https://github.com/slint-ui/slint.git"
default-features = false
features = [
"gettext",
"compat-1-2",
"gettext",
"accessibility",
"backend-winit-wayland",
"renderer-winit-femtovg",
"renderer-femtovg",
# "renderer-skia-opengl",
]
+102 -63
View File
@@ -35,10 +35,21 @@ async fn main() -> Result<()> {
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
// use
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
dbg!(1);
if !gamescope.is_empty() {
dbg!(2);
env::set_var("WAYLAND_DISPLAY", gamescope);
}
// gamescope-0
else if let Ok(wayland) = env::var("WAYLAND_DISPLAY") {
dbg!(3);
if wayland.is_empty() {
dbg!(4);
env::set_var("WAYLAND_DISPLAY", "gamescope-0");
}
}
}
dbg!("SHITR");
// Try to open a proxy and check for app state first
{
@@ -92,7 +103,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name;
let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
let args: Vec<String> = args().skip(1).collect();
@@ -163,73 +174,101 @@ async fn main() -> Result<()> {
thread::spawn(move || {
let mut state = AppState::StartingUp;
loop {
// save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(app_state) = app_state.lock() {
state = *app_state;
}
if is_rog_ally {
let config_copy_2 = config.clone();
let newui = setup_window(config.clone());
newui.window().on_close_requested(move || {
exit(0);
});
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut app_state) = app_state.lock() {
*app_state = AppState::MainWindowOpen;
}
let config_copy = config.clone();
let app_state_copy = app_state.clone();
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let app_state_copy = app_state_copy.clone();
let mut ui = ui.borrow_mut();
if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap();
ui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
} else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy);
newui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::BeforeRendering = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen =
config.lock().is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
ui.replace(newui);
}
});
})
.unwrap();
} else if state == AppState::QuitApp {
slint::quit_event_loop().unwrap();
exit(0);
} else if state != AppState::MainWindowOpen {
if let Ok(config) = config.lock() {
if !config.run_in_background {
slint::quit_event_loop().unwrap();
exit(0);
})
.ok();
} else {
// save as a var, don't hold the lock the entire time or deadlocks happen
if let Ok(app_state) = app_state.lock() {
state = *app_state;
}
// This sleep is required to give the event loop time to react
sleep(Duration::from_millis(300));
if state == AppState::MainWindowShouldOpen {
if let Ok(mut app_state) = app_state.lock() {
*app_state = AppState::MainWindowOpen;
}
let config_copy = config.clone();
let app_state_copy = app_state.clone();
slint::invoke_from_event_loop(move || {
UI.with(|ui| {
let app_state_copy = app_state_copy.clone();
let mut ui = ui.borrow_mut();
if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap();
ui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
} else {
let config_copy_2 = config_copy.clone();
let newui = setup_window(config_copy);
newui.window().on_close_requested(move || {
if let Ok(mut app_state) = app_state_copy.lock() {
*app_state = AppState::MainWindowClosed;
}
slint::CloseRequestResponse::HideWindow
});
let ui_copy = newui.as_weak();
newui
.window()
.set_rendering_notifier(move |s, _| {
if let slint::RenderingState::RenderingSetup = s {
let config = config_copy_2.clone();
ui_copy
.upgrade_in_event_loop(move |w| {
let fullscreen = config
.lock()
.is_ok_and(|c| c.start_fullscreen);
if fullscreen && !w.window().is_fullscreen() {
w.window().set_fullscreen(fullscreen);
}
})
.ok();
}
})
.ok();
ui.replace(newui);
}
});
})
.unwrap();
} else if state == AppState::QuitApp {
slint::quit_event_loop().unwrap();
exit(0);
} else if state != AppState::MainWindowOpen {
if let Ok(config) = config.lock() {
if !config.run_in_background {
slint::quit_event_loop().unwrap();
exit(0);
}
}
}
}
+1 -1
View File
@@ -9,6 +9,7 @@ use std::process::Command;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use futures_util::StreamExt;
use log::{debug, error, info, warn};
use notify_rust::{Hint, Notification, Timeout, Urgency};
use rog_platform::platform::GpuMode;
@@ -19,7 +20,6 @@ use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::runtime::Runtime;
use tokio::task::JoinHandle;
use zbus::export::futures_util::StreamExt;
use crate::config::Config;
use crate::error::Result;
+1 -1
View File
@@ -50,7 +50,7 @@ macro_rules! set_ui_callbacks {
tokio::spawn(async move {
let mut x = proxy_copy.receive().await;
concat_idents::concat_idents!(set = set_, $proxy_fn {
use zbus::export::futures_util::StreamExt;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy.upgrade_in_event_loop(move |handle| {
+1 -1
View File
@@ -62,7 +62,7 @@ pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
let anime_copy = anime.clone();
tokio::spawn(async move {
let mut x = anime_copy.receive_builtin_animations_changed().await;
use zbus::export::futures_util::StreamExt;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
+1 -1
View File
@@ -211,7 +211,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
// spawn required since the while let never exits
tokio::spawn(async move {
let mut x = proxy_copy.receive_led_mode_data_changed().await;
use zbus::export::futures_util::StreamExt;
use futures_util::StreamExt;
while let Some(e) = x.next().await {
if let Ok(out) = e.get().await {
handle_copy
+3 -3
View File
@@ -111,21 +111,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let Ok(balanced) = fans
.fan_curve_data(PlatformProfile::Balanced)
.await
.map_err(|e| error!("{e:}"))
.map_err(|e| error!("Couldn't get balanced data: {e:}"))
else {
return;
};
let Ok(perf) = fans
.fan_curve_data(PlatformProfile::Performance)
.await
.map_err(|e| error!("{e:}"))
.map_err(|e| error!("Couldn't get performance data: {e:}"))
else {
return;
};
let Ok(quiet) = fans
.fan_curve_data(PlatformProfile::Quiet)
.await
.map_err(|e| error!("{e:}"))
.map_err(|e| error!("Couldn't get quiet data: {e:}"))
else {
return;
};
@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-02-14 09:21+0000\n"
"POT-Creation-Date: 2025-02-15 22:50+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"
+6
View File
@@ -60,4 +60,10 @@ pub trait Slash {
fn show_on_sleep(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_sleep(&self, value: bool) -> zbus::Result<()>;
/// ShowOnLidClosed property
#[zbus(property)]
fn show_on_lid_closed(&self) -> zbus::Result<bool>;
#[zbus(property)]
fn set_show_on_lid_closed(&self, value: bool) -> zbus::Result<()>;
}
+2 -2
View File
@@ -175,7 +175,7 @@ impl Display for GpuMode {
}
}
#[repr(i32)]
#[repr(u32)]
#[derive(
Deserialize,
Serialize,
@@ -191,7 +191,7 @@ impl Display for GpuMode {
Clone,
Copy,
)]
#[zvariant(signature = "i")]
#[zvariant(signature = "u")]
/// `platform_profile` in asus_wmi
pub enum PlatformProfile {
#[default]
+23 -10
View File
@@ -62,7 +62,7 @@ pub const fn report_id(slash_type: SlashType) -> u8 {
/// Get the two device initialization packets. These are required for device
/// start after the laptop boots.
#[inline]
pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
pub fn slash_pkt_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
let report_id = report_id(slash_type);
let mut pkt1 = [0; PACKET_SIZE];
@@ -87,7 +87,20 @@ pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
}
#[inline]
pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket {
pub const fn slash_pkt_enable(slash_type: SlashType, enabled: bool) -> SlashUsbPacket {
let mut pkt = [0; PACKET_SIZE];
pkt[0] = report_id(slash_type);
pkt[1] = 0xd8;
pkt[2] = 0x02;
pkt[3] = 0x00;
pkt[4] = 0x01;
pkt[5] = if enabled { 0x00 } else { 0x80 };
pkt
}
#[inline]
pub const fn slash_pkt_save(slash_type: SlashType) -> SlashUsbPacket {
let mut pkt = [0; PACKET_SIZE];
pkt[0] = report_id(slash_type);
pkt[1] = 0xd4;
@@ -100,7 +113,7 @@ pub const fn pkt_save(slash_type: SlashType) -> SlashUsbPacket {
}
#[inline]
pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] {
pub const fn slash_pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPacket; 2] {
let report_id = report_id(slash_type);
let mut pkt1 = [0; PACKET_SIZE];
pkt1[0] = report_id;
@@ -133,7 +146,7 @@ pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPa
]
}
pub const fn get_options_packet(
pub const fn slash_pkt_options(
slash_type: SlashType,
enabled: bool,
brightness: u8,
@@ -146,7 +159,7 @@ pub const fn get_options_packet(
]
}
pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_boot(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -154,7 +167,7 @@ pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
]
}
pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_sleep(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = (!enabled) as u8;
[
@@ -162,7 +175,7 @@ pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12]
]
}
pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_low_battery(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -170,7 +183,7 @@ pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8
]
}
pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
pub const fn slash_pkt_shutdown(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
@@ -178,7 +191,7 @@ pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 1
]
}
pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [u8; 6] {
pub const fn slash_pkt_battery_saver(slash_type: SlashType, enabled: bool) -> [u8; 6] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[
@@ -186,7 +199,7 @@ pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [
]
}
pub const fn get_lid_closed_packet(slash_type: SlashType, enabled: bool) -> [u8; 7] {
pub const fn slash_pkt_lid_closed(slash_type: SlashType, enabled: bool) -> [u8; 7] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[