Merge branch 'migrate-to-rusb' into 'main'

Migrate to rusb Crate

See merge request gabmus/envision!46
This commit is contained in:
GabMus 2024-06-14 04:54:06 +00:00
commit bafcb649ce
3 changed files with 19 additions and 32 deletions

46
Cargo.lock generated
View file

@ -88,21 +88,6 @@ dependencies = [
"which", "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]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -292,13 +277,13 @@ dependencies = [
"lazy_static", "lazy_static",
"libadwaita", "libadwaita",
"libmonado-rs", "libmonado-rs",
"libusb",
"nix", "nix",
"phf", "phf",
"phf_macros", "phf_macros",
"relm4", "relm4",
"relm4-components", "relm4-components",
"reqwest", "reqwest",
"rusb",
"serde", "serde",
"serde_json", "serde_json",
"tracker", "tracker",
@ -1108,24 +1093,15 @@ dependencies = [
] ]
[[package]] [[package]]
name = "libusb" name = "libusb1-sys"
version = "0.3.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f990ddd929cbe53de4ecd6cf26e1f4e0c5b9796e4c629d9046570b03738aa53" checksum = "da050ade7ac4ff1ba5379af847a10a10a8e284181e060105bf8d86960ce9ce0f"
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"
dependencies = [ dependencies = [
"cc",
"libc", "libc",
"pkg-config", "pkg-config",
"vcpkg",
] ]
[[package]] [[package]]
@ -1686,6 +1662,16 @@ dependencies = [
"winreg", "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]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"

View file

@ -19,7 +19,7 @@ libadwaita = { version = "0.6.0", features = [
"v1_4" "v1_4"
] } ] }
libmonado-rs = { git = "https://github.com/technobaboo/libmonado-rs", version = "0.1.0" } 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 = [ nix = { version = "0.29.0", features = [
"fs", "fs",
"signal" "signal"

View file

@ -2,6 +2,7 @@ use crate::{
profile::Profile, profile::Profile,
profiles::{lighthouse::lighthouse_profile, wivrn::wivrn_profile, wmr::wmr_profile}, profiles::{lighthouse::lighthouse_profile, wivrn::wivrn_profile, wmr::wmr_profile},
}; };
use rusb::UsbContext;
use std::fmt::Display; use std::fmt::Display;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
@ -137,7 +138,7 @@ impl PhysicalXRDevice {
* Returns a Vec of tuples, each representing (vendor_id, product_id) * Returns a Vec of tuples, each representing (vendor_id, product_id)
*/ */
fn list_usb_devs() -> Vec<(u16, u16)> { 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 let devs = ctx
.devices() .devices()
.expect("Failed to list devices from libusb context"); .expect("Failed to list devices from libusb context");