Skip to content

Commit

Permalink
default linux to hidraw, disable linux libusb usage() and usage_page()
Browse files Browse the repository at this point in the history
  • Loading branch information
ruabmbua committed Nov 19, 2022
1 parent ec34c4d commit bbb7f3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ links = "hidapi"
documentation = "https://docs.rs/hidapi"

[features]
default = ["linux-static-libusb", "illumos-static-libusb"]
default = ["linux-static-hidraw", "illumos-static-libusb"]
linux-static-libusb = []
linux-static-hidraw = []
linux-shared-libusb = []
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
//! - `illumos-shared-libusb`: uses statically linked `hidraw` backend on Illumos
//! - `macos-shared-device`: enables shared access to HID devices on MacOS
//!
//! ## Linux backends
//!
//! On linux the libusb backends do not support [`DeviceInfo::usage()`] and [`DeviceInfo::usage_page()`].
//! The hidraw backend supports has support for them, but it might be buggy in older kernel versions.
//!
//! ## MacOS Shared device access
//!
//! Since `hidapi` 0.12 it is possible to open MacOS devices with shared access, so that multiple
Expand Down Expand Up @@ -421,9 +426,11 @@ impl DeviceInfo {
pub fn path(&self) -> &CStr {
&self.path
}

pub fn vendor_id(&self) -> u16 {
self.vendor_id
}

pub fn product_id(&self) -> u16 {
self.product_id
}
Expand All @@ -435,6 +442,7 @@ impl DeviceInfo {
_ => None,
}
}

pub fn serial_number_raw(&self) -> Option<&[wchar_t]> {
match self.serial_number {
WcharString::Raw(ref s) => Some(s),
Expand All @@ -453,6 +461,7 @@ impl DeviceInfo {
_ => None,
}
}

pub fn manufacturer_string_raw(&self) -> Option<&[wchar_t]> {
match self.manufacturer_string {
WcharString::Raw(ref s) => Some(s),
Expand All @@ -467,19 +476,26 @@ impl DeviceInfo {
_ => None,
}
}

pub fn product_string_raw(&self) -> Option<&[wchar_t]> {
match self.product_string {
WcharString::Raw(ref s) => Some(s),
_ => None,
}
}

/// Usage page is not available on linux libusb backends
#[cfg(not(any(feature = "linux-static-libusb", feature = "linux-shared-libusb")))]
pub fn usage_page(&self) -> u16 {
self.usage_page
}

/// Usage is not available on linux libusb backends
#[cfg(not(any(feature = "linux-static-libusb", feature = "linux-shared-libusb")))]
pub fn usage(&self) -> u16 {
self.usage
}

pub fn interface_number(&self) -> i32 {
self.interface_number
}
Expand Down

0 comments on commit bbb7f3e

Please sign in to comment.