Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid taking an exclusive lock on Litra devices on macOS #93

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ impl fmt::Debug for Litra {
impl Litra {
/// Initialize a new Litra context.
pub fn new() -> DeviceResult<Self> {
Ok(HidApi::new().map(Litra)?)
let hidapi = HidApi::new()?;
#[cfg(target_os = "macos")]
hidapi.set_open_exclusive(false);
Ok(Litra(hidapi))
}

/// Returns an [`Iterator`] of connected devices supported by this library.
Expand Down Expand Up @@ -177,7 +180,7 @@ impl Device<'_> {
}

/// Opens the device and returns a [`DeviceHandle`] that can be used for getting and setting the
/// device status.
/// device status. On macOS, this will open the device in non-exclusive mode.
pub fn open(&self, context: &Litra) -> DeviceResult<DeviceHandle> {
let hid_device = self.device_info.open_device(context.hidapi())?;
Ok(DeviceHandle {
Expand Down
Loading