Open Chrissie-AI opened 2 years ago
I don't have any issue with exclusive access in principle but I'm not sure it's possible to implement it consistently across all platforms and devices.
There's an open issue on the signal11/hidapi repo requesting this feature:
Option to open hid device with exclusive access #302
The implementation in Chrome doesn't use hidapi but we would want similar results. I think currently you can't use hidapi to request exclusive access on Windows due to limitations at the platform level.
Windows makes certain HID interfaces exclusive or shared based on the collection usage:
Matt, thanks for this speedy comment.
Obviously, I'd prefer consistent results across platforms, stationary or mobile, and across OSses also.
I'm constrained to using Chrome (for which I'm grateful), because not many Browsers do implement the webhid API. On a related note, the hid input controller I'm using (SpaceNavigator) is not easily available on a mobile device, so that's secondary on my priority list.
I'm in the same boat with a 6DOF device (same vendor) where it is really important to be able obtain exclusive use of the device to prevent the HID layer from treating 3 of the axes as mouse input. In most cases, users with a 6DOF device have a mouse for typical mouse things and a space mouse for 3D nav and object manipulation. This is currently not possible with WebHID.
I recommend changing the open()
method signature to open(options = {})
where exclusive:boolean
is an option. If exclusivity is requested and not supported or denied by the OS, it can throw an error.
I have a 6DOF input device (SpaceNavigator) which I'm using in a Three.js application for camera control. Connecting to, opening and processing of reportIds in the eventHandler of my application work as expected. Thanks for making the webhid API available available!
BUT ...
... apparently some other (default?) eventHandler also gets fired prior to mine. I was not able to suppress this via
so the default event handling seems be happening before any of my code gets executed.
In my particular use case, the SpaceNavigator's puck actions which control Rx, Ry, Rz rotations seem to be mapped to the 2D mouse's X- and Y-movements and the scroll wheel. So these default actions interfere with my intended camera control for as long as the 2D mouse cursor is within my application window. If the 2D mouse cursor is in another window, that window reacts to the default event processing of the events fired by my SpaceNavigator, while my application window at the same time gets the "clean" and intended reactions only.
What I'd like to see is getting exclusive access to an HID device's events, maybe via a parameter in the device.open() call. Any chance to get this added to the API?