Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for HID reports? #20

Open
latenitefilms opened this issue Jan 29, 2021 · 7 comments
Open

Add support for HID reports? #20

latenitefilms opened this issue Jan 29, 2021 · 7 comments

Comments

@latenitefilms
Copy link

Not urgent or important... but just incase you've already solved this elsewhere...

Have you got any extensions/libraries for handling generic HID reports (IOHIDDeviceRegisterInputReportCallback)?

I basically am just looking for something that does what the Stream Deck extension does - but more generic where I can supply a manufacturer key, and just see the raw data for testing purposes. Ideally it would have a callback for device connected, device disconnected, and input report.

Thoughts?

@latenitefilms
Copy link
Author

Hope you're well @asmagill ! I was messing around with another piece of hardware today, and it reminded me that it would be so helpful to have some kind of Lua-based iokit extension for getting the raw data off HID devices.

I'm currently just using a butchered version of hs.streamdeck and monitoring the Xcode console.

latenitefilms/hammerspoon@c1d33c7

@asmagill
Copy link
Owner

I've been playing with my iokit module off and on... The battery module needs to be updated for M1 macs, but I seem to be the only one who has noticed, so it's been easy to put off... the initial work I've done leverages that module, so I suspect I'll be wanting to add it soon. At the moment, it's strictly generic IOKit stuff, nothing that uses the specific sub-branches (IOUSB, IOHID, etc.) but I don't think it would be too hard to add... I'll take a closer look at specifically what the streamdeck module is doing and see what I'd have to add, hopefully later this coming week or weekend.

@latenitefilms
Copy link
Author

Legend, thanks mate! No rush or pressure - I just wanted to make a note here for myself, so that I remember what I was doing in the past, when future Chris attempts the same thing again.

@gingerbeardman
Copy link

gingerbeardman commented Feb 27, 2023

I'm trying to get raw data out of an old input device, a Sony USB Jog Controller (PCVA-JC1).

Using WebHID I can see the data, and it changing in realtime as I press the buttons and move the wheel.

So, is it already possible to read the HID Input Report using hs._asm.iokit?

Thanks!

Example input report (button A just pressed)

00 81 00 00

Device info (from WebHID Explorer)

productName: Sony USB Jog Controller
vendorId:    0x054C (1356)
productId:   0x00C4 (196)
opened:      false
collections[0]
  Usage FF02:0001
  Input reports: 0x00
  Output reports: 0x00
Input report 0x00
  24 values * 1 bits (bits 0 to 23)
    Data,Var,Rel
    Usages: 0007:0001 (Keyboard/Keypad > Keyboard ErrorRollOver) to 0007:0018 (Keyboard/Keypad > Keyboard u and U)
    Logical bounds: 0 to 1
Output report 0x00
  24 values * 1 bits (bits 0 to 23)
    Data,Var,Abs
    Usages: 0008:0001 (LED > Num Lock) to 0008:0018 (LED > Ring)
    Logical bounds: 0 to 1

More info

❯ ./hidapitester --vidpid 054c/00c4 --list-detail
054C/00C4: Sony - Sony USB Jog Controller
  vendorId:      0x054C
  productId:     0x00C4
  usagePage:     0xFF02
  usage:         0x0001
  serial_number:  
  interface:     0 
  path: IOService:/AppleARMPE/arm-io/AppleT600xIO/usb-drd0@2280000/AppleT6000USBXHCI@00000000/usb-drd0-port-hs@00100000/Sony USB Jog Controller@00100000/IOUSBHostInterface@0/AppleUserUSBHostHIDDevice

@latenitefilms
Copy link
Author

I don't believe there's any current Lua Extension that allows you to do what you want, but I agree, it would be pretty handy!

I'm currently just making new Objective-C Extensions each time I want to support a new device.

@gingerbeardman
Copy link

I'm happy to give that a go, is there a recommended starter template?

@latenitefilms
Copy link
Author

I'd probably recommend doing what I started doing above, and just duplicating hs.streamdeck and manipulating as required.

There's some more general information here:

https://github.com/Hammerspoon/hammerspoon/blob/master/CONTRIBUTING.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants