Shift init actions up a few calls to prevent over-eager init

This commit is contained in:
Luke D. Jones
2024-03-23 23:27:26 +13:00
parent 4b34ab83fb
commit 637360095c
7 changed files with 43 additions and 51 deletions

View File

@@ -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,

View File

@@ -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");

View File

@@ -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");

View File

@@ -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(),
});
}
}
}