mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Add Ally 1 and X as "old" style devices for power
These have a slightly different power settings data which needs to be verified. We can use the old style for now. Closes #542
This commit is contained in:
1673
Cargo.lock
generated
1673
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ default-members = [
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
tokio = { version = "^1.36.0", default-features = false, features = [
|
||||
tokio = { version = "^1.39.0", default-features = false, features = [
|
||||
"macros",
|
||||
"sync",
|
||||
"time",
|
||||
@@ -47,7 +47,7 @@ dirs = "^4.0"
|
||||
smol = "^1.3"
|
||||
mio = "0.8.11"
|
||||
|
||||
zbus = "4.2"
|
||||
zbus = "4.4"
|
||||
logind-zbus = { version = "4.0.3" } #, default-features = false, features = ["non_blocking"] }
|
||||
|
||||
serde = { version = "^1.0", features = ["serde_derive"] }
|
||||
|
||||
@@ -41,6 +41,8 @@ pub enum SetAuraZoneEnabled {
|
||||
Lid(AuraPowerStates),
|
||||
#[options(help = "")]
|
||||
RearGlow(AuraPowerStates),
|
||||
#[options(help = "")]
|
||||
Ally(AuraPowerStates),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Options)]
|
||||
|
||||
@@ -751,6 +751,7 @@ fn handle_led_power2(
|
||||
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
|
||||
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
|
||||
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ use crate::error::RogError;
|
||||
// #[serde(default)]
|
||||
pub struct AuraConfig {
|
||||
pub config_name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub ally_fix: Option<bool>,
|
||||
pub brightness: LedBrightness,
|
||||
pub current_mode: AuraModeNum,
|
||||
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
|
||||
@@ -57,6 +59,7 @@ impl AuraConfig {
|
||||
let enabled = LaptopAuraPower::new(device_type, &support_data);
|
||||
let mut config = AuraConfig {
|
||||
config_name: format!("aura_{prod_id}.ron"),
|
||||
ally_fix: None,
|
||||
brightness: LedBrightness::Med,
|
||||
current_mode: AuraModeNum::Static,
|
||||
builtins: BTreeMap::new(),
|
||||
|
||||
@@ -7,7 +7,7 @@ use log::{debug, info, warn};
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::{LedUsbPackets, UsbPackets};
|
||||
use rog_aura::usb::{LED_APPLY, LED_SET};
|
||||
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, LED_MSG_LEN};
|
||||
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, LED_MSG_LEN};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::keyboard_led::KeyboardBacklight;
|
||||
use udev::Device;
|
||||
@@ -317,6 +317,23 @@ impl CtrlKbdLed {
|
||||
config_loaded
|
||||
}
|
||||
|
||||
pub(super) fn fix_ally_power(&mut self) -> Result<(), RogError> {
|
||||
if self.led_type == AuraDeviceType::Ally {
|
||||
if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
if let Some(fix) = self.config.ally_fix.as_mut() {
|
||||
if !*fix {
|
||||
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
info!("Reset Ally power settings to base");
|
||||
}
|
||||
*fix = true;
|
||||
}
|
||||
self.config.write();
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set combination state for boot animation/sleep animation/all leds/keys
|
||||
/// leds/side leds LED active
|
||||
pub(super) fn set_power_states(&mut self) -> Result<(), RogError> {
|
||||
@@ -325,13 +342,17 @@ impl CtrlKbdLed {
|
||||
let buf = self.config.enabled.to_bytes(self.led_type);
|
||||
platform.set_kbd_rgb_state(&buf)?;
|
||||
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
|
||||
let bytes = self.config.enabled.to_bytes(self.led_type);
|
||||
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||
if let Some(p) = self.config.enabled.states.first() {
|
||||
if p.zone == PowerZones::Ally {
|
||||
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
hid_raw.write_bytes(&message)?;
|
||||
hid_raw.write_bytes(&LED_SET)?;
|
||||
// Changes won't persist unless apply is set
|
||||
hid_raw.write_bytes(&LED_APPLY)?;
|
||||
let bytes = self.config.enabled.to_bytes(self.led_type);
|
||||
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -296,6 +296,7 @@ impl CtrlTask for CtrlAuraZbus {
|
||||
impl crate::Reloadable for CtrlAuraZbus {
|
||||
async fn reload(&mut self) -> Result<(), RogError> {
|
||||
let mut ctrl = self.0.lock().await;
|
||||
ctrl.fix_ally_power()?;
|
||||
debug!("reloading keyboard mode");
|
||||
ctrl.write_current_config_mode()?;
|
||||
debug!("reloading power states");
|
||||
|
||||
@@ -903,18 +903,18 @@
|
||||
device_name: "RC71L",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, RainbowCycle],
|
||||
basic_modes: [Static, Breathe, Pulse, RainbowCycle, RainbowWave],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Ally],
|
||||
),
|
||||
(
|
||||
device_name: "RC72L",
|
||||
product_id: "",
|
||||
layout_name: "ga401q",
|
||||
basic_modes: [Static, Breathe, Pulse, RainbowCycle],
|
||||
basic_modes: [Static, Breathe, Pulse, RainbowCycle, RainbowWave],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
power_zones: [Keyboard],
|
||||
power_zones: [Ally],
|
||||
),
|
||||
])
|
||||
|
||||
@@ -102,7 +102,7 @@ impl AuraPowerState {
|
||||
]
|
||||
}
|
||||
|
||||
fn new_to_byte(&self) -> u32 {
|
||||
pub fn new_to_byte(&self) -> u32 {
|
||||
match self.zone {
|
||||
PowerZones::Logo => {
|
||||
self.boot as u32
|
||||
@@ -110,6 +110,12 @@ impl AuraPowerState {
|
||||
| (self.sleep as u32) << 4
|
||||
| (self.shutdown as u32) << 6
|
||||
}
|
||||
PowerZones::Ally => {
|
||||
(self.boot as u32)
|
||||
| (self.awake as u32) << 1
|
||||
| (self.sleep as u32) << 2
|
||||
| (self.shutdown as u32) << 3
|
||||
}
|
||||
PowerZones::Keyboard => {
|
||||
(self.boot as u32) << 1
|
||||
| (self.awake as u32) << 3
|
||||
@@ -187,7 +193,7 @@ impl LaptopAuraPower {
|
||||
// TODO: use support data to setup correct zones
|
||||
pub fn new(aura_type: AuraDeviceType, support_data: &LedSupportData) -> Self {
|
||||
match aura_type {
|
||||
AuraDeviceType::Unknown | AuraDeviceType::LaptopPost2021 => {
|
||||
AuraDeviceType::Unknown | AuraDeviceType::Ally | AuraDeviceType::LaptopPost2021 => {
|
||||
let mut states = Vec::new();
|
||||
for zone in support_data.power_zones.iter() {
|
||||
states.push(AuraPowerState::default_for(*zone))
|
||||
@@ -217,8 +223,13 @@ impl LaptopAuraPower {
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> {
|
||||
if let Some(stuff) = self.states.first() {
|
||||
if stuff.zone == PowerZones::Ally {
|
||||
return vec![0x5d, 0xd1, 0x09, 0x01, stuff.new_to_byte() as u8];
|
||||
}
|
||||
}
|
||||
match aura_type {
|
||||
AuraDeviceType::LaptopPost2021 => self.new_to_bytes(),
|
||||
AuraDeviceType::LaptopPost2021 | AuraDeviceType::Ally => self.new_to_bytes(),
|
||||
AuraDeviceType::LaptopPre2021 => {
|
||||
if self.states.len() == 1 {
|
||||
self.states
|
||||
|
||||
@@ -74,6 +74,7 @@ pub enum AuraDeviceType {
|
||||
LaptopPre2021 = 1,
|
||||
LaptopTuf = 2,
|
||||
ScsiExtDisk = 3,
|
||||
Ally = 4,
|
||||
Unknown = 255,
|
||||
}
|
||||
|
||||
@@ -90,6 +91,10 @@ impl AuraDeviceType {
|
||||
*self == Self::LaptopPost2021
|
||||
}
|
||||
|
||||
pub fn is_ally(&self) -> bool {
|
||||
*self == Self::Ally
|
||||
}
|
||||
|
||||
pub fn is_scsi(&self) -> bool {
|
||||
*self == Self::ScsiExtDisk
|
||||
}
|
||||
@@ -101,6 +106,7 @@ impl From<&str> for AuraDeviceType {
|
||||
"tuf" => AuraDeviceType::LaptopTuf,
|
||||
"1932" => AuraDeviceType::ScsiExtDisk,
|
||||
"1866" | "18c6" | "1869" | "1854" => Self::LaptopPre2021,
|
||||
"1abe" | "1b4c" => Self::Ally,
|
||||
_ => Self::LaptopPost2021,
|
||||
}
|
||||
}
|
||||
@@ -128,5 +134,7 @@ pub enum PowerZones {
|
||||
RearGlow = 4,
|
||||
/// Exists for the older 0x1866 models
|
||||
KeyboardAndLightbar = 5,
|
||||
/// Ally specific for creating correct packet
|
||||
Ally = 6,
|
||||
None = 255,
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ x11 = ["slint/backend-winit-x11"]
|
||||
tokio-debug = ["console-subscriber"]
|
||||
|
||||
[dependencies]
|
||||
console-subscriber = { version = "0.2.0", optional = true }
|
||||
console-subscriber = { version = "^0.4", optional = true }
|
||||
|
||||
nix = { version = "^0.28.0", features = ["fs"] }
|
||||
nix = { version = "^0.29.0", features = ["fs"] }
|
||||
tempfile = "3.3.0"
|
||||
betrayer = { version = "0.2.0" }
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ impl From<PowerZones> for SlintPowerZones {
|
||||
PowerZones::Lid => SlintPowerZones::Lid,
|
||||
PowerZones::RearGlow => SlintPowerZones::RearGlow,
|
||||
PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar,
|
||||
PowerZones::Ally => SlintPowerZones::Ally,
|
||||
PowerZones::None => SlintPowerZones::Keyboard,
|
||||
}
|
||||
}
|
||||
@@ -79,6 +80,7 @@ impl From<SlintPowerZones> for PowerZones {
|
||||
SlintPowerZones::Lid => PowerZones::Lid,
|
||||
SlintPowerZones::RearGlow => PowerZones::RearGlow,
|
||||
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
|
||||
SlintPowerZones::Ally => PowerZones::Ally,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,6 +153,7 @@ impl From<SlintDeviceType> for AuraDeviceType {
|
||||
SlintDeviceType::Tuf => Self::LaptopTuf,
|
||||
SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk,
|
||||
SlintDeviceType::Unknown => Self::Unknown,
|
||||
SlintDeviceType::Ally => Self::Ally,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,6 +166,7 @@ impl From<AuraDeviceType> for SlintDeviceType {
|
||||
AuraDeviceType::LaptopTuf => SlintDeviceType::Tuf,
|
||||
AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
|
||||
AuraDeviceType::Unknown => SlintDeviceType::Unknown,
|
||||
AuraDeviceType::Ally => SlintDeviceType::Ally,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-08-26 05:52+0000\n"
|
||||
"POT-Creation-Date: 2024-08-26 07:16+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"
|
||||
|
||||
@@ -4,6 +4,7 @@ export enum AuraDevType {
|
||||
Tuf,
|
||||
ScsiExtDisk,
|
||||
Unknown,
|
||||
Ally,
|
||||
}
|
||||
|
||||
export struct AuraEffect {
|
||||
@@ -28,6 +29,7 @@ export enum PowerZones {
|
||||
Lid,
|
||||
RearGlow,
|
||||
KeyboardAndLightbar,
|
||||
Ally,
|
||||
}
|
||||
|
||||
export struct AuraPowerState {
|
||||
@@ -52,6 +54,7 @@ export global AuraPageData {
|
||||
@tr("Aura power zone" => "Lid"),
|
||||
@tr("Aura power zone" => "Rear Glow"),
|
||||
@tr("Aura power zone" => "Keyboard and Lightbar"),
|
||||
@tr("Aura power zone" => "Ally"),
|
||||
];
|
||||
// Exists only for the older 0x1866 keybaords. On page setup it must
|
||||
// be set to match the supported_power_zones
|
||||
|
||||
@@ -43,23 +43,17 @@ impl KeyboardBacklight {
|
||||
PlatformError::Udev("match_subsystem failed".into(), err)
|
||||
})?;
|
||||
|
||||
enumerator
|
||||
.match_sysname("asus::kbd_backlight")
|
||||
.map_err(|err| {
|
||||
warn!("{}", err);
|
||||
PlatformError::Udev("match_subsystem failed".into(), err)
|
||||
})?;
|
||||
|
||||
if let Some(device) = (enumerator.scan_devices().map_err(|err| {
|
||||
for device in enumerator.scan_devices().map_err(|err| {
|
||||
warn!("{}", err);
|
||||
PlatformError::Udev("scan_devices failed".into(), err)
|
||||
})?)
|
||||
.next()
|
||||
{
|
||||
info!("Found keyboard LED controls at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
});
|
||||
})? {
|
||||
let sys = device.sysname().to_string_lossy();
|
||||
if sys.contains("kbd_backlight") || sys.contains("ally:rgb:gamepad") {
|
||||
info!("Found keyboard LED controls at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
});
|
||||
}
|
||||
}
|
||||
Err(PlatformError::MissingFunction(
|
||||
"KeyboardLed:new(), asus::kbd_backlight not found".into(),
|
||||
|
||||
@@ -19,6 +19,6 @@ uhid-virt = "^0.0.7"
|
||||
rog_anime = { path = "../rog-anime", features = ["dbus"] }
|
||||
|
||||
[dependencies.sdl2]
|
||||
version = "0.36"
|
||||
version = "0.37"
|
||||
default-features = false
|
||||
# features = ["gfx"]
|
||||
|
||||
Reference in New Issue
Block a user