From b4b1b38f063ab60ab80b4aa6006efab8f15575be Mon Sep 17 00:00:00 2001 From: Jonathan Steffan <3294812-damaestro@users.noreply.gitlab.com> Date: Fri, 14 Jun 2024 04:54:06 +0000 Subject: [PATCH] Migrate to rusb Crate --- Cargo.lock | 46 +++++++++++++++----------------------------- Cargo.toml | 2 +- src/device_prober.rs | 3 ++- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f34e22f..432fad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,21 +88,6 @@ dependencies = [ "which", ] -[[package]] -name = "bit-set" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e1e6fb1c9e3d6fcdec57216a74eaa03e41f52a22f13a16438251d8e88b89da" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bitflags" version = "1.3.2" @@ -292,13 +277,13 @@ dependencies = [ "lazy_static", "libadwaita", "libmonado-rs", - "libusb", "nix", "phf", "phf_macros", "relm4", "relm4-components", "reqwest", + "rusb", "serde", "serde_json", "tracker", @@ -1108,24 +1093,15 @@ dependencies = [ ] [[package]] -name = "libusb" -version = "0.3.0" +name = "libusb1-sys" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f990ddd929cbe53de4ecd6cf26e1f4e0c5b9796e4c629d9046570b03738aa53" -dependencies = [ - "bit-set", - "libc", - "libusb-sys", -] - -[[package]] -name = "libusb-sys" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c53b6582563d64ad3e692f54ef95239c3ea8069e82c9eb70ca948869a7ad767" +checksum = "da050ade7ac4ff1ba5379af847a10a10a8e284181e060105bf8d86960ce9ce0f" dependencies = [ + "cc", "libc", "pkg-config", + "vcpkg", ] [[package]] @@ -1686,6 +1662,16 @@ dependencies = [ "winreg", ] +[[package]] +name = "rusb" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab9f9ff05b63a786553a4c02943b74b34a988448671001e9a27e2f0565cc05a4" +dependencies = [ + "libc", + "libusb1-sys", +] + [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index 3cc9750..fd82872 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ libadwaita = { version = "0.6.0", features = [ "v1_4" ] } libmonado-rs = { git = "https://github.com/technobaboo/libmonado-rs", version = "0.1.0" } -libusb = "0.3.0" +rusb = "0.9.4" nix = { version = "0.29.0", features = [ "fs", "signal" diff --git a/src/device_prober.rs b/src/device_prober.rs index 2449f03..e44aa9c 100644 --- a/src/device_prober.rs +++ b/src/device_prober.rs @@ -2,6 +2,7 @@ use crate::{ profile::Profile, profiles::{lighthouse::lighthouse_profile, wivrn::wivrn_profile, wmr::wmr_profile}, }; +use rusb::UsbContext; use std::fmt::Display; #[derive(Debug, PartialEq, Eq)] @@ -137,7 +138,7 @@ impl PhysicalXRDevice { * Returns a Vec of tuples, each representing (vendor_id, product_id) */ fn list_usb_devs() -> Vec<(u16, u16)> { - let ctx = libusb::Context::new().expect("Failed to create libusb context"); + let ctx = rusb::Context::new().expect("Failed to create libusb context"); let devs = ctx .devices() .expect("Failed to list devices from libusb context");