mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Shift init actions up a few calls to prevent over-eager init
This commit is contained in:
@@ -24,7 +24,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
return Err("RogError::NoAuraKeyboard".into());
|
||||
}
|
||||
|
||||
let node = usb_node.unwrap().0;
|
||||
let node = usb_node.unwrap();
|
||||
|
||||
let mut packet: [u8; 64] = [
|
||||
0x5a, 0xd1, 0x0d, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
@@ -26,7 +26,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
return Err("RogError::NoAuraKeyboard".into());
|
||||
}
|
||||
|
||||
let node = usb_node.unwrap().0;
|
||||
let node = usb_node.unwrap();
|
||||
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
return Err("RogError::NoAuraKeyboard".into());
|
||||
}
|
||||
|
||||
let node = usb_node.unwrap().0;
|
||||
let node = usb_node.unwrap();
|
||||
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
|
||||
@@ -22,7 +22,7 @@ pub struct HidRaw {
|
||||
}
|
||||
|
||||
impl HidRaw {
|
||||
pub fn new(id_product: &str) -> Result<(Self, Device)> {
|
||||
pub fn new(id_product: &str) -> Result<Self> {
|
||||
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
||||
warn!("{}", err);
|
||||
PlatformError::Udev("enumerator failed".into(), err)
|
||||
@@ -47,17 +47,12 @@ impl HidRaw {
|
||||
if parent_id == id_product {
|
||||
if let Some(dev_node) = endpoint.devnode() {
|
||||
info!("Using device at: {:?} for hidraw control", dev_node);
|
||||
return Ok((
|
||||
Self {
|
||||
file: RefCell::new(
|
||||
OpenOptions::new().write(true).open(dev_node)?,
|
||||
),
|
||||
devfs_path: dev_node.to_owned(),
|
||||
prod_id: id_product.to_string(),
|
||||
syspath: endpoint.syspath().into(),
|
||||
},
|
||||
usb_device,
|
||||
));
|
||||
return Ok(Self {
|
||||
file: RefCell::new(OpenOptions::new().write(true).open(dev_node)?),
|
||||
devfs_path: dev_node.to_owned(),
|
||||
prod_id: id_product.to_string(),
|
||||
syspath: endpoint.syspath().into(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,15 +65,12 @@ impl HidRaw {
|
||||
"Using device at: {:?} for <TODO: label control> control",
|
||||
dev_node
|
||||
);
|
||||
return Ok((
|
||||
Self {
|
||||
file: RefCell::new(OpenOptions::new().write(true).open(dev_node)?),
|
||||
devfs_path: dev_node.to_owned(),
|
||||
prod_id: id_product.to_string(),
|
||||
syspath: endpoint.syspath().into(),
|
||||
},
|
||||
endpoint,
|
||||
));
|
||||
return Ok(Self {
|
||||
file: RefCell::new(OpenOptions::new().write(true).open(dev_node)?),
|
||||
devfs_path: dev_node.to_owned(),
|
||||
prod_id: id_product.to_string(),
|
||||
syspath: endpoint.syspath().into(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user