diff --git a/asusd/src/aura_laptop/mod.rs b/asusd/src/aura_laptop/mod.rs index 7fabceba..21b062f3 100644 --- a/asusd/src/aura_laptop/mod.rs +++ b/asusd/src/aura_laptop/mod.rs @@ -25,6 +25,24 @@ pub struct Aura { impl Aura { /// Initialise the device if required. pub async fn do_initialization(&self) -> Result<(), RogError> { + if let Some(hid) = &self.hid { + let hid = hid.lock().await; + let init_1: [u8; 2] = [0x5d, 0xb9]; + let init_2 = b"]ASUS Tech.Inc."; + let init_3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x1a]; + + hid.write_bytes(&init_1)?; + hid.write_bytes(init_2)?; + hid.write_bytes(&init_3)?; + + let config = self.config.lock().await; + if config.support_data.device_name.contains("GZ30") + || config.support_data.device_name.contains("Z13") + { + let z13_init: [u8; 4] = [0x5d, 0xc0, 0x03, 0x01]; + hid.write_bytes(&z13_init)?; + } + } Ok(()) } @@ -152,9 +170,54 @@ impl Aura { } } - let bytes = config.enabled.to_bytes(config.led_type); + let mut enabled = config.enabled.clone(); + if config.support_data.device_name.contains("GZ30") + || config.support_data.device_name.contains("Z13") + { + let logo_state = enabled + .states + .iter() + .find(|s| s.zone == PowerZones::Logo) + .cloned(); + if let Some(logo) = logo_state { + let mut lid_found = false; + let mut bar_found = false; + + for s in enabled.states.iter_mut() { + if s.zone == PowerZones::Lid { + s.boot = logo.boot; + s.awake = logo.awake; + s.sleep = logo.sleep; + s.shutdown = logo.shutdown; + lid_found = true; + } + if s.zone == PowerZones::Lightbar { + s.boot = logo.boot; + s.awake = logo.awake; + s.sleep = logo.sleep; + s.shutdown = logo.shutdown; + bar_found = true; + } + } + + if !lid_found { + let mut new_state = logo; + new_state.zone = PowerZones::Lid; + enabled.states.push(new_state.clone()); + new_state.zone = PowerZones::Lightbar; + enabled.states.push(new_state); + } else if !bar_found { + // Lid found but not bar? + let mut new_state = logo; + new_state.zone = PowerZones::Lightbar; + enabled.states.push(new_state); + } + } + } + + let bytes = enabled.to_bytes(config.led_type); let msg = [ - 0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3], + 0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3], 0xff, ]; hid_raw.write_bytes(&msg)?; } diff --git a/rog-aura/src/keyboard/power.rs b/rog-aura/src/keyboard/power.rs index 7b5b1f53..5019ec91 100644 --- a/rog-aura/src/keyboard/power.rs +++ b/rog-aura/src/keyboard/power.rs @@ -123,7 +123,8 @@ impl AuraPowerState { | ((self.shutdown as u32) << 7) } PowerZones::Lightbar => { - ((self.boot as u32) << (7 + 2)) + ((self.awake as u32) << (7 + 1)) + | ((self.boot as u32) << (7 + 2)) | ((self.awake as u32) << (7 + 3)) | ((self.sleep as u32) << (7 + 4)) | ((self.shutdown as u32) << (7 + 5)) @@ -133,12 +134,20 @@ impl AuraPowerState { | ((self.awake as u32) << (15 + 2)) | ((self.sleep as u32) << (15 + 3)) | ((self.shutdown as u32) << (15 + 4)) + | ((self.boot as u32) << (15 + 5)) + | ((self.awake as u32) << (15 + 6)) + | ((self.sleep as u32) << (15 + 7)) + | ((self.shutdown as u32) << (15 + 8)) } PowerZones::RearGlow => { ((self.boot as u32) << (23 + 1)) | ((self.awake as u32) << (23 + 2)) | ((self.sleep as u32) << (23 + 3)) | ((self.shutdown as u32) << (23 + 4)) + | ((self.boot as u32) << (23 + 5)) + | ((self.awake as u32) << (23 + 6)) + | ((self.sleep as u32) << (23 + 7)) + | ((self.shutdown as u32) << (23 + 8)) } PowerZones::None | PowerZones::KeyboardAndLightbar => 0, } @@ -618,19 +627,19 @@ mod test { assert_eq!(shut_keyb_, "10000000, 00000000, 00000000, 00000000"); // assert_eq!(boot_bar__, "00000000, 00000010, 00000000, 00000000"); - assert_eq!(awake_bar_, "00000000, 00000100, 00000000, 00000000"); + assert_eq!(awake_bar_, "00000000, 00000101, 00000000, 00000000"); assert_eq!(sleep_bar_, "00000000, 00001000, 00000000, 00000000"); assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000"); // - assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000"); - assert_eq!(awake_lid_, "00000000, 00000000, 00000010, 00000000"); - assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000"); - assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 00000000"); + assert_eq!(boot_lid__, "00000000, 00000000, 00010001, 00000000"); + assert_eq!(awake_lid_, "00000000, 00000000, 00100010, 00000000"); + assert_eq!(sleep_lid_, "00000000, 00000000, 01000100, 00000000"); + assert_eq!(shut_lid__, "00000000, 00000000, 10001000, 00000000"); // - assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00000001"); - assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00000010"); - assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 00000100"); - assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 00001000"); + assert_eq!(boot_rear_, "00000000, 00000000, 00000000, 00010001"); + assert_eq!(awake_rear, "00000000, 00000000, 00000000, 00100010"); + assert_eq!(sleep_rear, "00000000, 00000000, 00000000, 01000100"); + assert_eq!(shut_rear_, "00000000, 00000000, 00000000, 10001000"); // All on let byte1 = to_binary_string_post2021(&LaptopAuraPower { @@ -657,6 +666,6 @@ mod test { }, ], }); - assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111"); + assert_eq!(byte1, "11111111, 00011111, 11111111, 11111111"); } }