mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Refactor, rename, organise rog-aura stuff better
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
//! Using a combination of key-colour array plus a key layout to generate
|
||||
//! outputs.
|
||||
|
||||
use rog_aura::advanced::LedCode;
|
||||
use rog_aura::effects::{AdvancedEffects, Effect};
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_aura::keyboard::{KeyLayout, LedCode};
|
||||
use rog_aura::Colour;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
@@ -12,8 +12,8 @@ use fan_curve_cli::FanCurveCommand;
|
||||
use gumdrop::{Opt, Options};
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
|
||||
use rog_aura::power::KbAuraPowerState;
|
||||
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower};
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{self, AuraEffect};
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
@@ -601,10 +601,10 @@ fn handle_led_power_1_do_1866(
|
||||
aura: &AuraProxyBlocking,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDevRog1> = Vec::new();
|
||||
let mut disabled: Vec<AuraDevRog1> = Vec::new();
|
||||
let mut enabled: Vec<LaptopOldAuraPower> = Vec::new();
|
||||
let mut disabled: Vec<LaptopOldAuraPower> = Vec::new();
|
||||
|
||||
let mut check = |e: Option<bool>, a: AuraDevRog1| {
|
||||
let mut check = |e: Option<bool>, a: LaptopOldAuraPower| {
|
||||
if let Some(arg) = e {
|
||||
if arg {
|
||||
enabled.push(a);
|
||||
@@ -614,11 +614,11 @@ fn handle_led_power_1_do_1866(
|
||||
}
|
||||
};
|
||||
|
||||
check(power.awake, AuraDevRog1::Awake);
|
||||
check(power.boot, AuraDevRog1::Boot);
|
||||
check(power.sleep, AuraDevRog1::Sleep);
|
||||
check(power.keyboard, AuraDevRog1::Keyboard);
|
||||
check(power.lightbar, AuraDevRog1::Lightbar);
|
||||
check(power.awake, LaptopOldAuraPower::Awake);
|
||||
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,
|
||||
@@ -634,10 +634,10 @@ fn handle_led_power_1_do_tuf(
|
||||
aura: &AuraProxyBlocking,
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut enabled: Vec<AuraDevTuf> = Vec::new();
|
||||
let mut disabled: Vec<AuraDevTuf> = Vec::new();
|
||||
let mut enabled: Vec<LaptopTufAuraPower> = Vec::new();
|
||||
let mut disabled: Vec<LaptopTufAuraPower> = Vec::new();
|
||||
|
||||
let mut check = |e: Option<bool>, a: AuraDevTuf| {
|
||||
let mut check = |e: Option<bool>, a: LaptopTufAuraPower| {
|
||||
if let Some(arg) = e {
|
||||
if arg {
|
||||
enabled.push(a);
|
||||
@@ -647,10 +647,10 @@ fn handle_led_power_1_do_tuf(
|
||||
}
|
||||
};
|
||||
|
||||
check(power.awake, AuraDevTuf::Awake);
|
||||
check(power.boot, AuraDevTuf::Boot);
|
||||
check(power.sleep, AuraDevTuf::Sleep);
|
||||
check(power.keyboard, AuraDevTuf::Keyboard);
|
||||
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,
|
||||
@@ -696,7 +696,7 @@ fn handle_led_power2(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let set = |power: &mut KbAuraPowerState, set_to: &AuraPowerStates| {
|
||||
let set = |power: &mut AuraPowerState, set_to: &AuraPowerStates| {
|
||||
power.boot = set_to.boot;
|
||||
power.awake = set_to.awake;
|
||||
power.sleep = set_to.sleep;
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::time::Duration;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::{ActionLoader, AnimTime, AnimeType, Fade, Sequences as AnimeSequences, Vec2};
|
||||
use rog_aura::advanced::LedCode;
|
||||
use rog_aura::effects::{AdvancedEffects as AuraSequences, Breathe, DoomFlicker, Effect, Static};
|
||||
use rog_aura::keyboard::LedCode;
|
||||
use rog_aura::{Colour, Speed};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use asusd_user::ctrl_anime::{CtrlAnime, CtrlAnimeInner};
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::usb::get_anime_type;
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_aura::keyboard::KeyLayout;
|
||||
use rog_dbus::zbus_anime::AnimeProxyBlocking;
|
||||
use rog_dbus::zbus_aura::AuraProxyBlocking;
|
||||
use rog_dbus::zbus_platform::PlatformProxyBlocking;
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::collections::{BTreeMap, HashSet};
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use log::{debug, info};
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use rog_aura::power::AuraPower;
|
||||
use rog_aura::usb::{AuraDevRog1, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||
use rog_aura::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower};
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
@@ -13,9 +13,9 @@ use serde_derive::{Deserialize, Serialize};
|
||||
/// booting.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum AuraPowerConfig {
|
||||
AuraDevTuf(HashSet<AuraDevTuf>),
|
||||
AuraDevRog1(HashSet<AuraDevRog1>),
|
||||
AuraDevRog2(AuraPower),
|
||||
AuraDevTuf(HashSet<LaptopTufAuraPower>),
|
||||
AuraDevRog1(HashSet<LaptopOldAuraPower>),
|
||||
AuraDevRog2(LaptopAuraPower),
|
||||
}
|
||||
|
||||
impl Default for AuraPowerConfig {
|
||||
@@ -30,8 +30,8 @@ impl AuraPowerConfig {
|
||||
match control {
|
||||
AuraPowerConfig::AuraDevTuf(_) => [0, 0, 0, 0],
|
||||
AuraPowerConfig::AuraDevRog1(c) => {
|
||||
let c: Vec<AuraDevRog1> = c.iter().copied().collect();
|
||||
AuraDevRog1::to_bytes(&c)
|
||||
let c: Vec<LaptopOldAuraPower> = c.iter().copied().collect();
|
||||
LaptopOldAuraPower::to_bytes(&c)
|
||||
}
|
||||
AuraPowerConfig::AuraDevRog2(c) => c.to_bytes(),
|
||||
}
|
||||
@@ -41,27 +41,27 @@ impl AuraPowerConfig {
|
||||
if let Self::AuraDevTuf(c) = control {
|
||||
return Some([
|
||||
true,
|
||||
c.contains(&AuraDevTuf::Boot),
|
||||
c.contains(&AuraDevTuf::Awake),
|
||||
c.contains(&AuraDevTuf::Sleep),
|
||||
c.contains(&AuraDevTuf::Keyboard),
|
||||
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(&AuraDevRog1::Boot),
|
||||
c.contains(&AuraDevRog1::Awake),
|
||||
c.contains(&AuraDevRog1::Sleep),
|
||||
c.contains(&AuraDevRog1::Keyboard),
|
||||
c.contains(&LaptopOldAuraPower::Boot),
|
||||
c.contains(&LaptopOldAuraPower::Awake),
|
||||
c.contains(&LaptopOldAuraPower::Sleep),
|
||||
c.contains(&LaptopOldAuraPower::Keyboard),
|
||||
]);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_tuf(&mut self, power: AuraDevTuf, on: bool) {
|
||||
pub fn set_tuf(&mut self, power: LaptopTufAuraPower, on: bool) {
|
||||
if let Self::AuraDevTuf(p) = self {
|
||||
if on {
|
||||
p.insert(power);
|
||||
@@ -71,7 +71,7 @@ impl AuraPowerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_0x1866(&mut self, power: AuraDevRog1, on: bool) {
|
||||
pub fn set_0x1866(&mut self, power: LaptopOldAuraPower, on: bool) {
|
||||
if let Self::AuraDevRog1(p) = self {
|
||||
if on {
|
||||
p.insert(power);
|
||||
@@ -81,7 +81,7 @@ impl AuraPowerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_0x19b6(&mut self, power: AuraPower) {
|
||||
pub fn set_0x19b6(&mut self, power: LaptopAuraPower) {
|
||||
if let Self::AuraDevRog2(p) = self {
|
||||
*p = power;
|
||||
}
|
||||
@@ -151,21 +151,21 @@ impl AuraConfig {
|
||||
pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
|
||||
// create a default config here
|
||||
let enabled = if prod_id.is_new_style() {
|
||||
AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on())
|
||||
AuraPowerConfig::AuraDevRog2(LaptopAuraPower::new_all_on())
|
||||
} else if prod_id.is_tuf_style() {
|
||||
AuraPowerConfig::AuraDevTuf(HashSet::from([
|
||||
AuraDevTuf::Awake,
|
||||
AuraDevTuf::Boot,
|
||||
AuraDevTuf::Sleep,
|
||||
AuraDevTuf::Keyboard,
|
||||
LaptopTufAuraPower::Awake,
|
||||
LaptopTufAuraPower::Boot,
|
||||
LaptopTufAuraPower::Sleep,
|
||||
LaptopTufAuraPower::Keyboard,
|
||||
]))
|
||||
} else {
|
||||
AuraPowerConfig::AuraDevRog1(HashSet::from([
|
||||
AuraDevRog1::Awake,
|
||||
AuraDevRog1::Boot,
|
||||
AuraDevRog1::Sleep,
|
||||
AuraDevRog1::Keyboard,
|
||||
AuraDevRog1::Lightbar,
|
||||
LaptopOldAuraPower::Awake,
|
||||
LaptopOldAuraPower::Boot,
|
||||
LaptopOldAuraPower::Sleep,
|
||||
LaptopOldAuraPower::Keyboard,
|
||||
LaptopOldAuraPower::Lightbar,
|
||||
]))
|
||||
};
|
||||
let mut config = AuraConfig {
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::collections::{BTreeMap, HashSet};
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use inotify::Inotify;
|
||||
use log::{debug, info, warn};
|
||||
use rog_aura::advanced::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::aura_detection::LaptopLedData;
|
||||
use rog_aura::keyboard::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::usb::{AuraDevice, LED_APPLY, LED_SET};
|
||||
use rog_aura::{AuraEffect, Direction, LedBrightness, Speed, GRADIENT, LED_MSG_LEN};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
@@ -362,7 +362,7 @@ mod tests {
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![],
|
||||
advanced_type: rog_aura::AdvancedAuraType::None,
|
||||
advanced_type: rog_aura::keyboard::AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
|
||||
};
|
||||
let mut controller = CtrlKbdLed {
|
||||
@@ -405,7 +405,7 @@ mod tests {
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![AuraZone::Key1, AuraZone::Key2],
|
||||
advanced_type: rog_aura::AdvancedAuraType::None,
|
||||
advanced_type: rog_aura::keyboard::AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
|
||||
};
|
||||
let mut controller = CtrlKbdLed {
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::sync::Arc;
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
use rog_aura::keyboard::UsbPackets;
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||
use zbus::export::futures_util::lock::{Mutex, MutexGuard};
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
use crate::advanced::LedCode;
|
||||
|
||||
impl From<LedCode> for &str {
|
||||
fn from(k: LedCode) -> Self {
|
||||
(&k).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&LedCode> for &str {
|
||||
fn from(k: &LedCode) -> Self {
|
||||
#[allow(clippy::match_same_arms)]
|
||||
match k {
|
||||
LedCode::VolUp => "Volume Up",
|
||||
LedCode::VolDown => "Volume Down",
|
||||
LedCode::MicMute => "Mute Mic",
|
||||
LedCode::RogApp => "ROG",
|
||||
LedCode::RogFan => "Fan Control",
|
||||
LedCode::Esc => "Escape",
|
||||
LedCode::F1 => "F1",
|
||||
LedCode::F2 => "F2",
|
||||
LedCode::F3 => "F3",
|
||||
LedCode::F4 => "F4",
|
||||
LedCode::F5 => "F5",
|
||||
LedCode::F6 => "F6",
|
||||
LedCode::F7 => "F7",
|
||||
LedCode::F8 => "F8",
|
||||
LedCode::F9 => "F9",
|
||||
LedCode::F10 => "F10",
|
||||
LedCode::F11 => "F11",
|
||||
LedCode::F12 => "F12",
|
||||
LedCode::Del => "Delete",
|
||||
LedCode::Tilde => "Tilde",
|
||||
LedCode::N1 => "1",
|
||||
LedCode::N2 => "2",
|
||||
LedCode::N3 => "3",
|
||||
LedCode::N4 => "4",
|
||||
LedCode::N5 => "5",
|
||||
LedCode::N6 => "6",
|
||||
LedCode::N7 => "7",
|
||||
LedCode::N8 => "8",
|
||||
LedCode::N9 => "9",
|
||||
LedCode::N0 => "0",
|
||||
LedCode::Hyphen => "-",
|
||||
LedCode::Equals => "=",
|
||||
LedCode::Backspace => "Backspace",
|
||||
LedCode::Backspace3_1 => "Backspace LED 1",
|
||||
LedCode::Backspace3_2 => "Backspace LED 2",
|
||||
LedCode::Backspace3_3 => "Backspace LED 3",
|
||||
LedCode::Home => "Home",
|
||||
LedCode::Tab => "Tab",
|
||||
LedCode::Q => "Q",
|
||||
LedCode::W => "W",
|
||||
LedCode::E => "E",
|
||||
LedCode::R => "R",
|
||||
LedCode::T => "T",
|
||||
LedCode::Y => "Y",
|
||||
LedCode::U => "U",
|
||||
LedCode::I => "I",
|
||||
LedCode::O => "O",
|
||||
LedCode::P => "P",
|
||||
LedCode::LBracket => "[",
|
||||
LedCode::RBracket => "]",
|
||||
LedCode::BackSlash => "\\",
|
||||
LedCode::PgUp => "Page Up",
|
||||
LedCode::Caps => "Caps Lock",
|
||||
LedCode::A => "A",
|
||||
LedCode::S => "S",
|
||||
LedCode::D => "D",
|
||||
LedCode::F => "F",
|
||||
LedCode::G => "G",
|
||||
LedCode::H => "H",
|
||||
LedCode::J => "J",
|
||||
LedCode::K => "K",
|
||||
LedCode::L => "L",
|
||||
LedCode::SemiColon => ";",
|
||||
LedCode::Quote => "'",
|
||||
LedCode::Return => "Return",
|
||||
LedCode::Return3_1 => "Return LED 1",
|
||||
LedCode::Return3_2 => "Return LED 2",
|
||||
LedCode::Return3_3 => "Return LED 3",
|
||||
LedCode::PgDn => "Page Down",
|
||||
LedCode::LShift => "Left Shift",
|
||||
LedCode::LShift3_1 => "Left Shift LED 1",
|
||||
LedCode::LShift3_2 => "Left Shift LED 2",
|
||||
LedCode::LShift3_3 => "Left Shift LED 3",
|
||||
LedCode::Z => "Z",
|
||||
LedCode::X => "X",
|
||||
LedCode::C => "C",
|
||||
LedCode::V => "V",
|
||||
LedCode::B => "B",
|
||||
LedCode::N => "N",
|
||||
LedCode::M => "M",
|
||||
LedCode::Comma => ",",
|
||||
LedCode::Period => ".",
|
||||
LedCode::Star => "*",
|
||||
LedCode::NumPadDel => "Delete",
|
||||
LedCode::NumPadPlus => "+",
|
||||
LedCode::NumPadEnter => "Enter",
|
||||
LedCode::NumPadPause => "Pause",
|
||||
LedCode::NumPadPrtSc => "Print Screen",
|
||||
LedCode::NumPadHome => "Home",
|
||||
LedCode::NumLock => "Num-Lock",
|
||||
LedCode::FwdSlash => "/",
|
||||
LedCode::Rshift => "Right Shift",
|
||||
LedCode::Rshift3_1 => "Right Shift LED 1",
|
||||
LedCode::Rshift3_2 => "Right Shift LED 2",
|
||||
LedCode::Rshift3_3 => "Right Shift LED 3",
|
||||
LedCode::End => "End",
|
||||
LedCode::LCtrl => "Left Control",
|
||||
LedCode::LFn => "Left Fn",
|
||||
LedCode::Meta => "Meta",
|
||||
LedCode::LAlt => "Left Alt",
|
||||
LedCode::Spacebar => "Space",
|
||||
LedCode::Spacebar5_1 => "Space LED 1",
|
||||
LedCode::Spacebar5_2 => "Space LED 2",
|
||||
LedCode::Spacebar5_3 => "Space LED 3",
|
||||
LedCode::Spacebar5_4 => "Space LED 4",
|
||||
LedCode::Spacebar5_5 => "Space LED 5",
|
||||
LedCode::RAlt => "Right Alt",
|
||||
LedCode::PrtSc => "Print Screen",
|
||||
LedCode::RCtrl => "Right Control",
|
||||
LedCode::Pause => "Pause",
|
||||
LedCode::Up => "Up",
|
||||
LedCode::Down => "Down",
|
||||
LedCode::Left => "Left",
|
||||
LedCode::Right => "Right",
|
||||
LedCode::RFn => "Right Fn",
|
||||
LedCode::MediaPlay => "Media Play",
|
||||
LedCode::MediaStop => "Media Stop",
|
||||
LedCode::MediaNext => "Media Next",
|
||||
LedCode::MediaPrev => "Media Previous",
|
||||
LedCode::LidLogo => "Lid Logo",
|
||||
LedCode::LidLeft => "Lid Left",
|
||||
LedCode::LidRight => "Lid Right",
|
||||
LedCode::LightbarRight => "Lightbar Right",
|
||||
LedCode::LightbarRightCorner => "Lightbar Right Corner",
|
||||
LedCode::LightbarRightBottom => "Lightbar Right Bottom",
|
||||
LedCode::LightbarLeftBottom => "Lightbar Left Bottom",
|
||||
LedCode::LightbarLeftCorner => "Lightbar Left Corner",
|
||||
LedCode::LightbarLeft => "Lightbar Left",
|
||||
LedCode::Spacing | LedCode::Blocking => "",
|
||||
LedCode::SingleZone => "Single Zoned Keyboard",
|
||||
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
|
||||
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
|
||||
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,9 @@ use serde_derive::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::keyboard::AdvancedAuraType;
|
||||
use crate::usb::AuraDevice;
|
||||
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
|
||||
use crate::{AuraModeNum, AuraZone};
|
||||
|
||||
pub const ASUS_LED_MODE_CONF: &str = "/usr/share/asusd/aura_support.ron";
|
||||
pub const ASUS_LED_MODE_USER_CONF: &str = "/etc/asusd/asusd_user_ledmodes.ron";
|
||||
@@ -153,10 +154,10 @@ mod tests {
|
||||
use ron::ser::PrettyConfig;
|
||||
|
||||
use super::LaptopLedData;
|
||||
use crate::advanced::LedCode;
|
||||
use crate::aura_detection::{LedSupportFile, PowerZones};
|
||||
use crate::keyboard::{AdvancedAuraType, LedCode};
|
||||
// use crate::zoned::Zone;
|
||||
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
|
||||
use crate::{AuraModeNum, AuraZone};
|
||||
|
||||
#[test]
|
||||
fn check_data_parse() {
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9];
|
||||
pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d
|
||||
pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
|
||||
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
//! Older code that is not useful but stillr elevant as a reference
|
||||
|
||||
/// # 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_|
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[repr(u32)]
|
||||
pub enum AuraDevRog2 {
|
||||
BootLogo = 1,
|
||||
BootKeyb = 1 << 1,
|
||||
AwakeLogo = 1 << 2,
|
||||
AwakeKeyb = 1 << 3,
|
||||
SleepLogo = 1 << 4,
|
||||
SleepKeyb = 1 << 5,
|
||||
ShutdownLogo = 1 << 6,
|
||||
ShutdownKeyb = 1 << 7,
|
||||
BootBar = 1 << (7 + 2),
|
||||
AwakeBar = 1 << (7 + 3),
|
||||
SleepBar = 1 << (7 + 4),
|
||||
ShutdownBar = 1 << (7 + 5),
|
||||
BootLid = 1 << (15 + 1),
|
||||
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 {
|
||||
fn from(a: AuraDevRog2) -> Self {
|
||||
a as u32
|
||||
}
|
||||
}
|
||||
|
||||
impl AuraDevRog2 {
|
||||
pub fn to_bytes(control: &[Self]) -> [u8; 4] {
|
||||
let mut a: u32 = 0;
|
||||
for n in control {
|
||||
a |= *n as u32;
|
||||
}
|
||||
[
|
||||
(a & 0xff) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff000000) >> 24) as u8,
|
||||
]
|
||||
}
|
||||
|
||||
pub const fn dev_id() -> &'static str {
|
||||
"0x196b"
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::deprecated::AuraDevRog2;
|
||||
|
||||
#[test]
|
||||
fn check_0x19b6_control_bytes_binary_rep() {
|
||||
fn to_binary_string(bytes: &[AuraDevRog2]) -> String {
|
||||
let bytes = AuraDevRog2::to_bytes(bytes);
|
||||
format!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
)
|
||||
}
|
||||
|
||||
let boot_logo_ = to_binary_string(&[AuraDevRog2::BootLogo]);
|
||||
let boot_keyb_ = to_binary_string(&[AuraDevRog2::BootKeyb]);
|
||||
let sleep_logo = to_binary_string(&[AuraDevRog2::SleepLogo]);
|
||||
let sleep_keyb = to_binary_string(&[AuraDevRog2::SleepKeyb]);
|
||||
let awake_logo = to_binary_string(&[AuraDevRog2::AwakeLogo]);
|
||||
let awake_keyb = to_binary_string(&[AuraDevRog2::AwakeKeyb]);
|
||||
let shut_logo_ = to_binary_string(&[AuraDevRog2::ShutdownLogo]);
|
||||
let shut_keyb_ = to_binary_string(&[AuraDevRog2::ShutdownKeyb]);
|
||||
let boot_bar__ = to_binary_string(&[AuraDevRog2::BootBar]);
|
||||
let awake_bar_ = to_binary_string(&[AuraDevRog2::AwakeBar]);
|
||||
let sleep_bar_ = to_binary_string(&[AuraDevRog2::SleepBar]);
|
||||
let shut_bar__ = to_binary_string(&[AuraDevRog2::ShutdownBar]);
|
||||
let boot_lid__ = to_binary_string(&[AuraDevRog2::BootLid]);
|
||||
let awkae_lid_ = to_binary_string(&[AuraDevRog2::AwakeLid]);
|
||||
let sleep_lid_ = to_binary_string(&[AuraDevRog2::SleepLid]);
|
||||
let shut_lid__ = to_binary_string(&[AuraDevRog2::ShutdownLid]);
|
||||
let boot_rear_ = to_binary_string(&[AuraDevRog2::BootRearGlow]);
|
||||
let awake_rear = to_binary_string(&[AuraDevRog2::AwakeRearGlow]);
|
||||
let sleep_rear = to_binary_string(&[AuraDevRog2::SleepRearGlow]);
|
||||
let shut_rear_ = to_binary_string(&[AuraDevRog2::ShutdownRearGlow]);
|
||||
|
||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
|
||||
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!(sleep_bar_, "00000000, 00001000, 00000000, 00000000");
|
||||
assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000");
|
||||
//
|
||||
assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000");
|
||||
assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000");
|
||||
assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000");
|
||||
assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 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");
|
||||
|
||||
// All on
|
||||
let byte1 = [
|
||||
AuraDevRog2::BootLogo,
|
||||
AuraDevRog2::BootKeyb,
|
||||
AuraDevRog2::SleepLogo,
|
||||
AuraDevRog2::SleepKeyb,
|
||||
AuraDevRog2::AwakeLogo,
|
||||
AuraDevRog2::AwakeKeyb,
|
||||
AuraDevRog2::ShutdownLogo,
|
||||
AuraDevRog2::ShutdownKeyb,
|
||||
AuraDevRog2::BootBar,
|
||||
AuraDevRog2::AwakeBar,
|
||||
AuraDevRog2::SleepBar,
|
||||
AuraDevRog2::ShutdownBar,
|
||||
AuraDevRog2::AwakeLid,
|
||||
AuraDevRog2::BootLid,
|
||||
AuraDevRog2::SleepLid,
|
||||
AuraDevRog2::ShutdownLid,
|
||||
AuraDevRog2::AwakeRearGlow,
|
||||
AuraDevRog2::BootRearGlow,
|
||||
AuraDevRog2::SleepRearGlow,
|
||||
AuraDevRog2::ShutdownRearGlow,
|
||||
];
|
||||
let out = to_binary_string(&byte1);
|
||||
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::{EffectState, InputForEffect};
|
||||
use crate::advanced::LedCode;
|
||||
use crate::keyboard::{KeyLayout, LedCode};
|
||||
use crate::Colour;
|
||||
|
||||
pub struct InputBased {
|
||||
@@ -14,7 +14,7 @@ pub struct InputBased {
|
||||
}
|
||||
|
||||
impl EffectState for InputBased {
|
||||
fn next_colour_state(&mut self, _layout: &crate::layouts::KeyLayout) {
|
||||
fn next_colour_state(&mut self, _layout: &KeyLayout) {
|
||||
self.input.next_colour_state();
|
||||
self.colour = self.input.get_colour();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::EffectState;
|
||||
use crate::advanced::LedCode;
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::{KeyLayout, LedCode};
|
||||
use crate::{effect_state_impl, Colour, Speed};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::advanced::LedCode;
|
||||
use crate::effects::{p_random, EffectState};
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::{KeyLayout, LedCode};
|
||||
use crate::{effect_state_impl, Colour};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
|
||||
@@ -12,8 +12,7 @@ pub use breathe::*;
|
||||
mod static_;
|
||||
pub use static_::*;
|
||||
|
||||
use crate::advanced::{LedCode, LedUsbPackets, UsbPackets};
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::{KeyLayout, LedCode, LedUsbPackets, UsbPackets};
|
||||
use crate::Colour;
|
||||
|
||||
// static mut RNDINDEX: usize = 0;
|
||||
@@ -132,12 +131,12 @@ macro_rules! effect_state_impl {
|
||||
self.colour
|
||||
}
|
||||
|
||||
fn get_led(&self) -> $crate::advanced::LedCode {
|
||||
fn get_led(&self) -> $crate::keyboard::LedCode {
|
||||
self.led.clone()
|
||||
}
|
||||
|
||||
/// Change the led type
|
||||
fn set_led(&mut self, address: $crate::advanced::LedCode) {
|
||||
fn set_led(&mut self, address: $crate::keyboard::LedCode) {
|
||||
self.led = address;
|
||||
}
|
||||
};
|
||||
@@ -148,14 +147,14 @@ macro_rules! effect_impl {
|
||||
($($effect:ident),*) => {
|
||||
impl Effect {
|
||||
/// Get the type of LED set
|
||||
pub fn led(&self) -> $crate::advanced::LedCode {
|
||||
pub fn led(&self) -> $crate::keyboard::LedCode {
|
||||
match self {
|
||||
$(Effect::$effect(c) => c.get_led(),)*
|
||||
}
|
||||
}
|
||||
|
||||
/// Change the led type (can be used to change location of the effect)
|
||||
pub fn set_led(&mut self, address: $crate::advanced::LedCode) {
|
||||
pub fn set_led(&mut self, address: $crate::keyboard::LedCode) {
|
||||
match self {
|
||||
$(Effect::$effect(c) => c.set_led(address),)*
|
||||
}
|
||||
@@ -200,9 +199,8 @@ effect_impl!(Static, Breathe, DoomFlicker, DoomLightFlash);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::advanced::LedCode;
|
||||
use crate::effects::{AdvancedEffects, Breathe, DoomFlicker, Effect, Static};
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::{KeyLayout, LedCode};
|
||||
use crate::{Colour, Speed};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::EffectState;
|
||||
use crate::advanced::LedCode;
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::{KeyLayout, LedCode};
|
||||
use crate::{effect_state_impl, Colour};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
|
||||
@@ -490,9 +490,157 @@ impl From<LedUsbPackets> for UsbPackets {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LedCode> for &str {
|
||||
fn from(k: LedCode) -> Self {
|
||||
(&k).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&LedCode> for &str {
|
||||
fn from(k: &LedCode) -> Self {
|
||||
#[allow(clippy::match_same_arms)]
|
||||
match k {
|
||||
LedCode::VolUp => "Volume Up",
|
||||
LedCode::VolDown => "Volume Down",
|
||||
LedCode::MicMute => "Mute Mic",
|
||||
LedCode::RogApp => "ROG",
|
||||
LedCode::RogFan => "Fan Control",
|
||||
LedCode::Esc => "Escape",
|
||||
LedCode::F1 => "F1",
|
||||
LedCode::F2 => "F2",
|
||||
LedCode::F3 => "F3",
|
||||
LedCode::F4 => "F4",
|
||||
LedCode::F5 => "F5",
|
||||
LedCode::F6 => "F6",
|
||||
LedCode::F7 => "F7",
|
||||
LedCode::F8 => "F8",
|
||||
LedCode::F9 => "F9",
|
||||
LedCode::F10 => "F10",
|
||||
LedCode::F11 => "F11",
|
||||
LedCode::F12 => "F12",
|
||||
LedCode::Del => "Delete",
|
||||
LedCode::Tilde => "Tilde",
|
||||
LedCode::N1 => "1",
|
||||
LedCode::N2 => "2",
|
||||
LedCode::N3 => "3",
|
||||
LedCode::N4 => "4",
|
||||
LedCode::N5 => "5",
|
||||
LedCode::N6 => "6",
|
||||
LedCode::N7 => "7",
|
||||
LedCode::N8 => "8",
|
||||
LedCode::N9 => "9",
|
||||
LedCode::N0 => "0",
|
||||
LedCode::Hyphen => "-",
|
||||
LedCode::Equals => "=",
|
||||
LedCode::Backspace => "Backspace",
|
||||
LedCode::Backspace3_1 => "Backspace LED 1",
|
||||
LedCode::Backspace3_2 => "Backspace LED 2",
|
||||
LedCode::Backspace3_3 => "Backspace LED 3",
|
||||
LedCode::Home => "Home",
|
||||
LedCode::Tab => "Tab",
|
||||
LedCode::Q => "Q",
|
||||
LedCode::W => "W",
|
||||
LedCode::E => "E",
|
||||
LedCode::R => "R",
|
||||
LedCode::T => "T",
|
||||
LedCode::Y => "Y",
|
||||
LedCode::U => "U",
|
||||
LedCode::I => "I",
|
||||
LedCode::O => "O",
|
||||
LedCode::P => "P",
|
||||
LedCode::LBracket => "[",
|
||||
LedCode::RBracket => "]",
|
||||
LedCode::BackSlash => "\\",
|
||||
LedCode::PgUp => "Page Up",
|
||||
LedCode::Caps => "Caps Lock",
|
||||
LedCode::A => "A",
|
||||
LedCode::S => "S",
|
||||
LedCode::D => "D",
|
||||
LedCode::F => "F",
|
||||
LedCode::G => "G",
|
||||
LedCode::H => "H",
|
||||
LedCode::J => "J",
|
||||
LedCode::K => "K",
|
||||
LedCode::L => "L",
|
||||
LedCode::SemiColon => ";",
|
||||
LedCode::Quote => "'",
|
||||
LedCode::Return => "Return",
|
||||
LedCode::Return3_1 => "Return LED 1",
|
||||
LedCode::Return3_2 => "Return LED 2",
|
||||
LedCode::Return3_3 => "Return LED 3",
|
||||
LedCode::PgDn => "Page Down",
|
||||
LedCode::LShift => "Left Shift",
|
||||
LedCode::LShift3_1 => "Left Shift LED 1",
|
||||
LedCode::LShift3_2 => "Left Shift LED 2",
|
||||
LedCode::LShift3_3 => "Left Shift LED 3",
|
||||
LedCode::Z => "Z",
|
||||
LedCode::X => "X",
|
||||
LedCode::C => "C",
|
||||
LedCode::V => "V",
|
||||
LedCode::B => "B",
|
||||
LedCode::N => "N",
|
||||
LedCode::M => "M",
|
||||
LedCode::Comma => ",",
|
||||
LedCode::Period => ".",
|
||||
LedCode::Star => "*",
|
||||
LedCode::NumPadDel => "Delete",
|
||||
LedCode::NumPadPlus => "+",
|
||||
LedCode::NumPadEnter => "Enter",
|
||||
LedCode::NumPadPause => "Pause",
|
||||
LedCode::NumPadPrtSc => "Print Screen",
|
||||
LedCode::NumPadHome => "Home",
|
||||
LedCode::NumLock => "Num-Lock",
|
||||
LedCode::FwdSlash => "/",
|
||||
LedCode::Rshift => "Right Shift",
|
||||
LedCode::Rshift3_1 => "Right Shift LED 1",
|
||||
LedCode::Rshift3_2 => "Right Shift LED 2",
|
||||
LedCode::Rshift3_3 => "Right Shift LED 3",
|
||||
LedCode::End => "End",
|
||||
LedCode::LCtrl => "Left Control",
|
||||
LedCode::LFn => "Left Fn",
|
||||
LedCode::Meta => "Meta",
|
||||
LedCode::LAlt => "Left Alt",
|
||||
LedCode::Spacebar => "Space",
|
||||
LedCode::Spacebar5_1 => "Space LED 1",
|
||||
LedCode::Spacebar5_2 => "Space LED 2",
|
||||
LedCode::Spacebar5_3 => "Space LED 3",
|
||||
LedCode::Spacebar5_4 => "Space LED 4",
|
||||
LedCode::Spacebar5_5 => "Space LED 5",
|
||||
LedCode::RAlt => "Right Alt",
|
||||
LedCode::PrtSc => "Print Screen",
|
||||
LedCode::RCtrl => "Right Control",
|
||||
LedCode::Pause => "Pause",
|
||||
LedCode::Up => "Up",
|
||||
LedCode::Down => "Down",
|
||||
LedCode::Left => "Left",
|
||||
LedCode::Right => "Right",
|
||||
LedCode::RFn => "Right Fn",
|
||||
LedCode::MediaPlay => "Media Play",
|
||||
LedCode::MediaStop => "Media Stop",
|
||||
LedCode::MediaNext => "Media Next",
|
||||
LedCode::MediaPrev => "Media Previous",
|
||||
LedCode::LidLogo => "Lid Logo",
|
||||
LedCode::LidLeft => "Lid Left",
|
||||
LedCode::LidRight => "Lid Right",
|
||||
LedCode::LightbarRight => "Lightbar Right",
|
||||
LedCode::LightbarRightCorner => "Lightbar Right Corner",
|
||||
LedCode::LightbarRightBottom => "Lightbar Right Bottom",
|
||||
LedCode::LightbarLeftBottom => "Lightbar Left Bottom",
|
||||
LedCode::LightbarLeftCorner => "Lightbar Left Corner",
|
||||
LedCode::LightbarLeft => "Lightbar Left",
|
||||
LedCode::Spacing | LedCode::Blocking => "",
|
||||
LedCode::SingleZone => "Single Zoned Keyboard",
|
||||
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
|
||||
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
|
||||
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::advanced::{LedCode, LedUsbPackets, UsbPackets};
|
||||
use crate::keyboard::{LedCode, LedUsbPackets, UsbPackets};
|
||||
|
||||
macro_rules! colour_check_zoned {
|
||||
($zone:expr, $pkt_idx_start:expr) => {
|
||||
@@ -8,10 +8,10 @@ use std::slice::Iter;
|
||||
use log::warn;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::advanced::LedCode;
|
||||
use crate::aura_detection::LaptopLedData;
|
||||
use crate::error::Error;
|
||||
use crate::{AdvancedAuraType, AuraModeNum, AuraZone};
|
||||
use crate::keyboard::{AdvancedAuraType, LedCode};
|
||||
use crate::{AuraModeNum, AuraZone};
|
||||
|
||||
/// The `key_type` plays a role in effects (eventually). You could for example
|
||||
/// add a `ShapeType::Spacing` to pad out an effect, such as a laserbeam across
|
||||
@@ -459,7 +459,7 @@ mod tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::aura_detection::LedSupportFile;
|
||||
use crate::layouts::KeyLayout;
|
||||
use crate::keyboard::KeyLayout;
|
||||
|
||||
#[test]
|
||||
fn check_parse_all() {
|
||||
20
rog-aura/src/keyboard/mod.rs
Normal file
20
rog-aura/src/keyboard/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
/// All handling for `RgbAddress`ing.
|
||||
mod advanced;
|
||||
pub use advanced::*;
|
||||
|
||||
/// Helpers for consructing keyboard layouts for UI use and effects
|
||||
mod layouts;
|
||||
pub use layouts::*;
|
||||
|
||||
mod power;
|
||||
pub use power::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize)]
|
||||
pub enum AdvancedAuraType {
|
||||
/// A `None` will apply the effect to the whole keyboard via basic-static
|
||||
/// mode
|
||||
#[default]
|
||||
None,
|
||||
Zoned(Vec<LedCode>),
|
||||
PerKey,
|
||||
}
|
||||
472
rog-aura/src/keyboard/power.rs
Normal file
472
rog-aura/src/keyboard/power.rs
Normal file
@@ -0,0 +1,472 @@
|
||||
//! Power state for Laptop MCU RGB/LED. This is generally for newer
|
||||
//! 0x18c6, 0x19B6, 0x1a30, keyboard models (2021+)
|
||||
use std::fmt::Debug;
|
||||
use std::ops::{BitAnd, BitOr};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::aura_detection::PowerZones;
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AuraPowerState {
|
||||
pub boot: bool,
|
||||
pub awake: bool,
|
||||
pub sleep: bool,
|
||||
pub shutdown: bool,
|
||||
}
|
||||
|
||||
impl Default for AuraPowerState {
|
||||
/// Defaults all to off
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AuraPowerState {
|
||||
pub fn to_byte(&self, zone: PowerZones) -> u32 {
|
||||
match zone {
|
||||
PowerZones::Logo => {
|
||||
self.boot as u32
|
||||
| (self.awake as u32) << 2
|
||||
| (self.sleep as u32) << 4
|
||||
| (self.shutdown as u32) << 6
|
||||
}
|
||||
PowerZones::Keyboard => {
|
||||
(self.boot as u32) << 1
|
||||
| (self.awake as u32) << 3
|
||||
| (self.sleep as u32) << 5
|
||||
| (self.shutdown as u32) << 7
|
||||
}
|
||||
PowerZones::Lightbar => {
|
||||
(self.boot as u32) << (7 + 2)
|
||||
| (self.awake as u32) << (7 + 3)
|
||||
| (self.sleep as u32) << (7 + 4)
|
||||
| (self.shutdown as u32) << (7 + 5)
|
||||
}
|
||||
PowerZones::Lid => {
|
||||
(self.boot as u32) << (15 + 1)
|
||||
| (self.awake as u32) << (15 + 2)
|
||||
| (self.sleep as u32) << (15 + 3)
|
||||
| (self.shutdown as u32) << (15 + 4)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct LaptopAuraPower {
|
||||
pub keyboard: AuraPowerState,
|
||||
pub logo: AuraPowerState,
|
||||
pub lightbar: AuraPowerState,
|
||||
pub lid: AuraPowerState,
|
||||
pub rear_glow: AuraPowerState,
|
||||
}
|
||||
|
||||
impl LaptopAuraPower {
|
||||
pub fn new_all_on() -> Self {
|
||||
Self {
|
||||
keyboard: AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
logo: AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
lightbar: AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
lid: AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
rear_glow: AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> [u8; 4] {
|
||||
let mut a: u32 = 0;
|
||||
a |= self.keyboard.to_byte(PowerZones::Keyboard);
|
||||
a |= self.logo.to_byte(PowerZones::Logo);
|
||||
a |= self.lid.to_byte(PowerZones::Lid);
|
||||
a |= self.lightbar.to_byte(PowerZones::Lightbar);
|
||||
a |= self.rear_glow.to_byte(PowerZones::RearGlow);
|
||||
[
|
||||
(a & 0xff) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff000000) >> 24) as u8,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum LaptopTufAuraPower {
|
||||
Boot = 0,
|
||||
Awake = 1,
|
||||
Sleep = 2,
|
||||
Keyboard = 3,
|
||||
}
|
||||
|
||||
impl LaptopTufAuraPower {
|
||||
pub const fn dev_id() -> &'static str {
|
||||
"tuf"
|
||||
}
|
||||
}
|
||||
|
||||
/// # 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 | |
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum LaptopOldAuraPower {
|
||||
Awake = 0x000002,
|
||||
Keyboard = 0x080000,
|
||||
Lightbar = 0x040500,
|
||||
Boot = 0xc31209,
|
||||
Sleep = 0x300804,
|
||||
}
|
||||
|
||||
impl From<LaptopOldAuraPower> for u32 {
|
||||
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;
|
||||
|
||||
fn bitor(self, rhs: LaptopOldAuraPower) -> Self::Output {
|
||||
self as u32 | rhs as u32
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd<LaptopOldAuraPower> for LaptopOldAuraPower {
|
||||
type Output = u32;
|
||||
|
||||
fn bitand(self, rhs: LaptopOldAuraPower) -> Self::Output {
|
||||
self as u32 & rhs as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::keyboard::{AuraPowerState, LaptopAuraPower, LaptopOldAuraPower};
|
||||
|
||||
#[test]
|
||||
fn check_0x1866_control_bytes() {
|
||||
let bytes = [LaptopOldAuraPower::Keyboard, LaptopOldAuraPower::Awake];
|
||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
|
||||
|
||||
let bytes = [LaptopOldAuraPower::Lightbar, LaptopOldAuraPower::Awake];
|
||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x04, 0x05, 0x02, 0x00]);
|
||||
|
||||
let bytes = [LaptopOldAuraPower::Sleep];
|
||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x30, 0x08, 0x04, 0x00]);
|
||||
|
||||
let bytes = [LaptopOldAuraPower::Boot];
|
||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0xc3, 0x12, 0x09, 0x00]);
|
||||
|
||||
let bytes = [
|
||||
LaptopOldAuraPower::Keyboard,
|
||||
LaptopOldAuraPower::Lightbar,
|
||||
LaptopOldAuraPower::Awake,
|
||||
LaptopOldAuraPower::Sleep,
|
||||
LaptopOldAuraPower::Boot,
|
||||
];
|
||||
|
||||
let bytes = LaptopOldAuraPower::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_0x19b6_control_bytes_binary_rep() {
|
||||
fn to_binary_string(power: &LaptopAuraPower) -> String {
|
||||
let bytes = power.to_bytes();
|
||||
format!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
)
|
||||
}
|
||||
|
||||
let boot_logo_ = to_binary_string(&LaptopAuraPower {
|
||||
logo: AuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_keyb_ = to_binary_string(&LaptopAuraPower {
|
||||
keyboard: AuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_logo = to_binary_string(&LaptopAuraPower {
|
||||
logo: AuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_keyb = to_binary_string(&LaptopAuraPower {
|
||||
keyboard: AuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_logo = to_binary_string(&LaptopAuraPower {
|
||||
logo: AuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_keyb = to_binary_string(&LaptopAuraPower {
|
||||
keyboard: AuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_logo_ = to_binary_string(&LaptopAuraPower {
|
||||
logo: AuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_keyb_ = to_binary_string(&LaptopAuraPower {
|
||||
keyboard: AuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_bar__ = to_binary_string(&LaptopAuraPower {
|
||||
lightbar: AuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_bar_ = to_binary_string(&LaptopAuraPower {
|
||||
lightbar: AuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_bar_ = to_binary_string(&LaptopAuraPower {
|
||||
lightbar: AuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_bar__ = to_binary_string(&LaptopAuraPower {
|
||||
lightbar: AuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_lid__ = to_binary_string(&LaptopAuraPower {
|
||||
lid: AuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_lid_ = to_binary_string(&LaptopAuraPower {
|
||||
lid: AuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_lid_ = to_binary_string(&LaptopAuraPower {
|
||||
lid: AuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_lid__ = to_binary_string(&LaptopAuraPower {
|
||||
lid: AuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_rear_ = to_binary_string(&LaptopAuraPower {
|
||||
rear_glow: AuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_rear = to_binary_string(&LaptopAuraPower {
|
||||
rear_glow: AuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_rear = to_binary_string(&LaptopAuraPower {
|
||||
rear_glow: AuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_rear_ = to_binary_string(&LaptopAuraPower {
|
||||
rear_glow: AuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
|
||||
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!(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_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");
|
||||
|
||||
// All on
|
||||
let byte1 = LaptopAuraPower::new_all_on();
|
||||
let out = to_binary_string(&byte1);
|
||||
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,21 @@
|
||||
// TODO: Generic builtin modes
|
||||
// TODO: Traits for finding device + writing generic modes
|
||||
// TODO: Traits for writing aura_sync
|
||||
|
||||
mod builtin_modes;
|
||||
use advanced::LedCode;
|
||||
pub use builtin_modes::*;
|
||||
// TODO: separate keyboard and laptop parts?
|
||||
|
||||
/// A container of images/grids/gifs/pauses which can be iterated over to
|
||||
/// generate cool effects
|
||||
pub mod effects;
|
||||
|
||||
/// All handling for `RgbAddress`ing.
|
||||
pub mod advanced;
|
||||
/// Convert the `RgbAddress` to `&str` labels
|
||||
pub mod advanced_to_str;
|
||||
mod builtin_modes;
|
||||
pub use builtin_modes::*;
|
||||
|
||||
/// Helper for detecting what is available
|
||||
pub mod aura_detection;
|
||||
pub mod error;
|
||||
/// Helpers for consructing keyboard layouts for UI use and effects
|
||||
pub mod layouts;
|
||||
pub mod usb;
|
||||
|
||||
pub mod power;
|
||||
|
||||
mod deprecated;
|
||||
pub mod keyboard;
|
||||
|
||||
pub const LED_MSG_LEN: usize = 17;
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
@@ -64,13 +56,3 @@ pub const ORANGE: Colour = Colour {
|
||||
b: 0x00,
|
||||
};
|
||||
pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE];
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize)]
|
||||
pub enum AdvancedAuraType {
|
||||
/// A `None` will apply the effect to the whole keyboard via basic-static
|
||||
/// mode
|
||||
#[default]
|
||||
None,
|
||||
Zoned(Vec<LedCode>),
|
||||
PerKey,
|
||||
}
|
||||
|
||||
@@ -1,344 +0,0 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::aura_detection::PowerZones;
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct KbAuraPowerState {
|
||||
pub zone: PowerZones,
|
||||
pub boot: bool,
|
||||
pub awake: bool,
|
||||
pub sleep: bool,
|
||||
pub shutdown: bool,
|
||||
}
|
||||
|
||||
impl Default for KbAuraPowerState {
|
||||
/// Defaults all to off
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl KbAuraPowerState {
|
||||
pub fn to_byte(&self, zone: PowerZones) -> u32 {
|
||||
match zone {
|
||||
PowerZones::Logo => {
|
||||
self.boot as u32
|
||||
| (self.awake as u32) << 2
|
||||
| (self.sleep as u32) << 4
|
||||
| (self.shutdown as u32) << 6
|
||||
}
|
||||
PowerZones::Keyboard => {
|
||||
(self.boot as u32) << 1
|
||||
| (self.awake as u32) << 3
|
||||
| (self.sleep as u32) << 5
|
||||
| (self.shutdown as u32) << 7
|
||||
}
|
||||
PowerZones::Lightbar => {
|
||||
(self.boot as u32) << (7 + 2)
|
||||
| (self.awake as u32) << (7 + 3)
|
||||
| (self.sleep as u32) << (7 + 4)
|
||||
| (self.shutdown as u32) << (7 + 5)
|
||||
}
|
||||
PowerZones::Lid => {
|
||||
(self.boot as u32) << (15 + 1)
|
||||
| (self.awake as u32) << (15 + 2)
|
||||
| (self.sleep as u32) << (15 + 3)
|
||||
| (self.shutdown as u32) << (15 + 4)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct AuraPower {
|
||||
pub keyboard: KbAuraPowerState,
|
||||
pub logo: KbAuraPowerState,
|
||||
pub lightbar: KbAuraPowerState,
|
||||
pub lid: KbAuraPowerState,
|
||||
pub rear_glow: KbAuraPowerState,
|
||||
}
|
||||
|
||||
impl AuraPower {
|
||||
pub fn new_all_on() -> Self {
|
||||
Self {
|
||||
keyboard: KbAuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
logo: KbAuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
lightbar: KbAuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
lid: KbAuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
rear_glow: KbAuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> [u8; 4] {
|
||||
let mut a: u32 = 0;
|
||||
a |= self.keyboard.to_byte(PowerZones::Keyboard);
|
||||
a |= self.logo.to_byte(PowerZones::Logo);
|
||||
a |= self.lid.to_byte(PowerZones::Lid);
|
||||
a |= self.lightbar.to_byte(PowerZones::Lightbar);
|
||||
a |= self.rear_glow.to_byte(PowerZones::RearGlow);
|
||||
[
|
||||
(a & 0xff) as u8,
|
||||
((a & 0xff00) >> 8) as u8,
|
||||
((a & 0xff0000) >> 16) as u8,
|
||||
((a & 0xff000000) >> 24) as u8,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_0x19b6_control_bytes_binary_rep() {
|
||||
fn to_binary_string(power: &AuraPower) -> String {
|
||||
let bytes = power.to_bytes();
|
||||
format!(
|
||||
"{:08b}, {:08b}, {:08b}, {:08b}",
|
||||
bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
)
|
||||
}
|
||||
|
||||
let boot_logo_ = to_binary_string(&AuraPower {
|
||||
logo: KbAuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_keyb_ = to_binary_string(&AuraPower {
|
||||
keyboard: KbAuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_logo = to_binary_string(&AuraPower {
|
||||
logo: KbAuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_keyb = to_binary_string(&AuraPower {
|
||||
keyboard: KbAuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_logo = to_binary_string(&AuraPower {
|
||||
logo: KbAuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_keyb = to_binary_string(&AuraPower {
|
||||
keyboard: KbAuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_logo_ = to_binary_string(&AuraPower {
|
||||
logo: KbAuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_keyb_ = to_binary_string(&AuraPower {
|
||||
keyboard: KbAuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_bar__ = to_binary_string(&AuraPower {
|
||||
lightbar: KbAuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_bar_ = to_binary_string(&AuraPower {
|
||||
lightbar: KbAuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_bar_ = to_binary_string(&AuraPower {
|
||||
lightbar: KbAuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_bar__ = to_binary_string(&AuraPower {
|
||||
lightbar: KbAuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_lid__ = to_binary_string(&AuraPower {
|
||||
lid: KbAuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awkae_lid_ = to_binary_string(&AuraPower {
|
||||
lid: KbAuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_lid_ = to_binary_string(&AuraPower {
|
||||
lid: KbAuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_lid__ = to_binary_string(&AuraPower {
|
||||
lid: KbAuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let boot_rear_ = to_binary_string(&AuraPower {
|
||||
rear_glow: KbAuraPowerState {
|
||||
boot: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let awake_rear = to_binary_string(&AuraPower {
|
||||
rear_glow: KbAuraPowerState {
|
||||
awake: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let sleep_rear = to_binary_string(&AuraPower {
|
||||
rear_glow: KbAuraPowerState {
|
||||
sleep: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
let shut_rear_ = to_binary_string(&AuraPower {
|
||||
rear_glow: KbAuraPowerState {
|
||||
shutdown: true,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||
assert_eq!(boot_keyb_, "00000010, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_logo, "00000100, 00000000, 00000000, 00000000");
|
||||
assert_eq!(awake_keyb, "00001000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_logo, "00010000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(sleep_keyb, "00100000, 00000000, 00000000, 00000000");
|
||||
assert_eq!(shut_logo_, "01000000, 00000000, 00000000, 00000000");
|
||||
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!(sleep_bar_, "00000000, 00001000, 00000000, 00000000");
|
||||
assert_eq!(shut_bar__, "00000000, 00010000, 00000000, 00000000");
|
||||
//
|
||||
assert_eq!(boot_lid__, "00000000, 00000000, 00000001, 00000000");
|
||||
assert_eq!(awkae_lid_, "00000000, 00000000, 00000010, 00000000");
|
||||
assert_eq!(sleep_lid_, "00000000, 00000000, 00000100, 00000000");
|
||||
assert_eq!(shut_lid__, "00000000, 00000000, 00001000, 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");
|
||||
|
||||
// All on
|
||||
let byte1 = AuraPower::new_all_on();
|
||||
let out = to_binary_string(&byte1);
|
||||
assert_eq!(out, "11111111, 00011110, 00001111, 00001111");
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
use std::fmt::Debug;
|
||||
use std::ops::{BitAnd, BitOr};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::power::AuraPower;
|
||||
|
||||
pub const LED_INIT1: [u8; 2] = [0x5d, 0xb9];
|
||||
pub const LED_INIT2: &str = "]ASUS Tech.Inc."; // ] == 0x5d
|
||||
pub const LED_INIT3: [u8; 6] = [0x5d, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
pub const LED_INIT4: &str = "^ASUS Tech.Inc."; // ^ == 0x5e
|
||||
pub const LED_INIT5: [u8; 6] = [0x5e, 0x05, 0x20, 0x31, 0, 0x08];
|
||||
use crate::keyboard::{LaptopAuraPower, LaptopOldAuraPower, LaptopTufAuraPower};
|
||||
|
||||
// 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];
|
||||
@@ -36,11 +29,15 @@ pub enum AuraDevice {
|
||||
Tuf = 0,
|
||||
X1854 = 1,
|
||||
X1869 = 2,
|
||||
/// Pre-2020 laptops
|
||||
X1866 = 3,
|
||||
/// Z13 lightbar
|
||||
X18c6 = 4,
|
||||
/// Most modern laptops
|
||||
#[default]
|
||||
X19b6 = 5,
|
||||
X1a30 = 6,
|
||||
/// The ROG Ally
|
||||
X1abe = 7,
|
||||
Unknown = 99,
|
||||
}
|
||||
@@ -51,22 +48,14 @@ impl AuraDevice {
|
||||
}
|
||||
|
||||
pub fn is_old_style(&self) -> bool {
|
||||
!matches!(
|
||||
matches!(
|
||||
self,
|
||||
AuraDevice::Unknown
|
||||
| AuraDevice::Tuf
|
||||
| AuraDevice::X19b6
|
||||
| AuraDevice::X18c6
|
||||
| AuraDevice::X1a30
|
||||
| AuraDevice::X1abe
|
||||
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 | AuraDevice::X1abe
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_new_style(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 | AuraDevice::X1abe
|
||||
)
|
||||
!self.is_old_style() && !self.is_tuf_style()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,142 +114,10 @@ impl Debug for AuraDevice {
|
||||
pub struct AuraPowerDev {
|
||||
/// TUF laptops use a similar style of control to the older ROG devices but
|
||||
/// through WMI
|
||||
pub tuf: Vec<AuraDevTuf>,
|
||||
pub tuf: Vec<LaptopTufAuraPower>,
|
||||
/// Pre-0x19b6 devices use a different smaller scheme to the newer ROG
|
||||
/// devices
|
||||
pub old_rog: Vec<AuraDevRog1>,
|
||||
pub old_rog: Vec<LaptopOldAuraPower>,
|
||||
/// ASUS standardised control scheme from 2020 onwards
|
||||
pub rog: AuraPower,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum AuraDevTuf {
|
||||
Boot = 0,
|
||||
Awake = 1,
|
||||
Sleep = 2,
|
||||
Keyboard = 3,
|
||||
}
|
||||
|
||||
impl AuraDevTuf {
|
||||
pub const fn dev_id() -> &'static str {
|
||||
"tuf"
|
||||
}
|
||||
}
|
||||
|
||||
/// # 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 | |
|
||||
#[typeshare]
|
||||
#[cfg_attr(
|
||||
feature = "dbus",
|
||||
derive(Type, Value, OwnedValue),
|
||||
zvariant(signature = "u")
|
||||
)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum AuraDevRog1 {
|
||||
Awake = 0x000002,
|
||||
Keyboard = 0x080000,
|
||||
Lightbar = 0x040500,
|
||||
Boot = 0xc31209,
|
||||
Sleep = 0x300804,
|
||||
}
|
||||
|
||||
impl From<AuraDevRog1> for u32 {
|
||||
fn from(a: AuraDevRog1) -> Self {
|
||||
a as u32
|
||||
}
|
||||
}
|
||||
|
||||
impl AuraDevRog1 {
|
||||
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<AuraDevRog1> for AuraDevRog1 {
|
||||
type Output = u32;
|
||||
|
||||
fn bitor(self, rhs: AuraDevRog1) -> Self::Output {
|
||||
self as u32 | rhs as u32
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd<AuraDevRog1> for AuraDevRog1 {
|
||||
type Output = u32;
|
||||
|
||||
fn bitand(self, rhs: AuraDevRog1) -> Self::Output {
|
||||
self as u32 & rhs as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::AuraDevRog1;
|
||||
|
||||
#[test]
|
||||
fn check_0x1866_control_bytes() {
|
||||
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, 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, 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, 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, 0x00]);
|
||||
|
||||
let bytes = [
|
||||
AuraDevRog1::Keyboard,
|
||||
AuraDevRog1::Lightbar,
|
||||
AuraDevRog1::Awake,
|
||||
AuraDevRog1::Sleep,
|
||||
AuraDevRog1::Boot,
|
||||
];
|
||||
|
||||
let bytes = AuraDevRog1::to_bytes(&bytes);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0xff, 0x1f, 0x000f, 0x00]);
|
||||
}
|
||||
pub rog: LaptopAuraPower,
|
||||
}
|
||||
|
||||
@@ -46,53 +46,54 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
|
||||
}
|
||||
}
|
||||
|
||||
use rog_aura::power::KbAuraPowerState;
|
||||
use rog_aura::keyboard::{AuraPowerState, LaptopOldAuraPower, LaptopTufAuraPower};
|
||||
use rog_aura::usb::AuraPowerDev;
|
||||
use slint::{Model, ModelRc, RgbaColor};
|
||||
|
||||
use crate::slint_generatedMainWindow::AuraDevTuf as SlintAuraDevTuf;
|
||||
impl From<rog_aura::usb::AuraDevTuf> for SlintAuraDevTuf {
|
||||
fn from(value: rog_aura::usb::AuraDevTuf) -> Self {
|
||||
impl From<LaptopTufAuraPower> for SlintAuraDevTuf {
|
||||
fn from(value: LaptopTufAuraPower) -> Self {
|
||||
match value {
|
||||
rog_aura::usb::AuraDevTuf::Boot => SlintAuraDevTuf::Boot,
|
||||
rog_aura::usb::AuraDevTuf::Awake => SlintAuraDevTuf::Awake,
|
||||
rog_aura::usb::AuraDevTuf::Sleep => SlintAuraDevTuf::Sleep,
|
||||
rog_aura::usb::AuraDevTuf::Keyboard => SlintAuraDevTuf::Keyboard,
|
||||
LaptopTufAuraPower::Boot => SlintAuraDevTuf::Boot,
|
||||
LaptopTufAuraPower::Awake => SlintAuraDevTuf::Awake,
|
||||
LaptopTufAuraPower::Sleep => SlintAuraDevTuf::Sleep,
|
||||
LaptopTufAuraPower::Keyboard => SlintAuraDevTuf::Keyboard,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SlintAuraDevTuf> for rog_aura::usb::AuraDevTuf {
|
||||
impl From<SlintAuraDevTuf> for LaptopTufAuraPower {
|
||||
fn from(value: SlintAuraDevTuf) -> Self {
|
||||
match value {
|
||||
SlintAuraDevTuf::Boot => rog_aura::usb::AuraDevTuf::Boot,
|
||||
SlintAuraDevTuf::Awake => rog_aura::usb::AuraDevTuf::Awake,
|
||||
SlintAuraDevTuf::Sleep => rog_aura::usb::AuraDevTuf::Sleep,
|
||||
SlintAuraDevTuf::Keyboard => rog_aura::usb::AuraDevTuf::Keyboard,
|
||||
SlintAuraDevTuf::Boot => LaptopTufAuraPower::Boot,
|
||||
SlintAuraDevTuf::Awake => LaptopTufAuraPower::Awake,
|
||||
SlintAuraDevTuf::Sleep => LaptopTufAuraPower::Sleep,
|
||||
SlintAuraDevTuf::Keyboard => LaptopTufAuraPower::Keyboard,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use crate::slint_generatedMainWindow::AuraDevRog1 as SlintAuraDevRog1;
|
||||
impl From<rog_aura::usb::AuraDevRog1> for SlintAuraDevRog1 {
|
||||
fn from(value: rog_aura::usb::AuraDevRog1) -> Self {
|
||||
impl From<LaptopOldAuraPower> for SlintAuraDevRog1 {
|
||||
fn from(value: LaptopOldAuraPower) -> Self {
|
||||
match value {
|
||||
rog_aura::usb::AuraDevRog1::Awake => SlintAuraDevRog1::Awake,
|
||||
rog_aura::usb::AuraDevRog1::Keyboard => SlintAuraDevRog1::Keyboard,
|
||||
rog_aura::usb::AuraDevRog1::Lightbar => SlintAuraDevRog1::Lightbar,
|
||||
rog_aura::usb::AuraDevRog1::Boot => SlintAuraDevRog1::Boot,
|
||||
rog_aura::usb::AuraDevRog1::Sleep => SlintAuraDevRog1::Sleep,
|
||||
LaptopOldAuraPower::Awake => SlintAuraDevRog1::Awake,
|
||||
LaptopOldAuraPower::Keyboard => SlintAuraDevRog1::Keyboard,
|
||||
LaptopOldAuraPower::Lightbar => SlintAuraDevRog1::Lightbar,
|
||||
LaptopOldAuraPower::Boot => SlintAuraDevRog1::Boot,
|
||||
LaptopOldAuraPower::Sleep => SlintAuraDevRog1::Sleep,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SlintAuraDevRog1> for rog_aura::usb::AuraDevRog1 {
|
||||
impl From<SlintAuraDevRog1> for LaptopOldAuraPower {
|
||||
fn from(value: SlintAuraDevRog1) -> Self {
|
||||
match value {
|
||||
SlintAuraDevRog1::Awake => rog_aura::usb::AuraDevRog1::Awake,
|
||||
SlintAuraDevRog1::Keyboard => rog_aura::usb::AuraDevRog1::Keyboard,
|
||||
SlintAuraDevRog1::Lightbar => rog_aura::usb::AuraDevRog1::Lightbar,
|
||||
SlintAuraDevRog1::Boot => rog_aura::usb::AuraDevRog1::Boot,
|
||||
SlintAuraDevRog1::Sleep => rog_aura::usb::AuraDevRog1::Sleep,
|
||||
SlintAuraDevRog1::Awake => LaptopOldAuraPower::Awake,
|
||||
SlintAuraDevRog1::Keyboard => LaptopOldAuraPower::Keyboard,
|
||||
SlintAuraDevRog1::Lightbar => LaptopOldAuraPower::Lightbar,
|
||||
SlintAuraDevRog1::Boot => LaptopOldAuraPower::Boot,
|
||||
SlintAuraDevRog1::Sleep => LaptopOldAuraPower::Sleep,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,93 +126,83 @@ impl From<SlintPowerZones> for rog_aura::aura_detection::PowerZones {
|
||||
use crate::slint_generatedMainWindow::{
|
||||
AuraPower as SlintAuraPower, KbAuraPowerState as SlintKbAuraPowerState,
|
||||
};
|
||||
impl From<rog_aura::power::AuraPower> for SlintAuraPower {
|
||||
fn from(value: rog_aura::power::AuraPower) -> Self {
|
||||
impl From<rog_aura::keyboard::LaptopAuraPower> for SlintAuraPower {
|
||||
fn from(value: rog_aura::keyboard::LaptopAuraPower) -> Self {
|
||||
Self {
|
||||
keyboard: SlintKbAuraPowerState {
|
||||
awake: value.keyboard.awake,
|
||||
boot: value.keyboard.boot,
|
||||
shutdown: value.keyboard.shutdown,
|
||||
sleep: value.keyboard.sleep,
|
||||
zone: value.keyboard.zone.into(),
|
||||
},
|
||||
lid: SlintKbAuraPowerState {
|
||||
awake: value.lid.awake,
|
||||
boot: value.lid.boot,
|
||||
shutdown: value.lid.shutdown,
|
||||
sleep: value.lid.sleep,
|
||||
zone: value.lid.zone.into(),
|
||||
},
|
||||
lightbar: SlintKbAuraPowerState {
|
||||
awake: value.lightbar.awake,
|
||||
boot: value.lightbar.boot,
|
||||
shutdown: value.lightbar.shutdown,
|
||||
sleep: value.lightbar.sleep,
|
||||
zone: value.lightbar.zone.into(),
|
||||
},
|
||||
logo: SlintKbAuraPowerState {
|
||||
awake: value.logo.awake,
|
||||
boot: value.logo.boot,
|
||||
shutdown: value.logo.shutdown,
|
||||
sleep: value.logo.sleep,
|
||||
zone: value.logo.zone.into(),
|
||||
},
|
||||
rear_glow: SlintKbAuraPowerState {
|
||||
awake: value.rear_glow.awake,
|
||||
boot: value.rear_glow.boot,
|
||||
shutdown: value.rear_glow.shutdown,
|
||||
sleep: value.rear_glow.sleep,
|
||||
zone: value.rear_glow.zone.into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SlintAuraPower> for rog_aura::power::AuraPower {
|
||||
impl From<SlintAuraPower> for rog_aura::keyboard::LaptopAuraPower {
|
||||
fn from(value: SlintAuraPower) -> Self {
|
||||
Self {
|
||||
keyboard: KbAuraPowerState {
|
||||
keyboard: AuraPowerState {
|
||||
awake: value.keyboard.awake,
|
||||
boot: value.keyboard.boot,
|
||||
shutdown: value.keyboard.shutdown,
|
||||
sleep: value.keyboard.sleep,
|
||||
zone: value.keyboard.zone.into(),
|
||||
},
|
||||
lid: KbAuraPowerState {
|
||||
lid: AuraPowerState {
|
||||
awake: value.lid.awake,
|
||||
boot: value.lid.boot,
|
||||
shutdown: value.lid.shutdown,
|
||||
sleep: value.lid.sleep,
|
||||
zone: value.lid.zone.into(),
|
||||
},
|
||||
lightbar: KbAuraPowerState {
|
||||
lightbar: AuraPowerState {
|
||||
awake: value.lightbar.awake,
|
||||
boot: value.lightbar.boot,
|
||||
shutdown: value.lightbar.shutdown,
|
||||
sleep: value.lightbar.sleep,
|
||||
zone: value.lightbar.zone.into(),
|
||||
},
|
||||
logo: KbAuraPowerState {
|
||||
logo: AuraPowerState {
|
||||
awake: value.logo.awake,
|
||||
boot: value.logo.boot,
|
||||
shutdown: value.logo.shutdown,
|
||||
sleep: value.logo.sleep,
|
||||
zone: value.logo.zone.into(),
|
||||
},
|
||||
rear_glow: KbAuraPowerState {
|
||||
rear_glow: AuraPowerState {
|
||||
awake: value.rear_glow.awake,
|
||||
boot: value.rear_glow.boot,
|
||||
shutdown: value.rear_glow.shutdown,
|
||||
sleep: value.rear_glow.sleep,
|
||||
zone: value.rear_glow.zone.into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use crate::slint_generatedMainWindow::AuraPowerDev as SlintAuraPowerDev;
|
||||
impl From<rog_aura::usb::AuraPowerDev> for SlintAuraPowerDev {
|
||||
fn from(value: rog_aura::usb::AuraPowerDev) -> Self {
|
||||
impl From<AuraPowerDev> for SlintAuraPowerDev {
|
||||
fn from(value: AuraPowerDev) -> Self {
|
||||
let tuf: Vec<SlintAuraDevTuf> = value
|
||||
.tuf
|
||||
.iter()
|
||||
@@ -230,18 +221,11 @@ impl From<rog_aura::usb::AuraPowerDev> for SlintAuraPowerDev {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SlintAuraPowerDev> for rog_aura::usb::AuraPowerDev {
|
||||
impl From<SlintAuraPowerDev> for AuraPowerDev {
|
||||
fn from(value: SlintAuraPowerDev) -> Self {
|
||||
let tuf: Vec<rog_aura::usb::AuraDevTuf> = value
|
||||
.tuf
|
||||
.iter()
|
||||
.map(rog_aura::usb::AuraDevTuf::from)
|
||||
.collect();
|
||||
let old_rog: Vec<rog_aura::usb::AuraDevRog1> = value
|
||||
.old_rog
|
||||
.iter()
|
||||
.map(rog_aura::usb::AuraDevRog1::from)
|
||||
.collect();
|
||||
let tuf: Vec<LaptopTufAuraPower> = value.tuf.iter().map(LaptopTufAuraPower::from).collect();
|
||||
let old_rog: Vec<LaptopOldAuraPower> =
|
||||
value.old_rog.iter().map(LaptopOldAuraPower::from).collect();
|
||||
Self {
|
||||
tuf,
|
||||
old_rog,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-04-05 03:00+0000\n"
|
||||
"POT-Creation-Date: 2024-04-05 07:19+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"
|
||||
|
||||
@@ -43,7 +43,6 @@ export enum PowerZones {
|
||||
}
|
||||
|
||||
export struct KbAuraPowerState {
|
||||
zone: PowerZones,
|
||||
boot: bool,
|
||||
awake: bool,
|
||||
sleep: bool,
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use rog_aura::advanced::UsbPackets;
|
||||
use rog_aura::aura_detection::PowerZones;
|
||||
use rog_aura::keyboard::UsbPackets;
|
||||
use rog_aura::usb::{AuraDevice, AuraPowerDev};
|
||||
use rog_aura::{AuraEffect, AuraModeNum, AuraZone, LedBrightness};
|
||||
use zbus::blocking::Connection;
|
||||
|
||||
Reference in New Issue
Block a user