signal11 / hidapi

A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac, and Windows.
http://www.signal11.us/oss/hidapi/
Other
2.46k stars 901 forks source link

MacOS / Keyboard: could not open device #484

Closed real-felix closed 1 year ago

real-felix commented 1 year ago

Hello, I'm writing a keyboard firmware, and I'm debugging the official one to see how it works. For some reason, it yields 5 entrie:

% ./hidapitester --vidpid 3297/1969 --list-detail
3297/1969: ZSA Technology Labs - Moonlander Mark I
  vendorId:      0x3297
  productId:     0x1969
  usagePage:     0xFF60
  usage:         0x0061
  serial_number:  
  interface:     1 
  path: DevSrvsID:4295052728

3297/1969: ZSA Technology Labs - Moonlander Mark I
  vendorId:      0x3297
  productId:     0x1969
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     0 
  path: DevSrvsID:4295052723

3297/1969: ZSA Technology Labs - Moonlander Mark I
  vendorId:      0x3297
  productId:     0x1969
  usagePage:     0x0001
  usage:         0x0080
  serial_number:  
  interface:     2 
  path: DevSrvsID:4295052727

3297/1969: ZSA Technology Labs - Moonlander Mark I
  vendorId:      0x3297
  productId:     0x1969
  usagePage:     0x000C
  usage:         0x0001
  serial_number:  
  interface:     2 
  path: DevSrvsID:4295052727

3297/1969: ZSA Technology Labs - Moonlander Mark I
  vendorId:      0x3297
  productId:     0x1969
  usagePage:     0x0001
  usage:         0x0006
  serial_number:  
  interface:     2 
  path: DevSrvsID:4295052727

When I try and listen to the first one, it works correcly:

% sudo ./hidapitester --vidpid 3297/1969 --usagePage 0xFF60 --usage 0x0061  -l 8 --open --read-input-forever
Opening device, vid/pid:0x3297/0x1969, usagePage/usage: FF60/61
Device opened
Reading 8-byte input report 0, 250 msec timeout...read 0 bytes:
…

This obviously isn't the one for the keyboard, because it doesn't react to me pressing a key (always 0 bytes).

I tried opening the 2nd one:

% sudo ./hidapitester -v --vidpid 3297/1969 --usagePage 0x1 --usage 0x6 -l 8 --open --read-input-forever  
Looking for vid/pid 0x3297 / 0x1969  (12951 / 6505)
Set usagePage to 0x0001 (1)
Set usage to 0x0006 (6)
Set buflen to 8
Opening device, vid/pid:0x3297/0x1969, usagePage/usage: 1/6
Error: could not open device
Error on read: no device opened.

But it fails without detail. How can I know what happens here? My goal is to be able to see the keyboard's reports. Thanks by advance!

Youw commented 1 year ago

You cannot open Keyboard/Mouse devices with HIDAPI on Windows/macOS - operating system doesn't allow that. If you do want to open a Mouse/Keyboard - you need to use OS API. The only alternative - detach kernel driver, which is not trivial on macOS in general.

Youw commented 1 year ago

Oh, and please see #468.

real-felix commented 1 year ago

Oh, OK, thank you. Maybe you should archived the repo, so that it's obvious it's unmaintained.

Youw commented 1 year ago

Maybe you should archived the repo

I wish I could. The only owner of the repo is not answering for years now.