mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Unify the laptop aura power stuff
This commit is contained in:
58
Cargo.lock
generated
58
Cargo.lock
generated
@@ -236,9 +236,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-executor"
|
name = "async-executor"
|
||||||
version = "1.9.1"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316"
|
checksum = "5f98c37cf288e302c16ef6c8472aad1e034c6c84ce5ea7b8101c98eb4a802fee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-lock 3.3.0",
|
"async-lock 3.3.0",
|
||||||
"async-task",
|
"async-task",
|
||||||
@@ -666,9 +666,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.90"
|
version = "1.0.91"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
|
checksum = "1fd97381a8cc6493395a5afc4c691c1084b3768db713b73aa215217aa245d153"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -854,7 +854,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "const-field-offset"
|
name = "const-field-offset"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-field-offset-macro",
|
"const-field-offset-macro",
|
||||||
"field-offset",
|
"field-offset",
|
||||||
@@ -863,7 +863,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "const-field-offset-macro"
|
name = "const-field-offset-macro"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1168,9 +1168,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "drm"
|
name = "drm"
|
||||||
@@ -1877,9 +1877,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
version = "2.4.0"
|
version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e"
|
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crunchy",
|
"crunchy",
|
||||||
@@ -1931,7 +1931,7 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-backend-linuxkms"
|
name = "i-slint-backend-linuxkms"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"calloop",
|
"calloop",
|
||||||
"drm",
|
"drm",
|
||||||
@@ -1951,7 +1951,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-backend-qt"
|
name = "i-slint-backend-qt"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-field-offset",
|
"const-field-offset",
|
||||||
"i-slint-common",
|
"i-slint-common",
|
||||||
@@ -1963,7 +1963,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-backend-selector"
|
name = "i-slint-backend-selector"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"i-slint-backend-linuxkms",
|
"i-slint-backend-linuxkms",
|
||||||
@@ -1976,7 +1976,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-backend-winit"
|
name = "i-slint-backend-winit"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -2009,7 +2009,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-common"
|
name = "i-slint-common"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
@@ -2020,7 +2020,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-compiler"
|
name = "i-slint-compiler"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"by_address",
|
"by_address",
|
||||||
"codemap",
|
"codemap",
|
||||||
@@ -2049,7 +2049,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-core"
|
name = "i-slint-core"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"auto_enums",
|
"auto_enums",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -2094,7 +2094,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-core-macros"
|
name = "i-slint-core-macros"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.58",
|
"syn 2.0.58",
|
||||||
@@ -2103,7 +2103,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-renderer-femtovg"
|
name = "i-slint-renderer-femtovg"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"const-field-offset",
|
"const-field-offset",
|
||||||
@@ -2134,7 +2134,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "i-slint-renderer-skia"
|
name = "i-slint-renderer-skia"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -3651,9 +3651,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustversion"
|
name = "rustversion"
|
||||||
version = "1.0.14"
|
version = "1.0.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustybuzz"
|
name = "rustybuzz"
|
||||||
@@ -3901,7 +3901,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "slint"
|
name = "slint"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-field-offset",
|
"const-field-offset",
|
||||||
"i-slint-backend-selector",
|
"i-slint-backend-selector",
|
||||||
@@ -3917,7 +3917,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "slint-build"
|
name = "slint-build"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"i-slint-compiler",
|
"i-slint-compiler",
|
||||||
"spin_on",
|
"spin_on",
|
||||||
@@ -3928,7 +3928,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "slint-macros"
|
name = "slint-macros"
|
||||||
version = "1.6.0"
|
version = "1.6.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"i-slint-compiler",
|
"i-slint-compiler",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -4703,7 +4703,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "vtable"
|
name = "vtable"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-field-offset",
|
"const-field-offset",
|
||||||
"portable-atomic",
|
"portable-atomic",
|
||||||
@@ -4714,7 +4714,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "vtable-macro"
|
name = "vtable-macro"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#44cee9c31ea256c381f59b9e93d9579a3a8423e9"
|
source = "git+https://github.com/flukejones/sixtyfps.git?branch=feat/color_hsv#490f571f6c3242516bf2067f0e02cfd02ae76223"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -4993,9 +4993,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-wsapoll"
|
name = "winapi-wsapoll"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e"
|
checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ pub struct LedPowerCommand1 {
|
|||||||
pub help: bool,
|
pub help: bool,
|
||||||
#[options(meta = "", help = "Control if LEDs enabled while awake <true/false>")]
|
#[options(meta = "", help = "Control if LEDs enabled while awake <true/false>")]
|
||||||
pub awake: Option<bool>,
|
pub awake: Option<bool>,
|
||||||
#[options(meta = "", help = "Use with awake option <true/false>")]
|
#[options(help = "Use with awake option, if excluded defaults to false")]
|
||||||
pub keyboard: Option<bool>,
|
pub keyboard: bool,
|
||||||
#[options(meta = "", help = "Use with awake option <true/false>")]
|
#[options(help = "Use with awake option, if excluded defaults to false")]
|
||||||
pub lightbar: Option<bool>,
|
pub lightbar: bool,
|
||||||
#[options(meta = "", help = "Control boot animations <true/false>")]
|
#[options(meta = "", help = "Control boot animations <true/false>")]
|
||||||
pub boot: Option<bool>,
|
pub boot: Option<bool>,
|
||||||
#[options(meta = "", help = "Control suspend animations <true/false>")]
|
#[options(meta = "", help = "Control suspend animations <true/false>")]
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ use fan_curve_cli::FanCurveCommand;
|
|||||||
use gumdrop::{Opt, Options};
|
use gumdrop::{Opt, Options};
|
||||||
use rog_anime::usb::get_anime_type;
|
use rog_anime::usb::get_anime_type;
|
||||||
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
|
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
|
||||||
use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower};
|
use rog_aura::aura_detection::PowerZones;
|
||||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
|
||||||
|
use rog_aura::usb::AuraDevice;
|
||||||
use rog_aura::{self, AuraEffect};
|
use rog_aura::{self, AuraEffect};
|
||||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||||
@@ -572,8 +573,8 @@ fn handle_led_power1(
|
|||||||
if power.awake.is_none()
|
if power.awake.is_none()
|
||||||
&& power.sleep.is_none()
|
&& power.sleep.is_none()
|
||||||
&& power.boot.is_none()
|
&& power.boot.is_none()
|
||||||
&& power.keyboard.is_none()
|
&& !power.keyboard
|
||||||
&& power.lightbar.is_none()
|
&& !power.lightbar
|
||||||
{
|
{
|
||||||
if !power.help {
|
if !power.help {
|
||||||
println!("Missing arg or command\n");
|
println!("Missing arg or command\n");
|
||||||
@@ -582,15 +583,10 @@ fn handle_led_power1(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if dev_type.is_old_style() {
|
if dev_type.is_old_style() || dev_type.is_tuf_style() {
|
||||||
handle_led_power_1_do_1866(aura, power)?;
|
handle_led_power_1_do_1866(aura, power)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if dev_type.is_tuf_style() {
|
|
||||||
handle_led_power_1_do_tuf(aura, power)?;
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("These options are for keyboards of product ID 0x1866 or TUF only");
|
println!("These options are for keyboards of product ID 0x1866 or TUF only");
|
||||||
@@ -601,62 +597,24 @@ fn handle_led_power_1_do_1866(
|
|||||||
aura: &AuraProxyBlocking,
|
aura: &AuraProxyBlocking,
|
||||||
power: &LedPowerCommand1,
|
power: &LedPowerCommand1,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut enabled: Vec<LaptopOldAuraPower> = Vec::new();
|
let zone = if power.keyboard && power.lightbar {
|
||||||
let mut disabled: Vec<LaptopOldAuraPower> = Vec::new();
|
PowerZones::KeyboardAndLightbar
|
||||||
|
} else if power.lightbar {
|
||||||
let mut check = |e: Option<bool>, a: LaptopOldAuraPower| {
|
PowerZones::Lightbar
|
||||||
if let Some(arg) = e {
|
} else {
|
||||||
if arg {
|
PowerZones::Keyboard
|
||||||
enabled.push(a);
|
};
|
||||||
} else {
|
let states = LaptopAuraPower {
|
||||||
disabled.push(a);
|
states: vec![AuraPowerState {
|
||||||
}
|
zone,
|
||||||
}
|
boot: power.boot.unwrap_or_default(),
|
||||||
|
awake: power.awake.unwrap_or_default(),
|
||||||
|
sleep: power.sleep.unwrap_or_default(),
|
||||||
|
shutdown: false,
|
||||||
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
check(power.awake, LaptopOldAuraPower::Awake);
|
aura.set_led_power(states)?;
|
||||||
check(power.boot, LaptopOldAuraPower::Boot);
|
|
||||||
check(power.sleep, LaptopOldAuraPower::Sleep);
|
|
||||||
check(power.keyboard, LaptopOldAuraPower::Keyboard);
|
|
||||||
check(power.lightbar, LaptopOldAuraPower::Lightbar);
|
|
||||||
|
|
||||||
let data = AuraPowerDev {
|
|
||||||
old_rog: enabled,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
aura.set_led_power(data.clone())?; // TODO: verify this
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_led_power_1_do_tuf(
|
|
||||||
aura: &AuraProxyBlocking,
|
|
||||||
power: &LedPowerCommand1,
|
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let mut enabled: Vec<LaptopTufAuraPower> = Vec::new();
|
|
||||||
let mut disabled: Vec<LaptopTufAuraPower> = Vec::new();
|
|
||||||
|
|
||||||
let mut check = |e: Option<bool>, a: LaptopTufAuraPower| {
|
|
||||||
if let Some(arg) = e {
|
|
||||||
if arg {
|
|
||||||
enabled.push(a);
|
|
||||||
} else {
|
|
||||||
disabled.push(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
check(power.awake, LaptopTufAuraPower::Awake);
|
|
||||||
check(power.boot, LaptopTufAuraPower::Boot);
|
|
||||||
check(power.sleep, LaptopTufAuraPower::Sleep);
|
|
||||||
check(power.keyboard, LaptopTufAuraPower::Keyboard);
|
|
||||||
|
|
||||||
let data = AuraPowerDev {
|
|
||||||
tuf: enabled,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
aura.set_led_power(data.clone())?; // TODO: verify this
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -696,25 +654,30 @@ fn handle_led_power2(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let set = |power: &mut AuraPowerState, set_to: &AuraPowerStates| {
|
let mut states = aura.led_power()?;
|
||||||
power.boot = set_to.boot;
|
let mut set = |zone: PowerZones, set_to: &AuraPowerStates| {
|
||||||
power.awake = set_to.awake;
|
for state in states.states.iter_mut() {
|
||||||
power.sleep = set_to.sleep;
|
if state.zone == zone {
|
||||||
power.shutdown = set_to.shutdown;
|
state.boot = set_to.boot;
|
||||||
|
state.awake = set_to.awake;
|
||||||
|
state.sleep = set_to.sleep;
|
||||||
|
state.shutdown = set_to.shutdown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut enabled = aura.led_power()?;
|
|
||||||
if let Some(cmd) = &power.command {
|
if let Some(cmd) = &power.command {
|
||||||
match cmd {
|
match cmd {
|
||||||
aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(&mut enabled.rog.keyboard, k),
|
aura_cli::SetAuraZoneEnabled::Keyboard(k) => set(PowerZones::Keyboard, k),
|
||||||
aura_cli::SetAuraZoneEnabled::Logo(l) => set(&mut enabled.rog.logo, l),
|
aura_cli::SetAuraZoneEnabled::Logo(l) => set(PowerZones::Logo, l),
|
||||||
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(&mut enabled.rog.lightbar, l),
|
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
|
||||||
aura_cli::SetAuraZoneEnabled::Lid(l) => set(&mut enabled.rog.lid, l),
|
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
|
||||||
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(&mut enabled.rog.rear_glow, r),
|
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aura.set_led_power(enabled)?;
|
aura.set_led_power(states)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,112 +1,13 @@
|
|||||||
use std::collections::{BTreeMap, HashSet};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use config_traits::{StdConfig, StdConfigLoad};
|
use config_traits::{StdConfig, StdConfigLoad};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use rog_aura::aura_detection::LaptopLedData;
|
use rog_aura::aura_detection::LaptopLedData;
|
||||||
use rog_aura::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower};
|
use rog_aura::keyboard::{LaptopAuraPower, LaptopAuraType};
|
||||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
use rog_aura::usb::AuraDevice;
|
||||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Enable/disable LED control in various states such as
|
|
||||||
/// when the device is awake, suspended, shutting down or
|
|
||||||
/// booting.
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
||||||
pub enum AuraPowerConfig {
|
|
||||||
AuraDevTuf(HashSet<LaptopTufAuraPower>),
|
|
||||||
AuraDevRog1(HashSet<LaptopOldAuraPower>),
|
|
||||||
AuraDevRog2(LaptopAuraPower),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AuraPowerConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::AuraDevTuf(HashSet::default())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AuraPowerConfig {
|
|
||||||
/// Invalid for TUF laptops
|
|
||||||
pub fn to_bytes(control: &Self) -> [u8; 4] {
|
|
||||||
match control {
|
|
||||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0],
|
|
||||||
AuraPowerConfig::AuraDevRog1(c) => {
|
|
||||||
let c: Vec<LaptopOldAuraPower> = c.iter().copied().collect();
|
|
||||||
LaptopOldAuraPower::to_bytes(&c)
|
|
||||||
}
|
|
||||||
AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_tuf_bool_array(control: &Self) -> Option<[bool; 5]> {
|
|
||||||
if let Self::AuraDevTuf(c) = control {
|
|
||||||
return Some([
|
|
||||||
true,
|
|
||||||
c.contains(&LaptopTufAuraPower::Boot),
|
|
||||||
c.contains(&LaptopTufAuraPower::Awake),
|
|
||||||
c.contains(&LaptopTufAuraPower::Sleep),
|
|
||||||
c.contains(&LaptopTufAuraPower::Keyboard),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Self::AuraDevRog1(c) = control {
|
|
||||||
return Some([
|
|
||||||
true,
|
|
||||||
c.contains(&LaptopOldAuraPower::Boot),
|
|
||||||
c.contains(&LaptopOldAuraPower::Awake),
|
|
||||||
c.contains(&LaptopOldAuraPower::Sleep),
|
|
||||||
c.contains(&LaptopOldAuraPower::Keyboard),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_tuf(&mut self, power: LaptopTufAuraPower, on: bool) {
|
|
||||||
if let Self::AuraDevTuf(p) = self {
|
|
||||||
if on {
|
|
||||||
p.insert(power);
|
|
||||||
} else {
|
|
||||||
p.remove(&power);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_0x1866(&mut self, power: LaptopOldAuraPower, on: bool) {
|
|
||||||
if let Self::AuraDevRog1(p) = self {
|
|
||||||
if on {
|
|
||||||
p.insert(power);
|
|
||||||
} else {
|
|
||||||
p.remove(&power);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_0x19b6(&mut self, power: LaptopAuraPower) {
|
|
||||||
if let Self::AuraDevRog2(p) = self {
|
|
||||||
*p = power;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&AuraPowerConfig> for AuraPowerDev {
|
|
||||||
fn from(config: &AuraPowerConfig) -> Self {
|
|
||||||
match config {
|
|
||||||
AuraPowerConfig::AuraDevTuf(d) => AuraPowerDev {
|
|
||||||
tuf: d.iter().copied().collect(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
AuraPowerConfig::AuraDevRog1(d) => AuraPowerDev {
|
|
||||||
old_rog: d.iter().copied().collect(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
AuraPowerConfig::AuraDevRog2(d) => AuraPowerDev {
|
|
||||||
rog: d.clone(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
|
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
|
||||||
// #[serde(default)]
|
// #[serde(default)]
|
||||||
pub struct AuraConfig {
|
pub struct AuraConfig {
|
||||||
@@ -116,7 +17,7 @@ pub struct AuraConfig {
|
|||||||
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
||||||
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
|
pub multizone: Option<BTreeMap<AuraModeNum, Vec<AuraEffect>>>,
|
||||||
pub multizone_on: bool,
|
pub multizone_on: bool,
|
||||||
pub enabled: AuraPowerConfig,
|
pub enabled: LaptopAuraPower,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuraConfig {
|
impl AuraConfig {
|
||||||
@@ -151,22 +52,11 @@ impl AuraConfig {
|
|||||||
pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
|
pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
|
||||||
// create a default config here
|
// create a default config here
|
||||||
let enabled = if prod_id.is_new_style() {
|
let enabled = if prod_id.is_new_style() {
|
||||||
AuraPowerConfig::AuraDevRog2(LaptopAuraPower::new_all_on())
|
LaptopAuraPower::new(LaptopAuraType::New, support_data)
|
||||||
} else if prod_id.is_tuf_style() {
|
} else if prod_id.is_tuf_style() {
|
||||||
AuraPowerConfig::AuraDevTuf(HashSet::from([
|
LaptopAuraPower::new(LaptopAuraType::Tuf, support_data)
|
||||||
LaptopTufAuraPower::Awake,
|
|
||||||
LaptopTufAuraPower::Boot,
|
|
||||||
LaptopTufAuraPower::Sleep,
|
|
||||||
LaptopTufAuraPower::Keyboard,
|
|
||||||
]))
|
|
||||||
} else {
|
} else {
|
||||||
AuraPowerConfig::AuraDevRog1(HashSet::from([
|
LaptopAuraPower::new(LaptopAuraType::Old, support_data)
|
||||||
LaptopOldAuraPower::Awake,
|
|
||||||
LaptopOldAuraPower::Boot,
|
|
||||||
LaptopOldAuraPower::Sleep,
|
|
||||||
LaptopOldAuraPower::Keyboard,
|
|
||||||
LaptopOldAuraPower::Lightbar,
|
|
||||||
]))
|
|
||||||
};
|
};
|
||||||
let mut config = AuraConfig {
|
let mut config = AuraConfig {
|
||||||
config_name: format!("aura_{prod_id:?}.ron"),
|
config_name: format!("aura_{prod_id:?}.ron"),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use rog_platform::hid_raw::HidRaw;
|
|||||||
use rog_platform::keyboard_led::KeyboardLed;
|
use rog_platform::keyboard_led::KeyboardLed;
|
||||||
use zbus::zvariant::OwnedObjectPath;
|
use zbus::zvariant::OwnedObjectPath;
|
||||||
|
|
||||||
use super::config::{AuraConfig, AuraPowerConfig};
|
use super::config::AuraConfig;
|
||||||
use crate::ctrl_aura::manager::dbus_path_for_dev;
|
use crate::ctrl_aura::manager::dbus_path_for_dev;
|
||||||
use crate::error::RogError;
|
use crate::error::RogError;
|
||||||
|
|
||||||
@@ -191,12 +191,14 @@ impl CtrlKbdLed {
|
|||||||
/// leds/side leds LED active
|
/// leds/side leds LED active
|
||||||
pub(super) fn set_power_states(&mut self) -> Result<(), RogError> {
|
pub(super) fn set_power_states(&mut self) -> Result<(), RogError> {
|
||||||
if let LEDNode::KbdLed(platform) = &mut self.led_node {
|
if let LEDNode::KbdLed(platform) = &mut self.led_node {
|
||||||
if let Some(pwr) = AuraPowerConfig::to_tuf_bool_array(&self.config.enabled) {
|
// TODO: tuf bool array
|
||||||
let buf = [1, pwr[1] as u8, pwr[2] as u8, pwr[3] as u8, pwr[4] as u8];
|
// if let Some(pwr) =
|
||||||
platform.set_kbd_rgb_state(&buf)?;
|
// AuraPowerConfig::to_tuf_bool_array(&self.config.enabled) {
|
||||||
}
|
// let buf = [1, pwr[1] as u8, pwr[2] as u8, pwr[3] as u8,
|
||||||
|
// pwr[4] as u8]; platform.set_kbd_rgb_state(&buf)?;
|
||||||
|
// }
|
||||||
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||||
let bytes = AuraPowerConfig::to_bytes(&self.config.enabled);
|
let bytes = self.config.enabled.to_bytes(self.led_prod.into());
|
||||||
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||||
|
|
||||||
hid_raw.write_bytes(&message)?;
|
hid_raw.write_bytes(&message)?;
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use std::sync::Arc;
|
|||||||
use config_traits::StdConfig;
|
use config_traits::StdConfig;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use rog_aura::aura_detection::PowerZones;
|
use rog_aura::aura_detection::PowerZones;
|
||||||
use rog_aura::keyboard::UsbPackets;
|
use rog_aura::keyboard::{LaptopAuraPower, UsbPackets};
|
||||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
use rog_aura::usb::AuraDevice;
|
||||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||||
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
||||||
use zbus::export::futures_util::StreamExt;
|
use zbus::export::futures_util::StreamExt;
|
||||||
@@ -167,9 +167,9 @@ impl CtrlAuraZbus {
|
|||||||
|
|
||||||
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
// As property doesn't work for AuraPowerDev (complexity of serialization?)
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
async fn led_power(&self) -> AuraPowerDev {
|
async fn led_power(&self) -> LaptopAuraPower {
|
||||||
let ctrl = self.0.lock().await;
|
let ctrl = self.0.lock().await;
|
||||||
AuraPowerDev::from(&ctrl.config.enabled)
|
ctrl.config.enabled.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a variety of states, input is array of enum.
|
/// Set a variety of states, input is array of enum.
|
||||||
@@ -177,16 +177,16 @@ impl CtrlAuraZbus {
|
|||||||
///
|
///
|
||||||
/// For Modern ROG devices the "enabled" flag is ignored.
|
/// For Modern ROG devices the "enabled" flag is ignored.
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
async fn set_led_power(&mut self, options: AuraPowerDev) -> Result<(), ZbErr> {
|
async fn set_led_power(&mut self, options: LaptopAuraPower) -> Result<(), ZbErr> {
|
||||||
let mut ctrl = self.0.lock().await;
|
let mut ctrl = self.0.lock().await;
|
||||||
// TODO: set the older devices
|
for opt in options.states {
|
||||||
// for p in options.tuf {
|
let zone = opt.zone;
|
||||||
// ctrl.config.enabled.set_tuf(p, enabled);
|
for config in ctrl.config.enabled.states.iter_mut() {
|
||||||
// }
|
if config.zone == zone {
|
||||||
// for p in options.old_rog {
|
*config = opt;
|
||||||
// ctrl.config.enabled.set_0x1866(p, enabled);
|
}
|
||||||
// }
|
}
|
||||||
ctrl.config.enabled.set_0x19b6(options.rog);
|
}
|
||||||
ctrl.config.write();
|
ctrl.config.write();
|
||||||
Ok(ctrl.set_power_states().map_err(|e| {
|
Ok(ctrl.set_power_states().map_err(|e| {
|
||||||
warn!("{}", e);
|
warn!("{}", e);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub struct LedSupportFile(Vec<LaptopLedData>);
|
|||||||
derive(Type, Value, OwnedValue),
|
derive(Type, Value, OwnedValue),
|
||||||
zvariant(signature = "u")
|
zvariant(signature = "u")
|
||||||
)]
|
)]
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Copy, Clone)]
|
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Debug, Default, Copy, Clone)]
|
||||||
pub enum PowerZones {
|
pub enum PowerZones {
|
||||||
/// The logo on some laptop lids
|
/// The logo on some laptop lids
|
||||||
#[default]
|
#[default]
|
||||||
@@ -44,6 +44,8 @@ pub enum PowerZones {
|
|||||||
Lid = 3,
|
Lid = 3,
|
||||||
/// The led strip on the rear of some laptops
|
/// The led strip on the rear of some laptops
|
||||||
RearGlow = 4,
|
RearGlow = 4,
|
||||||
|
/// On pre-2021 laptops there is either 1 or 2 zones used
|
||||||
|
KeyboardAndLightbar = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
|
|||||||
@@ -8,15 +8,64 @@ use typeshare::typeshare;
|
|||||||
#[cfg(feature = "dbus")]
|
#[cfg(feature = "dbus")]
|
||||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||||
|
|
||||||
use crate::aura_detection::PowerZones;
|
use crate::aura_detection::{LaptopLedData, PowerZones};
|
||||||
|
use crate::usb::AuraDevice;
|
||||||
|
|
||||||
|
// Possible API:
|
||||||
|
// # Common parts:
|
||||||
|
// - boot
|
||||||
|
// - awake
|
||||||
|
// - sleep
|
||||||
|
// ## New only
|
||||||
|
// - shutdown
|
||||||
|
//
|
||||||
|
// ## Only only
|
||||||
|
// - keyboard
|
||||||
|
// - lightbar
|
||||||
|
// ## TUF only
|
||||||
|
// - keyboard
|
||||||
|
//
|
||||||
|
// # New has parts:
|
||||||
|
// - keyboard
|
||||||
|
// - lightbar
|
||||||
|
// - logo
|
||||||
|
// - lid
|
||||||
|
// - rear_glow
|
||||||
|
|
||||||
|
#[typeshare]
|
||||||
|
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub enum LaptopAuraType {
|
||||||
|
New = 0,
|
||||||
|
Old = 1,
|
||||||
|
Tuf = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AuraDevice> for LaptopAuraType {
|
||||||
|
fn from(value: AuraDevice) -> Self {
|
||||||
|
if value.is_old_style() {
|
||||||
|
Self::Old
|
||||||
|
} else if value.is_tuf_style() {
|
||||||
|
Self::Tuf
|
||||||
|
} else {
|
||||||
|
Self::New
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Meaning of this struct depends on the laptop generation.
|
||||||
|
/// - 2021+, the struct is a single zone with 4 states
|
||||||
|
/// - pre-2021, the struct is 1 or 2 zones and 3 states
|
||||||
|
/// - Tuf, the struct is 1 zone and 3 states
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct AuraPowerState {
|
pub struct AuraPowerState {
|
||||||
|
pub zone: PowerZones,
|
||||||
pub boot: bool,
|
pub boot: bool,
|
||||||
pub awake: bool,
|
pub awake: bool,
|
||||||
pub sleep: bool,
|
pub sleep: bool,
|
||||||
|
/// Ignored for pre-2021 and Tuf
|
||||||
pub shutdown: bool,
|
pub shutdown: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,17 +73,77 @@ impl Default for AuraPowerState {
|
|||||||
/// Defaults all to off
|
/// Defaults all to off
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
boot: false,
|
zone: PowerZones::Keyboard,
|
||||||
awake: false,
|
boot: true,
|
||||||
sleep: false,
|
awake: true,
|
||||||
shutdown: false,
|
sleep: true,
|
||||||
|
shutdown: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuraPowerState {
|
impl AuraPowerState {
|
||||||
pub fn to_byte(&self, zone: PowerZones) -> u32 {
|
fn default_for(zone: PowerZones) -> Self {
|
||||||
match zone {
|
Self {
|
||||||
|
zone,
|
||||||
|
boot: true,
|
||||||
|
awake: true,
|
||||||
|
sleep: true,
|
||||||
|
shutdown: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tuf_to_bytes(&self) -> Vec<u8> {
|
||||||
|
todo!("0s and 1s for bool array")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Bits for older 0x1866 keyboard model
|
||||||
|
///
|
||||||
|
/// Keybord and Lightbar require Awake, Boot and Sleep apply to both
|
||||||
|
/// Keybord and Lightbar regardless of if either are enabled (or Awake is
|
||||||
|
/// enabled)
|
||||||
|
///
|
||||||
|
/// | Byte 1 | Byte 2 | Byte 3 | function | hex |
|
||||||
|
/// |------------|------------|------------|----------|----------|
|
||||||
|
/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 |
|
||||||
|
/// | 0000, 1000 | 0000, 0000 | 0000, 0000 | Keyboard | 08,00,00 |
|
||||||
|
/// | 0000, 0100 | 0000, 0101 | 0000, 0000 | Lightbar | 04,05,00 |
|
||||||
|
/// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 |
|
||||||
|
/// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 |
|
||||||
|
/// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | |
|
||||||
|
fn old_to_bytes(&self) -> Vec<u8> {
|
||||||
|
let mut a: u32 = 0;
|
||||||
|
if self.awake {
|
||||||
|
a |= OldAuraPower::Awake as u32;
|
||||||
|
}
|
||||||
|
if self.boot {
|
||||||
|
a |= OldAuraPower::Boot as u32;
|
||||||
|
}
|
||||||
|
if self.sleep {
|
||||||
|
a |= OldAuraPower::Sleep as u32;
|
||||||
|
}
|
||||||
|
if matches!(
|
||||||
|
self.zone,
|
||||||
|
PowerZones::Keyboard | PowerZones::KeyboardAndLightbar
|
||||||
|
) {
|
||||||
|
a |= OldAuraPower::Keyboard as u32;
|
||||||
|
}
|
||||||
|
if matches!(
|
||||||
|
self.zone,
|
||||||
|
PowerZones::Lightbar | PowerZones::KeyboardAndLightbar
|
||||||
|
) {
|
||||||
|
a |= OldAuraPower::Lightbar as u32;
|
||||||
|
}
|
||||||
|
vec![
|
||||||
|
((a & 0xff0000) >> 16) as u8,
|
||||||
|
((a & 0xff00) >> 8) as u8,
|
||||||
|
(a & 0xff) as u8,
|
||||||
|
0x00,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_to_byte(&self) -> u32 {
|
||||||
|
match self.zone {
|
||||||
PowerZones::Logo => {
|
PowerZones::Logo => {
|
||||||
self.boot as u32
|
self.boot as u32
|
||||||
| (self.awake as u32) << 2
|
| (self.awake as u32) << 2
|
||||||
@@ -65,126 +174,100 @@ impl AuraPowerState {
|
|||||||
| (self.sleep as u32) << (23 + 3)
|
| (self.sleep as u32) << (23 + 3)
|
||||||
| (self.shutdown as u32) << (23 + 4)
|
| (self.shutdown as u32) << (23 + 4)
|
||||||
}
|
}
|
||||||
|
PowerZones::KeyboardAndLightbar => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Track and control the Aura keyboard power state
|
|
||||||
///
|
|
||||||
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
|
|
||||||
///
|
|
||||||
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
|
|
||||||
/// |--------|---------|---------|---------|----------|
|
|
||||||
/// |00000001| 00000000| 00000000| 00000000|boot_logo_|
|
|
||||||
/// |00000010| 00000000| 00000000| 00000000|boot_keyb_|
|
|
||||||
/// |00000100| 00000000| 00000000| 00000000|awake_logo|
|
|
||||||
/// |00001000| 00000000| 00000000| 00000000|awake_keyb|
|
|
||||||
/// |00010000| 00000000| 00000000| 00000000|sleep_logo|
|
|
||||||
/// |00100000| 00000000| 00000000| 00000000|sleep_keyb|
|
|
||||||
/// |01000000| 00000000| 00000000| 00000000|shut_logo_|
|
|
||||||
/// |10000000| 00000000| 00000000| 00000000|shut_keyb_|
|
|
||||||
/// |00000000| 00000010| 00000000| 00000000|boot_bar__|
|
|
||||||
/// |00000000| 00000100| 00000000| 00000000|awake_bar_|
|
|
||||||
/// |00000000| 00001000| 00000000| 00000000|sleep_bar_|
|
|
||||||
/// |00000000| 00010000| 00000000| 00000000|shut_bar__|
|
|
||||||
/// |00000000| 00000000| 00000001| 00000000|boot_lid__|
|
|
||||||
/// |00000000| 00000000| 00000010| 00000000|awkae_lid_|
|
|
||||||
/// |00000000| 00000000| 00000100| 00000000|sleep_lid_|
|
|
||||||
/// |00000000| 00000000| 00001000| 00000000|shut_lid__|
|
|
||||||
/// |00000000| 00000000| 00000000| 00000001|boot_rear_|
|
|
||||||
/// |00000000| 00000000| 00000000| 00000010|awake_rear|
|
|
||||||
/// |00000000| 00000000| 00000000| 00000100|sleep_rear|
|
|
||||||
/// |00000000| 00000000| 00000000| 00001000|shut_rear_|
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct LaptopAuraPower {
|
pub struct LaptopAuraPower {
|
||||||
pub keyboard: AuraPowerState,
|
pub states: Vec<AuraPowerState>,
|
||||||
pub logo: AuraPowerState,
|
|
||||||
pub lightbar: AuraPowerState,
|
|
||||||
pub lid: AuraPowerState,
|
|
||||||
pub rear_glow: AuraPowerState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LaptopAuraPower {
|
impl LaptopAuraPower {
|
||||||
pub fn new_all_on() -> Self {
|
/// # Bits for newer 0x18c6, 0x19B6, 0x1a30, keyboard models
|
||||||
Self {
|
///
|
||||||
keyboard: AuraPowerState {
|
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Label |
|
||||||
boot: true,
|
/// |--------|---------|---------|---------|----------|
|
||||||
awake: true,
|
/// |00000001| 00000000| 00000000| 00000000|boot_logo_|
|
||||||
sleep: true,
|
/// |00000010| 00000000| 00000000| 00000000|boot_keyb_|
|
||||||
shutdown: true,
|
/// |00000100| 00000000| 00000000| 00000000|awake_logo|
|
||||||
},
|
/// |00001000| 00000000| 00000000| 00000000|awake_keyb|
|
||||||
logo: AuraPowerState {
|
/// |00010000| 00000000| 00000000| 00000000|sleep_logo|
|
||||||
boot: true,
|
/// |00100000| 00000000| 00000000| 00000000|sleep_keyb|
|
||||||
awake: true,
|
/// |01000000| 00000000| 00000000| 00000000|shut_logo_|
|
||||||
sleep: true,
|
/// |10000000| 00000000| 00000000| 00000000|shut_keyb_|
|
||||||
shutdown: true,
|
/// |00000000| 00000010| 00000000| 00000000|boot_bar__|
|
||||||
},
|
/// |00000000| 00000100| 00000000| 00000000|awake_bar_|
|
||||||
lightbar: AuraPowerState {
|
/// |00000000| 00001000| 00000000| 00000000|sleep_bar_|
|
||||||
boot: true,
|
/// |00000000| 00010000| 00000000| 00000000|shut_bar__|
|
||||||
awake: true,
|
/// |00000000| 00000000| 00000001| 00000000|boot_lid__|
|
||||||
sleep: true,
|
/// |00000000| 00000000| 00000010| 00000000|awkae_lid_|
|
||||||
shutdown: true,
|
/// |00000000| 00000000| 00000100| 00000000|sleep_lid_|
|
||||||
},
|
/// |00000000| 00000000| 00001000| 00000000|shut_lid__|
|
||||||
lid: AuraPowerState {
|
/// |00000000| 00000000| 00000000| 00000001|boot_rear_|
|
||||||
boot: true,
|
/// |00000000| 00000000| 00000000| 00000010|awake_rear|
|
||||||
awake: true,
|
/// |00000000| 00000000| 00000000| 00000100|sleep_rear|
|
||||||
sleep: true,
|
/// |00000000| 00000000| 00000000| 00001000|shut_rear_|
|
||||||
shutdown: true,
|
fn new_to_bytes(&self) -> Vec<u8> {
|
||||||
},
|
|
||||||
rear_glow: AuraPowerState {
|
|
||||||
boot: true,
|
|
||||||
awake: true,
|
|
||||||
sleep: true,
|
|
||||||
shutdown: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_bytes(&self) -> [u8; 4] {
|
|
||||||
let mut a: u32 = 0;
|
let mut a: u32 = 0;
|
||||||
a |= self.keyboard.to_byte(PowerZones::Keyboard);
|
for state in self.states.iter() {
|
||||||
a |= self.logo.to_byte(PowerZones::Logo);
|
a |= state.new_to_byte();
|
||||||
a |= self.lid.to_byte(PowerZones::Lid);
|
}
|
||||||
a |= self.lightbar.to_byte(PowerZones::Lightbar);
|
vec![
|
||||||
a |= self.rear_glow.to_byte(PowerZones::RearGlow);
|
|
||||||
[
|
|
||||||
(a & 0xff) as u8,
|
(a & 0xff) as u8,
|
||||||
((a & 0xff00) >> 8) as u8,
|
((a & 0xff00) >> 8) as u8,
|
||||||
((a & 0xff0000) >> 16) as u8,
|
((a & 0xff0000) >> 16) as u8,
|
||||||
((a & 0xff000000) >> 24) as u8,
|
((a & 0xff000000) >> 24) as u8,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[typeshare]
|
// TODO: use support data to setup correct zones
|
||||||
#[cfg_attr(
|
pub fn new(aura_type: LaptopAuraType, _support_data: &LaptopLedData) -> Self {
|
||||||
feature = "dbus",
|
match aura_type {
|
||||||
derive(Type, Value, OwnedValue),
|
LaptopAuraType::New => {
|
||||||
zvariant(signature = "u")
|
let mut states = Vec::new();
|
||||||
)]
|
for zone in [
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
PowerZones::Keyboard,
|
||||||
#[repr(u32)]
|
PowerZones::Lid,
|
||||||
pub enum LaptopTufAuraPower {
|
PowerZones::Lightbar,
|
||||||
Boot = 0,
|
PowerZones::Logo,
|
||||||
Awake = 1,
|
PowerZones::RearGlow,
|
||||||
Sleep = 2,
|
] {
|
||||||
Keyboard = 3,
|
states.push(AuraPowerState::default_for(zone))
|
||||||
}
|
}
|
||||||
|
Self { states }
|
||||||
|
}
|
||||||
|
LaptopAuraType::Old => Self {
|
||||||
|
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)],
|
||||||
|
},
|
||||||
|
LaptopAuraType::Tuf => Self {
|
||||||
|
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl LaptopTufAuraPower {
|
pub fn to_bytes(&self, aura_type: LaptopAuraType) -> Vec<u8> {
|
||||||
pub const fn dev_id() -> &'static str {
|
match aura_type {
|
||||||
"tuf"
|
LaptopAuraType::New => self.new_to_bytes(),
|
||||||
|
LaptopAuraType::Old => self
|
||||||
|
.states
|
||||||
|
.first()
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.old_to_bytes(),
|
||||||
|
LaptopAuraType::Tuf => self
|
||||||
|
.states
|
||||||
|
.first()
|
||||||
|
.cloned()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.tuf_to_bytes(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Bits for older 0x1866 keyboard model
|
|
||||||
///
|
|
||||||
/// Keybord and Lightbar require Awake, Boot and Sleep apply to both
|
|
||||||
/// Keybord and Lightbar regardless of if either are enabled (or Awake is
|
|
||||||
/// enabled)
|
|
||||||
///
|
|
||||||
/// | Byte 1 | Byte 2 | Byte 3 | function | hex |
|
/// | Byte 1 | Byte 2 | Byte 3 | function | hex |
|
||||||
/// |------------|------------|------------|----------|----------|
|
/// |------------|------------|------------|----------|----------|
|
||||||
/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 |
|
/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | Awake | 00,00,02 |
|
||||||
@@ -193,98 +276,97 @@ impl LaptopTufAuraPower {
|
|||||||
/// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 |
|
/// | 1100, 0011 | 0001, 0010 | 0000, 1001 | Boot/Sht | c3,12,09 |
|
||||||
/// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 |
|
/// | 0011, 0000 | 0000, 1000 | 0000, 0100 | Sleep | 30,08,04 |
|
||||||
/// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | |
|
/// | 1111, 1111 | 0001, 1111 | 0000, 1111 | all on | |
|
||||||
#[typeshare]
|
|
||||||
#[cfg_attr(
|
|
||||||
feature = "dbus",
|
|
||||||
derive(Type, Value, OwnedValue),
|
|
||||||
zvariant(signature = "u")
|
|
||||||
)]
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum LaptopOldAuraPower {
|
enum OldAuraPower {
|
||||||
Awake = 0x000002,
|
Awake = 0x000002,
|
||||||
Keyboard = 0x080000,
|
|
||||||
Lightbar = 0x040500,
|
|
||||||
Boot = 0xc31209,
|
Boot = 0xc31209,
|
||||||
Sleep = 0x300804,
|
Sleep = 0x300804,
|
||||||
|
Keyboard = 0x080000,
|
||||||
|
Lightbar = 0x040500,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<LaptopOldAuraPower> for u32 {
|
impl BitOr<OldAuraPower> for OldAuraPower {
|
||||||
fn from(a: LaptopOldAuraPower) -> Self {
|
|
||||||
a as u32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LaptopOldAuraPower {
|
|
||||||
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
|
|
||||||
let mut a: u32 = 0;
|
|
||||||
for n in control {
|
|
||||||
a |= *n as u32;
|
|
||||||
}
|
|
||||||
[
|
|
||||||
((a & 0xff0000) >> 16) as u8,
|
|
||||||
((a & 0xff00) >> 8) as u8,
|
|
||||||
(a & 0xff) as u8,
|
|
||||||
0x00,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn dev_id() -> &'static str {
|
|
||||||
"0x1866"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BitOr<LaptopOldAuraPower> for LaptopOldAuraPower {
|
|
||||||
type Output = u32;
|
type Output = u32;
|
||||||
|
|
||||||
fn bitor(self, rhs: LaptopOldAuraPower) -> Self::Output {
|
fn bitor(self, rhs: OldAuraPower) -> Self::Output {
|
||||||
self as u32 | rhs as u32
|
self as u32 | rhs as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BitAnd<LaptopOldAuraPower> for LaptopOldAuraPower {
|
impl BitAnd<OldAuraPower> for OldAuraPower {
|
||||||
type Output = u32;
|
type Output = u32;
|
||||||
|
|
||||||
fn bitand(self, rhs: LaptopOldAuraPower) -> Self::Output {
|
fn bitand(self, rhs: OldAuraPower) -> Self::Output {
|
||||||
self as u32 & rhs as u32
|
self as u32 & rhs as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<OldAuraPower> for u32 {
|
||||||
|
fn from(a: OldAuraPower) -> Self {
|
||||||
|
a as u32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopOldAuraPower};
|
use crate::aura_detection::{LaptopLedData, PowerZones};
|
||||||
|
use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopAuraType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_0x1866_control_bytes() {
|
fn check_0x1866_control_bytes() {
|
||||||
let bytes = [LaptopOldAuraPower::Keyboard, LaptopOldAuraPower::Awake];
|
let state = AuraPowerState {
|
||||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
zone: PowerZones::Keyboard,
|
||||||
|
awake: true,
|
||||||
|
boot: false,
|
||||||
|
sleep: false,
|
||||||
|
shutdown: false,
|
||||||
|
};
|
||||||
|
let bytes = state.old_to_bytes();
|
||||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||||
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
|
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
|
||||||
|
|
||||||
let bytes = [LaptopOldAuraPower::Lightbar, LaptopOldAuraPower::Awake];
|
let state = AuraPowerState {
|
||||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
zone: PowerZones::Lightbar,
|
||||||
|
awake: true,
|
||||||
|
boot: false,
|
||||||
|
sleep: false,
|
||||||
|
shutdown: false,
|
||||||
|
};
|
||||||
|
let bytes = state.old_to_bytes();
|
||||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||||
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
|
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
|
||||||
|
|
||||||
let bytes = [LaptopOldAuraPower::Sleep];
|
let bytes = AuraPowerState {
|
||||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
zone: PowerZones::Keyboard,
|
||||||
|
awake: false,
|
||||||
|
boot: false,
|
||||||
|
sleep: true,
|
||||||
|
shutdown: false,
|
||||||
|
};
|
||||||
|
let bytes = bytes.old_to_bytes();
|
||||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||||
assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]);
|
assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]);
|
||||||
|
|
||||||
let bytes = [LaptopOldAuraPower::Boot];
|
let bytes = AuraPowerState {
|
||||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
zone: PowerZones::Keyboard,
|
||||||
|
awake: false,
|
||||||
|
boot: true,
|
||||||
|
sleep: false,
|
||||||
|
shutdown: false,
|
||||||
|
};
|
||||||
|
let bytes = bytes.old_to_bytes();
|
||||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||||
assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]);
|
assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]);
|
||||||
|
|
||||||
let bytes = [
|
let power = AuraPowerState {
|
||||||
LaptopOldAuraPower::Keyboard,
|
zone: PowerZones::KeyboardAndLightbar,
|
||||||
LaptopOldAuraPower::Lightbar,
|
awake: true,
|
||||||
LaptopOldAuraPower::Awake,
|
boot: true,
|
||||||
LaptopOldAuraPower::Sleep,
|
sleep: true,
|
||||||
LaptopOldAuraPower::Boot,
|
shutdown: false,
|
||||||
];
|
};
|
||||||
|
|
||||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
let bytes = power.old_to_bytes();
|
||||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||||
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
|
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
|
||||||
}
|
}
|
||||||
@@ -292,7 +374,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn check_0x19b6_control_bytes_binary_rep() {
|
fn check_0x19b6_control_bytes_binary_rep() {
|
||||||
fn to_binary_string(power: &LaptopAuraPower) -> String {
|
fn to_binary_string(power: &LaptopAuraPower) -> String {
|
||||||
let bytes = power.to_bytes();
|
let bytes = power.to_bytes(LaptopAuraType::New);
|
||||||
format!(
|
format!(
|
||||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||||
@@ -300,144 +382,144 @@ mod test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let boot_logo_ = to_binary_string(&LaptopAuraPower {
|
let boot_logo_ = to_binary_string(&LaptopAuraPower {
|
||||||
logo: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Logo,
|
||||||
boot: true,
|
boot: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let boot_keyb_ = to_binary_string(&LaptopAuraPower {
|
let boot_keyb_ = to_binary_string(&LaptopAuraPower {
|
||||||
keyboard: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Keyboard,
|
||||||
boot: true,
|
boot: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let sleep_logo = to_binary_string(&LaptopAuraPower {
|
let sleep_logo = to_binary_string(&LaptopAuraPower {
|
||||||
logo: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Logo,
|
||||||
sleep: true,
|
sleep: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let sleep_keyb = to_binary_string(&LaptopAuraPower {
|
let sleep_keyb = to_binary_string(&LaptopAuraPower {
|
||||||
keyboard: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Keyboard,
|
||||||
sleep: true,
|
sleep: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let awake_logo = to_binary_string(&LaptopAuraPower {
|
let awake_logo = to_binary_string(&LaptopAuraPower {
|
||||||
logo: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Logo,
|
||||||
awake: true,
|
awake: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let awake_keyb = to_binary_string(&LaptopAuraPower {
|
let awake_keyb = to_binary_string(&LaptopAuraPower {
|
||||||
keyboard: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Keyboard,
|
||||||
awake: true,
|
awake: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let shut_logo_ = to_binary_string(&LaptopAuraPower {
|
let shut_logo_ = to_binary_string(&LaptopAuraPower {
|
||||||
logo: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Logo,
|
||||||
shutdown: true,
|
shutdown: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let shut_keyb_ = to_binary_string(&LaptopAuraPower {
|
let shut_keyb_ = to_binary_string(&LaptopAuraPower {
|
||||||
keyboard: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Keyboard,
|
||||||
shutdown: true,
|
shutdown: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let boot_bar__ = to_binary_string(&LaptopAuraPower {
|
let boot_bar__ = to_binary_string(&LaptopAuraPower {
|
||||||
lightbar: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lightbar,
|
||||||
boot: true,
|
boot: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let awake_bar_ = to_binary_string(&LaptopAuraPower {
|
let awake_bar_ = to_binary_string(&LaptopAuraPower {
|
||||||
lightbar: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lightbar,
|
||||||
awake: true,
|
awake: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let sleep_bar_ = to_binary_string(&LaptopAuraPower {
|
let sleep_bar_ = to_binary_string(&LaptopAuraPower {
|
||||||
lightbar: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lightbar,
|
||||||
sleep: true,
|
sleep: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let shut_bar__ = to_binary_string(&LaptopAuraPower {
|
let shut_bar__ = to_binary_string(&LaptopAuraPower {
|
||||||
lightbar: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lightbar,
|
||||||
shutdown: true,
|
shutdown: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let boot_lid__ = to_binary_string(&LaptopAuraPower {
|
let boot_lid__ = to_binary_string(&LaptopAuraPower {
|
||||||
lid: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lid,
|
||||||
boot: true,
|
boot: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let awake_lid_ = to_binary_string(&LaptopAuraPower {
|
let awake_lid_ = to_binary_string(&LaptopAuraPower {
|
||||||
lid: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lid,
|
||||||
awake: true,
|
awake: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let sleep_lid_ = to_binary_string(&LaptopAuraPower {
|
let sleep_lid_ = to_binary_string(&LaptopAuraPower {
|
||||||
lid: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lid,
|
||||||
sleep: true,
|
sleep: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let shut_lid__ = to_binary_string(&LaptopAuraPower {
|
let shut_lid__ = to_binary_string(&LaptopAuraPower {
|
||||||
lid: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::Lid,
|
||||||
shutdown: true,
|
shutdown: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let boot_rear_ = to_binary_string(&LaptopAuraPower {
|
let boot_rear_ = to_binary_string(&LaptopAuraPower {
|
||||||
rear_glow: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::RearGlow,
|
||||||
boot: true,
|
boot: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let awake_rear = to_binary_string(&LaptopAuraPower {
|
let awake_rear = to_binary_string(&LaptopAuraPower {
|
||||||
rear_glow: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::RearGlow,
|
||||||
awake: true,
|
awake: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let sleep_rear = to_binary_string(&LaptopAuraPower {
|
let sleep_rear = to_binary_string(&LaptopAuraPower {
|
||||||
rear_glow: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::RearGlow,
|
||||||
sleep: true,
|
sleep: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
let shut_rear_ = to_binary_string(&LaptopAuraPower {
|
let shut_rear_ = to_binary_string(&LaptopAuraPower {
|
||||||
rear_glow: AuraPowerState {
|
states: vec![AuraPowerState {
|
||||||
|
zone: PowerZones::RearGlow,
|
||||||
shutdown: true,
|
shutdown: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}],
|
||||||
..Default::default()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||||
@@ -465,7 +547,7 @@ mod test {
|
|||||||
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
|
assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000");
|
||||||
|
|
||||||
// All on
|
// All on
|
||||||
let byte1 = LaptopAuraPower::new_all_on();
|
let byte1 = LaptopAuraPower::new(LaptopAuraType::New, &LaptopLedData::default());
|
||||||
let out = to_binary_string(&byte1);
|
let out = to_binary_string(&byte1);
|
||||||
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
|
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ use typeshare::typeshare;
|
|||||||
#[cfg(feature = "dbus")]
|
#[cfg(feature = "dbus")]
|
||||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||||
|
|
||||||
use crate::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower};
|
|
||||||
|
|
||||||
// Only these two packets must be 17 bytes
|
// Only these two packets must be 17 bytes
|
||||||
pub const LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
pub const LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
pub const LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
pub const LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
@@ -106,18 +104,3 @@ impl Debug for AuraDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This struct is intended as a helper to pass args to generic dbus interface
|
|
||||||
#[typeshare]
|
|
||||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
|
||||||
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
|
|
||||||
pub struct AuraPowerDev {
|
|
||||||
/// TUF laptops use a similar style of control to the older ROG devices but
|
|
||||||
/// through WMI
|
|
||||||
pub tuf: Vec<LaptopTufAuraPower>,
|
|
||||||
/// Pre-0x19b6 devices use a different smaller scheme to the newer ROG
|
|
||||||
/// devices
|
|
||||||
pub old_rog: Vec<LaptopOldAuraPower>,
|
|
||||||
/// ASUS standardised control scheme from 2020 onwards
|
|
||||||
pub rog: LaptopAuraPower,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use rog_aura::aura_detection::PowerZones;
|
||||||
use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower};
|
use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower};
|
||||||
use rog_aura::usb::AuraPowerDev;
|
use rog_aura::usb::AuraPowerDev;
|
||||||
use slint::{Model, ModelRc, RgbaColor};
|
use slint::{Model, ModelRc, RgbaColor};
|
||||||
@@ -102,11 +103,12 @@ use crate::slint_generatedMainWindow::PowerZones as SlintPowerZones;
|
|||||||
impl From<rog_aura::aura_detection::PowerZones> for SlintPowerZones {
|
impl From<rog_aura::aura_detection::PowerZones> for SlintPowerZones {
|
||||||
fn from(value: rog_aura::aura_detection::PowerZones) -> Self {
|
fn from(value: rog_aura::aura_detection::PowerZones) -> Self {
|
||||||
match value {
|
match value {
|
||||||
rog_aura::aura_detection::PowerZones::Logo => SlintPowerZones::Logo,
|
PowerZones::Logo => SlintPowerZones::Logo,
|
||||||
rog_aura::aura_detection::PowerZones::Keyboard => SlintPowerZones::Keyboard,
|
PowerZones::Keyboard => SlintPowerZones::Keyboard,
|
||||||
rog_aura::aura_detection::PowerZones::Lightbar => SlintPowerZones::Lightbar,
|
PowerZones::Lightbar => SlintPowerZones::Lightbar,
|
||||||
rog_aura::aura_detection::PowerZones::Lid => SlintPowerZones::Lid,
|
PowerZones::Lid => SlintPowerZones::Lid,
|
||||||
rog_aura::aura_detection::PowerZones::RearGlow => SlintPowerZones::RearGlow,
|
PowerZones::RearGlow => SlintPowerZones::RearGlow,
|
||||||
|
PowerZones::KeyboardAndLightbar => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use rog_aura::usb::AuraPowerDev;
|
use rog_aura::keyboard::LaptopAuraPower;
|
||||||
use rog_dbus::zbus_aura::AuraProxy;
|
use rog_dbus::zbus_aura::AuraProxy;
|
||||||
use slint::{ComponentHandle, Model, RgbaColor, SharedString};
|
use slint::{ComponentHandle, Model, RgbaColor, SharedString};
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
|||||||
.on_set_led_power(move |power| {
|
.on_set_led_power(move |power| {
|
||||||
let handle_copy = handle_copy.clone();
|
let handle_copy = handle_copy.clone();
|
||||||
let proxy_copy = aura.clone();
|
let proxy_copy = aura.clone();
|
||||||
let power: AuraPowerDev = power.into();
|
let power: LaptopAuraPower = power.into();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
show_toast(
|
show_toast(
|
||||||
"Anime builtin animations changed".into(),
|
"Anime builtin animations changed".into(),
|
||||||
|
|||||||
@@ -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-05 08:20+0000\n"
|
"POT-Creation-Date: 2024-04-08 09:19+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"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"
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ export component ColourSlider inherits VerticalLayout {
|
|||||||
callback external_colour_change();
|
callback external_colour_change();
|
||||||
|
|
||||||
external_colour_change => {
|
external_colour_change => {
|
||||||
if (root.final_colour.hue() < 0) {
|
if (root.final_colour.hue < 0) {
|
||||||
c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue() + 360) / 360);
|
c1.value = (root.base_colours.length - 1) * ((root.final_colour.hue + 360) / 360);
|
||||||
} else {
|
} else {
|
||||||
c1.value = (root.base_colours.length - 1) * (root.final_colour.hue() / 360);
|
c1.value = (root.base_colours.length - 1) * (root.final_colour.hue / 360);
|
||||||
}
|
}
|
||||||
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.brightness());
|
c2.value = root.base_shade.length - (root.base_shade.length * root.final_colour.value);
|
||||||
root.set_base_colour();
|
root.set_base_colour();
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use rog_aura::aura_detection::PowerZones;
|
use rog_aura::aura_detection::PowerZones;
|
||||||
use rog_aura::keyboard::UsbPackets;
|
use rog_aura::keyboard::{LaptopAuraPower, UsbPackets};
|
||||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
use rog_aura::usb::AuraDevice;
|
||||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||||
use zbus::blocking::Connection;
|
use zbus::blocking::Connection;
|
||||||
use zbus::{proxy, Result};
|
use zbus::{proxy, Result};
|
||||||
@@ -67,9 +67,9 @@ trait Aura {
|
|||||||
|
|
||||||
/// LedPower property
|
/// LedPower property
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn led_power(&self) -> zbus::Result<AuraPowerDev>;
|
fn led_power(&self) -> zbus::Result<LaptopAuraPower>;
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn set_led_power(&self, value: AuraPowerDev) -> zbus::Result<()>;
|
fn set_led_power(&self, value: LaptopAuraPower) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// SupportedBrightness property
|
/// SupportedBrightness property
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
|
|||||||
Reference in New Issue
Block a user