Skip to content

Commit

Permalink
Fixed made native get_device() properly grab the first one
Browse files Browse the repository at this point in the history
  • Loading branch information
G2-Games committed Feb 18, 2024
1 parent 1b8df6a commit 538103c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ rustflags = ["--cfg=web_sys_unstable_apis"]

[build]
#just comment in the "current" target
#target = "x86_64-unknown-linux-gnu"
target = "wasm32-unknown-unknown"
target = "x86_64-unknown-linux-gnu"
#target = "wasm32-unknown-unknown"
3 changes: 2 additions & 1 deletion src/backend/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ pub async fn get_device(device_filter: Vec<DeviceFilter>) -> Result<UsbDevice, U
result
})
{
device_info = Some(prelim_dev_inf)
device_info = Some(prelim_dev_inf);
break
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Cross USB is a USB library which works seamlessly across native and WASM targets.
//!
//! The idea is the user only has to write one way to access USB devices, which can be compiled
//! to both WASM and native targets without any conditional compilation or configuration.
//! to both WASM and native targets without any additional conditional compilation or configuration.
//!
//! For native device support, this library uses [nusb](https://docs.rs/nusb/latest/nusb/), a cross platform USB library written in Rust
//! and comparable to the very popular `libusb` C library. Web Assembly support is provided by [web-sys](https://docs.rs/web-sys/latest/web_sys/)
//! with the [Web USB API](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API)
//! with the [Web USB API](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API).
//!
//! When a [UsbInterface] is dropped, it is automatically released.
//!
Expand Down Expand Up @@ -83,7 +83,7 @@ pub use crate::context::DeviceFilter;
#[doc(inline)]
pub use crate::context::get_device;

/// Macro to create a device filter easily from data.
/// Macro to create a device filter more easily.
///
/// The only valid keys are fields of the [DeviceFilter] struct.
/// You may use as many or as few of them as you need, the rest
Expand Down
2 changes: 1 addition & 1 deletion src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub trait Device {
async fn open_interface(&self, number: u8) -> Result<UsbInterface, UsbError>;

/// Reset the device, which causes it to no longer be usable. You must
/// request a new device with [crate::get_device] or [crate::get_device_filter]
/// request a new device with [crate::get_device]
async fn reset(&self) -> Result<(), UsbError>;

/// Remove the device from the paired devices list, causing it to no longer be usable. You must request to reconnect using [crate::get_device]
Expand Down

0 comments on commit 538103c

Please sign in to comment.