Skip to content

Navigation Menu

Sign in
Sign up

Unable to open HID device in MacOS With Electron Universal macOS applications #489

Unanswered
lan08438 asked this question in Q&A
Discussion options

Mac OS X Version:12.4
Electron Version:13.6.7
Node.js Version :14.17.3
hidapi: Latest Version

I used the HidAPI function in V8 C++ to open the device for Node.js on the Electron platform, and I want to make hid_send_feature_report() to command the device,

first apply hid_enumerate with VID and PID to get the specified device
The receiver applies the path to the Function of hid_open_path(), but the result of Return Value is NULL (0),

After a further check for the Function of hid_open_path(), IOHIDDeviceOpen in the subroutine, the returned value is e00002e2, defined as kIOReturnNotPermitted

This only happens if Electron-Builder is packaged into an universal file, but if Electron is packaged separately into x86 (Intel) and arm64 (Apple) or if VSCode is used for debugging, the function of hid_open_path() can be successfully opened. ( The above app all have permission to open through Input Monitoring of macOS)

May I ask if I want to package it into one universal file, what can I do to be able to succesfully open it?

issues

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

This sounds like some Electron-specific behavior.
There is no difference in either a separate x64/arm64 build or a Universal build of HIDAPI is used.
Both work the same way as per all my tests.

What I assume is more likely, is that your Electron application creates some kind of a container or a sandbox which doesn't have the permission to use HID devices.
But that's only an assumption, I'm not familiar with the Electron to know exactly what's going on.

You must be logged in to vote
1 reply
Comment options

Understand, I will look for behavior from the direction of Electron application.

Comment options

There are some electron examples from the node-hid project and other places. You may want to give it a try.
https://github.com/node-hid/node-hid
https://github.com/todbot/electron-hid-test
https://github.com/todbot/electron-hid-toy
https://github.com/todbot/electron-blink1-toy

You must be logged in to vote
1 reply
Comment options

Wow, that seems like useful information, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /