todbot / hidapitester

Simple command-line program to test HIDAPI
GNU General Public License v3.0
263 stars 31 forks source link

error handling for hid_open_path to output specific error messages #30

Closed Dentrax closed 5 months ago

Dentrax commented 5 months ago

I've been debugging why I keep getting the following error on the Mac:

Error: could not open device
Error on send: no device opened.

I had to deep dive into code a bit and added some logs and handled the error and eventually it was because of: (iokit/common) not permitted

Giving Input Monitoring permission to Warp terminal fixed the issue! So I wanted to submit a PR for this.

Here is how the error will look like with the -v flag:

Looking for vid/pid 0x046D / 0xB36A  (1133 / 45930)
Set usage to 0x0080 (128)
Set usagePage to 0x0001 (1)
Opening device, vid/pid:0x046D/0xB36A, usagePage/usage: 1/80
Device found: path: DevSrvsID:4295054735, vid: 0x046D, pid: 0xB36A, usage_page: 0x0001, usage: 0x0006
Device found: path: DevSrvsID:4295054735, vid: 0x046D, pid: 0xB36A, usage_page: 0x000C, usage: 0x0001
Device found: path: DevSrvsID:4295054735, vid: 0x046D, pid: 0xB36A, usage_page: 0x0001, usage: 0x0080
Device found: path: DevSrvsID:4295054735, vid: 0x046D, pid: 0xB36A, usage_page: 0xFF43, usage: 0x0202
Opening device by path: DevSrvsID:4295054735
Error: could not open device at path: DevSrvsID:4295054735
Error: hid_open_path: failed to open IOHIDDevice from mach entry: (0xE00002E2) (iokit/common) not permitted

/cc @todbot

todbot commented 5 months ago

Looks good, thanks!