Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.06k stars 583 forks source link

Feature Request: watch and react to HID Input Report #3392

Open gingerbeardman opened 1 year ago

gingerbeardman commented 1 year ago

I believe @cmsj is taking a look at this.

HID Input Report is a set of bytes that designate the current button state of a HID device.

It would be useful to set a watcher on these, and maybe have the ability to read (to get input outside of a watcher) and send (to set LEDs, features, etc). Also requesting HID Device Info, or a list of connected HID devices, would be useful to watch for connection of certain devices (it would work for Bluetooth devices).

Background I'd like to use it to respond to button presses on a HID device that is not a standard keyboard (it has multiple states per button: just pressed, pressed, held, just released) and that historically required additional software "driver": Sony USB Jog Controller (PCVA-JC1).

I've been viewing the report using:

Related Other use cases I've found for this are linked below.

cmsj commented 1 year ago

tl;dr I'm thinking I can reshape the code in HSStreamDeckManager to provide a generic way to listen for HID events from a USB device, and shove it into hs.hid. I don't want to step on @asmagill 's toes with the possible future of his IOKit work, but this feels like a simple enough task that it ought to be fine to have it in hs.hid and if it's technically also possible later with an hs.iokit then so be it.

asmagill commented 1 year ago

If you have an idea, go for it. The iokit module is one I go back to every so often because I think I've found a new way to approach it that will allow reducing code replication among our modules that use IOKit and IOService and provide a more generic approach that can be easily extended from Lua without having to resort to Objective-C code... and each time I hit a wall, discovering that each use in Hammerspoon is somewhat unique and does things just differently enough that a generic module approach doesn't simplify things.

I keep hoping I'm missing something and inspiration will hit, but as of now, my iokit module is more of a poking and prodding tool and not really a fully useful module in its own right.

gingerbeardman commented 2 months ago

Congrats on 1.0

Hopefully we will see some additions like this in future

latenitefilms commented 2 months ago

This is definitely something I'm interesting in tackling at some point.