node-elgato-stream-deck icon indicating copy to clipboard operation
node-elgato-stream-deck copied to clipboard

WIP: WebHID support

Open Julusian opened this issue 4 years ago • 1 comments

Related: #10 WebHID is now available in some early builds of Chrome behind a feature flag and so can be tested. (https://bugs.chromium.org/p/chromium/issues/detail?id=890096)

Demo at: https://streamdeck.julusian.dev/

This PR aims to add support for WebHID as an alternate backend to node-hid. With this it is possible to use a streamdeck in the browser, and will enable easy use for a whole range of webapps.

This is very much a work in progress. It is unlikely to be completed anytime soon as I don't see much point in releasing a webhid compatible version before it is available in stable releases of Chrome (January maybe?)

Justification

To do this, some restructuring had to be done to the project, so that it is possible to install a package that does not depend on node-hid when only targetting the browser. This has been achieved using lerna with yarn workspaces and splitting this project into 3 packages.

  • elgato-stream-deck-core is the common base code, that should generally not be referenced by library users directly, except for in code which wants to be portable, but the other libraries will still be needed to open devices.
  • elgato-stream-deck is the node version. while the name may be slightly unclear, this keeps it the same as it is currently, which will make migration for existing users easier.
  • elgato-stream-deck-web is the webhid version

The node and web version have different api's for opening/listing/detecting devices, but this is because of underlying platform differences. Once the device is opened, the same api is used. This means that all of the api methods now return promises to be more compatible with the webhid api. It may be confusing for the node api as the underlying calls are synchronous, so something may need to be done for this.

I am considering extending the web api to allow for more image manipulation, as that can be easily done without introducing dependencies via a canvas. This could either be done by extending the StreamDeck interface, or it could be done as a 'plugin' (optional parameter when opening the device). Perhaps a sharp plugin package could also be made for node to the same api to restore some of the functionality that was removed in 3.0.

Julusian avatar Sep 11 '19 22:09 Julusian

This is all sounding pretty good to me so far! Good work.

Abrahamic-God avatar Sep 11 '19 23:09 Abrahamic-God