mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Make laptop matching more generic using product_id instead of board_name
This commit is contained in:
@@ -28,7 +28,7 @@ impl LaptopGL753 {
|
|||||||
// from `cat /sys/class/dmi/id/board_name`
|
// from `cat /sys/class/dmi/id/board_name`
|
||||||
board_name: "LaptopGL753VE",
|
board_name: "LaptopGL753VE",
|
||||||
// from `cat /sys/class/dmi/id/product_family`
|
// from `cat /sys/class/dmi/id/product_family`
|
||||||
prod_family: "ROG Strix",
|
prod_family: "",
|
||||||
report_filter_bytes: [0x5a, 0x02],
|
report_filter_bytes: [0x5a, 0x02],
|
||||||
min_led_bright: 0x00,
|
min_led_bright: 0x00,
|
||||||
max_led_bright: 0x03,
|
max_led_bright: 0x03,
|
||||||
|
|||||||
@@ -13,24 +13,42 @@ mod gx502;
|
|||||||
use gx502::LaptopGX502;
|
use gx502::LaptopGX502;
|
||||||
|
|
||||||
pub(crate) fn match_laptop() -> Box<dyn Laptop> {
|
pub(crate) fn match_laptop() -> Box<dyn Laptop> {
|
||||||
let dmi = sysfs_class::DmiId::default();
|
for device in rusb::devices().unwrap().iter() {
|
||||||
let board_name = dmi.board_name().unwrap();
|
let device_desc = device.device_descriptor().unwrap();
|
||||||
match &board_name.as_str()[..5] {
|
if device_desc.vendor_id() == 0x0b05 {
|
||||||
// TODO: FX503VD - 0x1869,
|
match device_desc.product_id() {
|
||||||
// These two models seem to have the same characteristics
|
0x1866 => {
|
||||||
"GX502" | "GA502" => {
|
info!("Found GX502 or similar");
|
||||||
info!("Found GX502 or GA502 series");
|
return Box::new(LaptopGX502::new());
|
||||||
Box::new(LaptopGX502::new())
|
}
|
||||||
}
|
0x1854 => {
|
||||||
// LED should work for this, but unsure of keys
|
info!("Found GL753 or similar");
|
||||||
"GL753" => {
|
return Box::new(LaptopGL753::new());
|
||||||
info!("Found GL753 series");
|
}
|
||||||
Box::new(LaptopGL753::new())
|
_ => {}
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
panic!("could not match laptop");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
panic!("could not match laptop");
|
||||||
|
|
||||||
|
// let dmi = sysfs_class::DmiId::default();
|
||||||
|
// let board_name = dmi.board_name().unwrap();
|
||||||
|
// match &board_name.as_str()[..5] {
|
||||||
|
// // TODO: FX503VD - 0x1869,
|
||||||
|
// // These two models seem to have the same characteristics
|
||||||
|
// "GX502" | "GA502" | "GU502" => {
|
||||||
|
// info!("Found GX502 or GA502 series");
|
||||||
|
// Box::new(LaptopGX502::new())
|
||||||
|
// }
|
||||||
|
// // LED should work for this, but unsure of keys
|
||||||
|
// "GL753" => {
|
||||||
|
// info!("Found GL753 series");
|
||||||
|
// Box::new(LaptopGL753::new())
|
||||||
|
// }
|
||||||
|
// _ => {
|
||||||
|
// panic!("could not match laptop");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All laptop models should implement this trait. The role of a `Laptop` is to
|
/// All laptop models should implement this trait. The role of a `Laptop` is to
|
||||||
|
|||||||
Reference in New Issue
Block a user