mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Narrow the search space of aura devices down
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::{BTreeMap, HashSet};
|
||||||
|
|
||||||
use config_traits::{StdConfig, StdConfigLoad};
|
use config_traits::{StdConfig, StdConfigLoad};
|
||||||
use inotify::Inotify;
|
use inotify::Inotify;
|
||||||
@@ -62,6 +62,7 @@ impl CtrlKbdLed {
|
|||||||
pub fn find_all(data: &LaptopLedData) -> Result<Vec<Self>, RogError> {
|
pub fn find_all(data: &LaptopLedData) -> Result<Vec<Self>, RogError> {
|
||||||
info!("Searching for all Aura devices");
|
info!("Searching for all Aura devices");
|
||||||
let mut devices = Vec::new();
|
let mut devices = Vec::new();
|
||||||
|
let mut found = HashSet::new();
|
||||||
|
|
||||||
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
||||||
warn!("{}", err);
|
warn!("{}", err);
|
||||||
@@ -74,18 +75,32 @@ impl CtrlKbdLed {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
for end_point in enumerator.scan_devices()? {
|
for end_point in enumerator.scan_devices()? {
|
||||||
|
// usb_device gives us a product and vendor ID
|
||||||
if let Some(usb_device) =
|
if let Some(usb_device) =
|
||||||
end_point.parent_with_subsystem_devtype("usb", "usb_device")?
|
end_point.parent_with_subsystem_devtype("usb", "usb_device")?
|
||||||
{
|
{
|
||||||
// Device is something like 002, while its parent is the MCU
|
// The asus_wmi driver latches MCU that controls the USB endpoints
|
||||||
// Think of it like the device is an endpoint of the USB device attached
|
if let Some(parent) = end_point.parent() {
|
||||||
if let Some(parent_id) = usb_device.attribute_value("idProduct") {
|
if let Some(driver) = parent.driver() {
|
||||||
let prod_id = AuraDevice::from(parent_id.to_str().unwrap());
|
// There is a tree of devices added so filter by driver
|
||||||
if prod_id == AuraDevice::Unknown {
|
if driver != "asus" {
|
||||||
log::debug!("Unknown or invalid device: {parent_id:?}, skipping");
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
continue;
|
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() {
|
let dev_node = if let Some(dev_node) = usb_device.devnode() {
|
||||||
dev_node
|
dev_node
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user