darwin: add option to open device in non-exclusive mode #397
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!397
Loading…
Reference in a new issue
No description provided.
Delete branch "macos-non-exclusive"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves: #27
Resolves: #344
@dnaq try if this works for you.
That looks like it would work beautifully for my use case.
I thought that hidapi idea is to provide generic crossplatform API if possible.
We can add such option for Windows too (do not pass
FILE_SHARE_READandFILE_SHARE_WRITEto CreateFile). Maybe its better to do not-os-specifichid_open_pathinstead?I already had this conversation somewhere (but I can't find it, so here it goes again):
Having a "cross-platform" function that is known only to work for some platforms defeats the whole "cross-platform" idea.
Pretty much the same thing we can tell about similar option: ReadWrite or ReadOnly Open: supported by Windows and HIDRAW, but not supported by macOS and LIBUSB. More than that - on Window you can open a device without specifying ReadWrite or ReadOnly, and on HIDRAW you have to specify one of them.
There is also a question of consistency, e.g.: "shouldn't a cross-platform application behave consistently across platforms?".
I.e. since we open on Windows in shared mode, why don't we open in Non-Exclusive mode on macOS by default?
I already asked myself this question here.
In addition to that: on LIBUSB we open with exclusive access (and there is no option to do otherwise), so current behavior on macOS is consistent with LIBUSB.
Given all of the above, my strategy is: