gary-rowe / hid4java

A cross-platform Java Native Access (JNA) wrapper for the libusb/hidapi library. Works out of the box on Windows/Mac/Linux.
MIT License
223 stars 70 forks source link

Option to open device in non-exclusive mode #131

Closed DaPutzy closed 1 year ago

DaPutzy commented 1 year ago

I use this library to read metrics (battery level, etc.) from my wireless headset (HyperX Cloud Flight) on macOS (12.6) using this build. However while reading data i can no longer control the volume via headset since the library uses the device exclusively.

As far as i understand from this issue there is a way to use a device non exclusively under macOS, so that I could read data and still get system volume events. This would be a great addition to this library!

DaPutzy commented 1 year ago

I just hacked this together locally and it works great! I used my local libhidapi.0.12.0.dylib

which contains:

00000000000034ec T _hid_close
0000000000003650 T _hid_darwin_get_location_id
00000000000036f0 T _hid_darwin_get_open_exclusive
0000000000003704 T _hid_darwin_is_device_open_exclusive
0000000000002818 T _hid_darwin_set_open_exclusive
0000000000002868 T _hid_enumerate
0000000000003720 T _hid_error
000000000000282c T _hid_exit
0000000000002be8 T _hid_free_enumeration
000000000000345c T _hid_get_feature_report
0000000000003648 T _hid_get_indexed_string
00000000000034dc T _hid_get_input_report
0000000000003600 T _hid_get_manufacturer_string
0000000000003618 T _hid_get_product_string
0000000000003630 T _hid_get_serial_number_string
0000000000002774 T _hid_init
0000000000002c3c T _hid_open
0000000000002cd8 T _hid_open_path
0000000000003428 T _hid_read
0000000000003248 T _hid_read_timeout
000000000000344c T _hid_send_feature_report
0000000000003438 T _hid_set_nonblocking
000000000000275c T _hid_version
0000000000002768 T _hid_version_str
00000000000031d4 T _hid_write