Skip to content

Commit

Permalink
convert to use rusb instead of libusb
Browse files Browse the repository at this point in the history
libusb has been unmaintained for a while now:
dcuddeback/libusb-rs#49 (and last commit
from 8 years ago)

Convert to rusb, so we get updates in crates.
  • Loading branch information
bentiss authored and whot committed Jun 23, 2024
1 parent b2dd920 commit a72095f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
54 changes: 26 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ description = "Utility to switch Huion tablets into tablet mode"

[dependencies]
anyhow = "1.0.86"
libusb = "0.3.0"
rusb = "0.9.4"
udev = "0.8.0"
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use anyhow::{Context, Result};
use libusb;
use rusb;
use rusb::UsbContext;
use std::path::{Path, PathBuf};

fn send_usb_request(device: &libusb::Device) -> Result<()> {
fn send_usb_request(device: &rusb::Device<rusb::Context>) -> Result<()> {
let timeout = std::time::Duration::from_millis(100);
let handle = device.open()?;
// See the uclogic driver
Expand Down Expand Up @@ -38,7 +39,7 @@ fn send_usb_request(device: &libusb::Device) -> Result<()> {
}

fn send_usb_to_all() -> Result<()> {
let ctx = libusb::Context::new().unwrap();
let ctx = rusb::Context::new().unwrap();

const HUION_VENDOR_ID: u16 = 0x256C;

Expand Down Expand Up @@ -79,7 +80,7 @@ fn send_usb_to_device(path: &Path) -> Result<()> {
let bus = str::parse(&busnum.to_string_lossy())?;
let addr = str::parse(&devnum.to_string_lossy())?;

let ctx = libusb::Context::new().unwrap();
let ctx = rusb::Context::new().unwrap();
let rc = ctx
.devices()
.unwrap()
Expand Down

0 comments on commit a72095f

Please sign in to comment.