Open latenitefilms opened 3 years ago
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.
https://github.com/latenitefilms/hammerspoon/commit/c1d33c7668846d6190bbce6df78ccf29ef7954ee
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.
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.
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
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.
I'm happy to give that a go, is there a recommended starter template?
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
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?