ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
173 stars 82 forks source link

Implement MacOS and Windows APIs from `hidapi` 0.12 release #93

Closed KarlK90 closed 1 year ago

KarlK90 commented 1 year ago

This PR implements FFI bindings and safe implementations for the following APIs that where added in hidapi release 0.12

MacOS:

Windows:

The hid_darwin_set_open_exclusive() API is also put to use by introducing the macos-shared-device feature flag for MacOS so it is possible to have multiple HidDevice handles that access the same physical device.

A convenience addition is the implementation of Debug for HidDevice, this will only print HidDevice but allows wrapping types like HidResult<HidDevice> into a dbg! macro.

KarlK90 commented 1 year ago

I've added docs.rs specific metadata and documentation hints in the latest commit and also hid the cfg_libusb_only macro which should be internal(?). The result will look like this:

image

I find that much nicer, although there are now 2 distinct Impl HidApi blocks in the documentation...

KarlK90 commented 1 year ago

@ruabmbua thanks for the swift review, applied changes and added IMHO better platform specific documentation.

ruabmbua commented 1 year ago

Thanks for the contribution!