Narrow the search space of aura devices down

This commit is contained in:
Luke D. Jones
2024-03-23 14:30:00 +13:00
parent 4b38e5daa6
commit ac605cbc00
2 changed files with 23 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashSet};
use config_traits::{StdConfig, StdConfigLoad};
use inotify::Inotify;
@@ -62,6 +62,7 @@ impl CtrlKbdLed {
pub fn find_all(data: &LaptopLedData) -> Result<Vec<Self>, RogError> {
info!("Searching for all Aura devices");
let mut devices = Vec::new();
let mut found = HashSet::new();
let mut enumerator = udev::Enumerator::new().map_err(|err| {
warn!("{}", err);
@@ -74,18 +75,32 @@ impl CtrlKbdLed {
})?;
for end_point in enumerator.scan_devices()? {
// usb_device gives us a product and vendor ID
if let Some(usb_device) =
end_point.parent_with_subsystem_devtype("usb", "usb_device")?
{
// Device is something like 002, while its parent is the MCU
// Think of it like the device is an endpoint of the USB device attached
if let Some(parent_id) = usb_device.attribute_value("idProduct") {
let prod_id = AuraDevice::from(parent_id.to_str().unwrap());
if prod_id == AuraDevice::Unknown {
log::debug!("Unknown or invalid device: {parent_id:?}, skipping");
// The asus_wmi driver latches MCU that controls the USB endpoints
if let Some(parent) = end_point.parent() {
if let Some(driver) = parent.driver() {
// There is a tree of devices added so filter by driver
if driver != "asus" {
continue;
}
} else {
continue;
}
}
// Device is something like 002, while its parent is the MCU
// Think of it like the device is an endpoint of the USB device attached
if let Some(usb_id) = usb_device.attribute_value("idProduct") {
let prod_id = AuraDevice::from(usb_id.to_str().unwrap());
if prod_id == AuraDevice::Unknown || found.contains(&prod_id) {
log::debug!("Unknown or invalid device: {usb_id:?}, skipping");
continue;
}
found.insert(prod_id);
}
let dev_node = if let Some(dev_node) = usb_device.devnode() {
dev_node
} else {

View File

@@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-03-22 22:45+0000\n"
"POT-Creation-Date: 2024-03-23 01:29+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"