-
-
Notifications
You must be signed in to change notification settings - Fork 116
darwin: add option to open device in non-exclusive mode #194
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
base: master
Are you sure you want to change the base?
Conversation
what about putting platform specific functions into a platform specific submodule? |
I think we should just do this change on all platforms not only on macos
and cython will take care of it correctly = include functions if they can be resolved and not if they cannot. I am going to push another commit into the PR branch to test the hypothesis |
Hm, ok, that didn't work :-) let's get back to the drawing board |
AFAIK cython does not resolve symbols but only creates c code. so if a function is used in cython code, the linker expects it to be present somewhere which is not the case for platform specific functions in libusb as it does not provide stubs for it. I think the cleanest solution is to add a darwin subpackage. this could also be done for other platform specific functions. |
I agree this is the cleanest solution, but not sure if it is also a preferred one. ChatGPT says we can use this trick: in the
in the
@vulpes2 will you update your PR to try this trick? |
Conditional compilation is deprecated and should not be used (as @vulpes2 mentioned in #194 (comment)): https://docs.cython.org/en/latest/src/userguide/migrating_to_cy30.html#deprecated-def-if |
Right. If @vulpes2 wants to create a new model - please do so. And see how complex the change is. |
Not sure if it's possible to split these into a platform-specific subpackage, will investigate in that approach. |
This has turned out to be incredibly complicated due to my lack of experience in python packaging, spent a few hours trying and couldn't figure it out. Here are some main issues that I ran into and couldn't resolve, maybe someone with more python packaging experience can provide some pointers.
|
After a bit of time I finally figured this out. The documentation was terrible so it's not so obvious at first glance. Will push my changes in a bit. |
This is ready for review now, I've tested this on macOS and linux. The Darwin-specific functions are not defined when it's built on linux, and setting exclusive access to 0 on macOS will make it possible to open HID stuff that are being used by the system now. @prusnak |
|
I think I've hacked a possible solution without |
here a first version master...bearsh:cython-hidapi:platform-subclasses |
Need some help on getting the conditional include to work, this obviously will not compile on non-darwin platforms.
int hid_darwin_get_open_exclusive()
on all platforms in python.Fixes #178