mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Aura: add support for Rear Glow power modes
This commit is contained in:
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
- Support for FX507Z LED modes
|
||||
- Support for GL503V LED modes
|
||||
- Support the Rear Glow on some laptops
|
||||
### Changed
|
||||
- Move FX506HC to FX506H in arua DB to catch full series of this range
|
||||
- Move FX506LH to FX506L in arua DB to catch full series of this range
|
||||
|
||||
@@ -31,13 +31,19 @@ pub struct LedPowerCommand2 {
|
||||
#[derive(Options)]
|
||||
pub enum SetAuraEnabled {
|
||||
/// Applies to both old and new models
|
||||
#[options(help = "set <keyboard, logo, lightbar> to enabled while device is awake")]
|
||||
#[options(help = "set <keyboard, logo, lightbar, rearglow> to enabled while device is awake")]
|
||||
Awake(AuraEnabled),
|
||||
#[options(help = "set <keyboard, logo, lightbar> to enabled while the device is booting")]
|
||||
#[options(
|
||||
help = "set <keyboard, logo, lightbar, rearglow> to enabled while the device is booting"
|
||||
)]
|
||||
Boot(AuraEnabled),
|
||||
#[options(help = "set <keyboard, logo, lightbar> to animate while the device is suspended")]
|
||||
#[options(
|
||||
help = "set <keyboard, logo, lightbar, rearglow> to animate while the device is suspended"
|
||||
)]
|
||||
Sleep(AuraEnabled),
|
||||
#[options(help = "set <keyboard, logo, lightbar> to animate while the device is shutdown")]
|
||||
#[options(
|
||||
help = "set <keyboard, logo, lightbar, rearglow> to animate while the device is shutdown"
|
||||
)]
|
||||
Shutdown(AuraEnabled),
|
||||
}
|
||||
|
||||
@@ -50,7 +56,9 @@ pub struct AuraEnabled {
|
||||
#[options(meta = "", help = "<true/false>")]
|
||||
pub logo: Option<bool>,
|
||||
#[options(meta = "", help = "<true/false>")]
|
||||
pub lightbar: Option<bool>,
|
||||
pub frontglow: Option<bool>,
|
||||
#[options(meta = "", help = "<true/false>")]
|
||||
pub rearglow: Option<bool>,
|
||||
#[options(meta = "", help = "<true/false>")]
|
||||
pub lid: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -601,26 +601,30 @@ fn handle_led_power2(
|
||||
aura_cli::SetAuraEnabled::Boot(arg) => {
|
||||
check(arg.keyboard, AuraDevRog2::BootKeyb);
|
||||
check(arg.logo, AuraDevRog2::BootLogo);
|
||||
check(arg.lightbar, AuraDevRog2::BootBar);
|
||||
check(arg.frontglow, AuraDevRog2::BootBar);
|
||||
check(arg.rearglow, AuraDevRog2::BootRearGlow);
|
||||
check(arg.lid, AuraDevRog2::AwakeLid);
|
||||
}
|
||||
aura_cli::SetAuraEnabled::Sleep(arg) => {
|
||||
check(arg.keyboard, AuraDevRog2::SleepKeyb);
|
||||
check(arg.logo, AuraDevRog2::SleepLogo);
|
||||
check(arg.lightbar, AuraDevRog2::SleepBar);
|
||||
check(arg.frontglow, AuraDevRog2::SleepBar);
|
||||
check(arg.rearglow, AuraDevRog2::SleepRearGlow);
|
||||
check(arg.lid, AuraDevRog2::SleepLid);
|
||||
}
|
||||
aura_cli::SetAuraEnabled::Awake(arg) => {
|
||||
check(arg.keyboard, AuraDevRog2::AwakeKeyb);
|
||||
check(arg.logo, AuraDevRog2::AwakeLogo);
|
||||
check(arg.lightbar, AuraDevRog2::AwakeBar);
|
||||
check(arg.frontglow, AuraDevRog2::AwakeBar);
|
||||
check(arg.rearglow, AuraDevRog2::AwakeRearGlow);
|
||||
check(arg.lid, AuraDevRog2::AwakeLid);
|
||||
}
|
||||
aura_cli::SetAuraEnabled::Shutdown(arg) => {
|
||||
check(arg.keyboard, AuraDevRog2::ShutdownKeyb);
|
||||
check(arg.logo, AuraDevRog2::ShutdownLogo);
|
||||
check(arg.lightbar, AuraDevRog2::ShutdownBar);
|
||||
check(arg.lid, AuraDevRog2::ShutdownBar);
|
||||
check(arg.frontglow, AuraDevRog2::ShutdownBar);
|
||||
check(arg.rearglow, AuraDevRog2::ShutdownRearGlow);
|
||||
check(arg.lid, AuraDevRog2::ShutdownLid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ pub enum AuraPowerConfig {
|
||||
|
||||
impl AuraPowerConfig {
|
||||
/// Invalid for TUF laptops
|
||||
pub fn to_bytes(control: &Self) -> [u8; 3] {
|
||||
pub fn to_bytes(control: &Self) -> [u8; 4] {
|
||||
match control {
|
||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0],
|
||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0],
|
||||
AuraPowerConfig::AuraDevRog1(c) => {
|
||||
let c: Vec<AuraDevRog1> = c.iter().copied().collect();
|
||||
AuraDevRog1::to_bytes(&c)
|
||||
@@ -156,6 +156,10 @@ impl AuraConfig {
|
||||
AuraDevRog2::AwakeBar,
|
||||
AuraDevRog2::SleepBar,
|
||||
AuraDevRog2::ShutdownBar,
|
||||
AuraDevRog2::BootRearGlow,
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
AuraDevRog2::SleepRearGlow,
|
||||
AuraDevRog2::ShutdownRearGlow,
|
||||
]))
|
||||
} else if prod_id == AuraDevice::Tuf {
|
||||
AuraPowerConfig::AuraDevTuf(HashSet::from([
|
||||
|
||||
@@ -200,7 +200,7 @@ impl CtrlKbdLed {
|
||||
}
|
||||
} else if let LEDNode::Rog(hid_raw) = &self.led_node {
|
||||
let bytes = AuraPowerConfig::to_bytes(&self.config.enabled);
|
||||
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2]];
|
||||
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||
|
||||
hid_raw.write_bytes(&message)?;
|
||||
hid_raw.write_bytes(&LED_SET)?;
|
||||
|
||||
@@ -78,6 +78,10 @@ impl CtrlKbdLedZbus {
|
||||
/// BootBar,
|
||||
/// SleepBar,
|
||||
/// ShutdownBar,
|
||||
/// BootRearBar,
|
||||
/// AwakeRearBar,
|
||||
/// SleepRearBar,
|
||||
/// ShutdownRearBar,
|
||||
/// }
|
||||
/// ```
|
||||
async fn set_leds_power(
|
||||
|
||||
@@ -112,14 +112,17 @@ impl AuraDevTuf {
|
||||
/// 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 | |
|
||||
/// | Byte 1 | Byte 2 | Byte 3 | Byte 4 | function | hex
|
||||
/// |
|
||||
/// |------------|------------|------------|------------|-----------|-------------|
|
||||
/// | 0000, 0000 | 0000, 0000 | 0000, 0010 | 0000, 0000 | Awake |
|
||||
/// 00,00,02,00 | | 0000, 1000 | 0000, 0000 | 0000, 0000 | 0000, 0000 | Keyboard
|
||||
/// | 08,00,00,00 | | 0000, 0100 | 0000, 0101 | 0000, 0000 | 0000, 0000 |
|
||||
/// Lightbar | 04,05,00,00 | | 1100, 0011 | 0001, 0010 | 0000, 1001 | 0000,
|
||||
/// 0000 | Boot/Sht | c3,12,09,00 | | 0011, 0000 | 0000, 1000 | 0000, 0100 |
|
||||
/// 0000, 0000 | Sleep | 30,08,04,00 | | 1111, 1111 | 0001, 1111 | 0000,
|
||||
/// 1111 | 0000, 0000 | all on | | | 0000, 0000 | 0000, 0000 |
|
||||
/// 0000, 0000 | 0000, 0010 | Rear Glow | 00,00,00,02 |
|
||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
@@ -138,7 +141,7 @@ impl From<AuraDevRog1> for u32 {
|
||||
}
|
||||
|
||||
impl AuraDevRog1 {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
|
||||
let mut a: u32 = 0;
|
||||
for n in control {
|
||||
a |= *n as u32;
|
||||
@@ -147,6 +150,7 @@ impl AuraDevRog1 {
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
(a & 0xff) as u8,
|
||||
0x00,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -217,6 +221,10 @@ pub enum AuraDevRog2 {
|
||||
AwakeLid = 1 << (15 + 2),
|
||||
SleepLid = 1 << (15 + 3),
|
||||
ShutdownLid = 1 << (15 + 4),
|
||||
BootRearGlow = 1 << (23 + 1),
|
||||
AwakeRearGlow = 1 << (23 + 2),
|
||||
SleepRearGlow = 1 << (23 + 3),
|
||||
ShutdownRearGlow = 1 << (23 + 4),
|
||||
}
|
||||
|
||||
impl From<AuraDevRog2> for u32 {
|
||||
@@ -226,7 +234,7 @@ impl From<AuraDevRog2> for u32 {
|
||||
}
|
||||
|
||||
impl AuraDevRog2 {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 3] {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
|
||||
let mut a: u32 = 0;
|
||||
for n in control {
|
||||
a |= *n as u32;
|
||||
@@ -235,6 +243,7 @@ impl AuraDevRog2 {
|
||||
(a & 0xff) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff000000) >> 24) as u8,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -269,22 +278,22 @@ mod tests {
|
||||
let bytes = [AuraDevRog1::Keyboard, AuraDevRog1::Awake];
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x08, 0x00, 0x02]);
|
||||
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
|
||||
|
||||
let bytes = [AuraDevRog1::Lightbar, AuraDevRog1::Awake];
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x04, 0x05, 0x02]);
|
||||
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
|
||||
|
||||
let bytes = [AuraDevRog1::Sleep];
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x30, 0x08, 0x04]);
|
||||
assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]);
|
||||
|
||||
let bytes = [AuraDevRog1::Boot];
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0xc3, 0x12, 0x09]);
|
||||
assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]);
|
||||
|
||||
let bytes = [
|
||||
AuraDevRog1::Keyboard,
|
||||
@@ -296,7 +305,7 @@ mod tests {
|
||||
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0xff, 0x1f, 0x000f]);
|
||||
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -442,5 +451,70 @@ mod tests {
|
||||
let bytes = AuraDevRog2::to_bytes(&byte3);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes[2], 0x06);
|
||||
|
||||
let byte4 = [
|
||||
// AuraDev19b6::AwakeRearBar,
|
||||
AuraDevRog2::BootRearGlow,
|
||||
AuraDevRog2::SleepRearGlow,
|
||||
AuraDevRog2::ShutdownRearGlow,
|
||||
];
|
||||
let bytes = AuraDevRog2::to_bytes(&byte4);
|
||||
println!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
);
|
||||
assert_eq!(bytes[3], 0x0d);
|
||||
|
||||
let byte4 = [
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
AuraDevRog2::BootRearGlow,
|
||||
// AuraDevRog2::SleepRearBar,
|
||||
AuraDevRog2::ShutdownRearGlow,
|
||||
];
|
||||
let bytes = AuraDevRog2::to_bytes(&byte4);
|
||||
println!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
);
|
||||
assert_eq!(bytes[3], 0x0b);
|
||||
|
||||
let byte4 = [
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
AuraDevRog2::BootRearGlow,
|
||||
AuraDevRog2::SleepRearGlow,
|
||||
// AuraDevRog2::ShutdownRearBar,
|
||||
];
|
||||
let bytes = AuraDevRog2::to_bytes(&byte4);
|
||||
println!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
);
|
||||
assert_eq!(bytes[3], 0x07);
|
||||
|
||||
let byte4 = [
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
// AuraDevRog2::BootRearBar,
|
||||
AuraDevRog2::SleepRearGlow,
|
||||
// AuraDevRog2::ShutdownRearBar,
|
||||
];
|
||||
let bytes = AuraDevRog2::to_bytes(&byte4);
|
||||
println!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
);
|
||||
assert_eq!(bytes[3], 0x06);
|
||||
|
||||
let byte4 = [
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
// AuraDevRog2::BootRearBar,
|
||||
// AuraDevRog2::SleepRearBar,
|
||||
// AuraDevRog2::ShutdownRearBar,
|
||||
];
|
||||
let bytes = AuraDevRog2::to_bytes(&byte4);
|
||||
println!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
);
|
||||
assert_eq!(bytes[3], 0x02);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user