Support Rog Ally LED modes (basic)

This commit is contained in:
Luke D. Jones
2023-11-07 17:22:17 +13:00
parent fd37f41ef1
commit 0fd0aeff88
11 changed files with 58 additions and 24 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support for G733PZ LED modes
- Support for G713RC LED modes
- Support Rog Ally LED modes (basic)
### Changed
- Fix loading of fan curves from stored settings

View File

@@ -45,7 +45,7 @@ notify-rust = { git = "https://github.com/flukejones/notify-rust.git", default-f
[profile.release]
# thin = 57s, asusd = 9.0M
# fat = 72s, asusd = 6.4M
lto = "fat"
#lto = "fat"
debug = false
opt-level = 3
panic = "abort"

View File

@@ -134,6 +134,8 @@ introspect:
build:
ifeq ($(VENDORED),1)
cargo vendor-filterer --platform x86_64-unknown-linux-gnu vendor
#cargo vendor
@echo "version = $(VERSION)"
tar pxf vendor_asusctl_$(VERSION).tar.xz
endif

View File

@@ -131,17 +131,13 @@ fn do_parsed(
if let Some(cmdlist) = CliStart::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| {
if !matches!(
supported.keyboard_led.dev_id,
AuraDevice::X1854
| AuraDevice::X1869
| AuraDevice::X1866
| AuraDevice::Tuf
) && command.trim().starts_with("led-pow-1")
if !supported.keyboard_led.dev_id.is_old_style()
&& !supported.keyboard_led.dev_id.is_tuf_style()
&& command.trim().starts_with("led-pow-1")
{
return false;
}
if supported.keyboard_led.dev_id != AuraDevice::X19b6
if !supported.keyboard_led.dev_id.is_new_style()
&& command.trim().starts_with("led-pow-2")
{
return false;
@@ -584,7 +580,7 @@ fn handle_led_power2(
return Ok(());
}
if supported.dev_id != AuraDevice::X19b6 {
if !supported.dev_id.is_new_style() {
println!("This option applies only to keyboards with product ID 0x19b6");
}

View File

@@ -143,9 +143,9 @@ impl StdConfigLoad for AuraConfig {}
impl AuraConfig {
pub fn from_default_support(prod_id: AuraDevice, support_data: &LaptopLedData) -> Self {
// create a default config here
let enabled = if prod_id == AuraDevice::X19b6 {
let enabled = if prod_id.is_new_style() {
AuraPowerConfig::AuraDevRog2(AuraPower::new_all_on())
} else if prod_id == AuraDevice::Tuf {
} else if prod_id.is_tuf_style() {
AuraPowerConfig::AuraDevTuf(HashSet::from([
AuraDevTuf::Awake,
AuraDevTuf::Boot,

View File

@@ -679,4 +679,12 @@
advanced_type: None,
power_zones: [Keyboard],
),
(
board_name: "RC71L",
layout_name: "ga401q",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
)
])

View File

@@ -8,7 +8,7 @@ use crate::{AdvancedAuraType, 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";
pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 7] = [
pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 8] = [
AuraDevice::Tuf,
AuraDevice::X1854,
AuraDevice::X1869,
@@ -16,6 +16,7 @@ pub const ASUS_KEYBOARD_DEVICES: [AuraDevice; 7] = [
AuraDevice::X18c6,
AuraDevice::X19b6,
AuraDevice::X1a30,
AuraDevice::X1abe,
];
#[derive(Debug, Default, Clone, PartialEq, Eq, Deserialize, Serialize)]

View File

@@ -37,9 +37,35 @@ pub enum AuraDevice {
#[default]
X19b6,
X1a30,
X1abe,
Unknown,
}
impl AuraDevice {
pub fn is_tuf_style(&self) -> bool {
matches!(self, AuraDevice::Tuf)
}
pub fn is_old_style(&self) -> bool {
!matches!(
self,
AuraDevice::Unknown
| AuraDevice::Tuf
| AuraDevice::X19b6
| AuraDevice::X18c6
| AuraDevice::X1a30
| AuraDevice::X1abe
)
}
pub fn is_new_style(&self) -> bool {
matches!(
self,
AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 | AuraDevice::X1abe
)
}
}
impl From<AuraDevice> for &str {
fn from(a: AuraDevice) -> Self {
match a {
@@ -50,6 +76,7 @@ impl From<AuraDevice> for &str {
AuraDevice::X18c6 => "18c6",
AuraDevice::X19b6 => "19b6",
AuraDevice::X1a30 => "1a30",
AuraDevice::X1abe => "1abe",
AuraDevice::Unknown => "unknown",
}
}
@@ -65,6 +92,7 @@ impl From<&str> for AuraDevice {
"1854" | "0x1854" => AuraDevice::X1854,
"19b6" | "0x19b6" => AuraDevice::X19b6,
"1a30" | "0x1a30" => AuraDevice::X1a30,
"1abe" | "0x1abe" => AuraDevice::X1abe,
_ => AuraDevice::Unknown,
}
}
@@ -80,6 +108,7 @@ impl Debug for AuraDevice {
Self::X18c6 => write!(f, "0x18c6"),
Self::X19b6 => write!(f, "0x19B6"),
Self::X1a30 => write!(f, "0x1A30"),
Self::X1abe => write!(f, "0x1ABE"),
Self::Unknown => write!(f, "Unknown"),
}
}

View File

@@ -100,7 +100,7 @@ pub fn get_ipc_file() -> Result<File, crate::error::Error> {
let fifo_path = tmp_dir.join("ipc.pipe");
if let Err(e) = unistd::mkfifo(&fifo_path, stat::Mode::S_IRWXU) {
if !matches!(e, nix::errno::Errno::EEXIST) {
return Err(e)?;
Err(e)?
}
}
Ok(OpenOptions::new()

View File

@@ -8,15 +8,11 @@ use crate::system_state::SystemState;
pub fn aura_power_group(supported: &SupportedFunctions, states: &mut SystemState, ui: &mut Ui) {
ui.heading("Keyboard LED power settings");
match supported.keyboard_led.dev_id {
AuraDevice::X1854 | AuraDevice::X1869 | AuraDevice::X1866 => {
aura_power1(supported, states, ui);
}
AuraDevice::X19b6 | AuraDevice::X18c6 | AuraDevice::X1a30 => {
aura_power2(supported, states, ui)
}
AuraDevice::Tuf => aura_power1(supported, states, ui),
AuraDevice::Unknown => {}
if supported.keyboard_led.dev_id.is_old_style() || supported.keyboard_led.dev_id.is_tuf_style()
{
aura_power1(supported, states, ui);
} else if supported.keyboard_led.dev_id.is_new_style() {
aura_power2(supported, states, ui);
}
}

View File

@@ -75,6 +75,7 @@ pub fn read_attr_u8_array(device: &Device, attr_name: &str) -> Result<Vec<u8>> {
}
pub fn write_attr_u8_array(device: &mut Device, attr: &str, values: &[u8]) -> Result<()> {
#[allow(clippy::format_collect)]
let tmp: String = values.iter().map(|v| format!("{} ", v)).collect();
let tmp = tmp.trim();
device
@@ -102,7 +103,7 @@ mod tests {
#[test]
fn check() {
let data = [1, 2, 3, 4, 5];
#[allow(clippy::format_collect)]
let tmp: String = data.iter().map(|v| format!("{} ", v)).collect();
let tmp = tmp.trim();
assert_eq!(tmp, "1 2 3 4 5");