Skip to content

Commit

Permalink
getRawHidDevice
Browse files Browse the repository at this point in the history
- Added a function to allow access to the raw HID device object.
  • Loading branch information
hopejr committed May 4, 2023
1 parent 8b88508 commit a53f2c1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Library to use Contour Design ShuttleXpress and ShuttlePro (v1 and v2) in Node.js projects without the driver. In some markets, these devices are also known as Multimedia Controller Xpress and Multimedia Controller PRO v2.

_This library now supports multiple devices connected at one time (since v1.1.0). This change is backwards compatible and simply includes the device connection UUID for each event as the final parameter in the callback._
_This library now supports multiple devices connected at one time (since v1.1.0). This change is backwards compatible and simply includes a hash of the device id for each event as the final parameter in the callback._

## Installation
```sh
Expand Down Expand Up @@ -35,6 +35,29 @@ This should be called after the 'connect' event listener has been declared, othe

Stops the service and monitoring. This must be called before your script ends.


`getDeviceList()`
Use to retrieve all the devices that are connected.

Returns:
- `deviceList` Array - contains the following information:
- `id` String - either an MD5 hash of the serial number (if it exists) or the device path, used to distinguish between multiple devices that may be connected at once.
- `name` String - name of the device ('ShuttleXpress', 'ShuttlePro v1', or 'ShuttlePro v2')
- `hasShuttle` Boolean
- `hasJog` Boolean
- `numButtons` Integer


`getRawHidDevice(id)`
Use to retrieve the raw HID device object for the device identified by id.

Parameters:
- `id` String

Returns:
- `hid` Object - the raw HID device object


### Events
`shuttle.on('...', () => {})`

Expand Down
5 changes: 5 additions & 0 deletions lib/Shuttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Shuttle extends EventEmitter {
})
}

getRawHidDevice (id) {
const device = this._hid.find(ele => ele.id === id)
return device ? device.hid : null
}

_connect () {
const foundDevices = []
const devices = hid.devices()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shuttle-control-usb",
"version": "1.1.0",
"version": "1.2.0",
"description": "NodeJS Interface for Contour ShuttleXpress, ShuttlePro V1, and ShuttlePro V2",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a53f2c1

Please sign in to comment.