WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
140 stars 35 forks source link

Exclusion #40

Open JamesB7 opened 3 years ago

JamesB7 commented 3 years ago

Hello,

I'm the creator of the HIDSharp library for C# USB HID communications. I use this library in a product I'm contracted to create, Evolv's EScribe Suite.

Since Windows does not provide any form of exclusion for USB HID devices, I do it manually using global mutexes, with handoffs, etc. This allows different aspects of the (multiprocess) product to coordinate and not conflict as far as USB HID communications go. (This also works on Mac and Linux.) Of course, this problem does not exist with WebUSB, since USB access is not shared.

Is there any equivalent for Chrome? I could easily extend my HIDSharp library to support however Chrome may implement this (Windows mutexes, or whatnot), and update our desktop applications. Our ECigStats software downloads statistics upon connect, and my web implementation does the same, so if both are present, it does not work too well. We have other pieces of software that also need exclusion.

Does Chrome provide anything of this sort, named mutexes or whatnot (prefixed by the origin or something would be fine)? It need not be specific to WebHID, I just haven't found anything at all of this kind.

Thank you!

James

inexorabletash commented 3 years ago

Would https://wicg.github.io/web-locks/ be a fit here? They're origin-scoped named mutexes, supported in Chrome for the last several years.

JamesB7 commented 3 years ago

Hmm... If the locks can be manipulated from desktop software, I could update said software to also take and check the web lock. That's the real question, I suppose, whether said locks are backed predictably by an OS resource of some kind.

inexorabletash commented 3 years ago

The locks are internal to the browser. Sorry, I misinterpreted your use case.

JamesB7 commented 3 years ago

That's too bad. Between web instances it would work well actually. Problem is we have both desktop and web software, and HID doesn't have any OS-level exclusion. Hmm. I'll see if I can come up with any alternate approach. Thanks for the idea though :)