Skip to content

Commit

Permalink
fix: re-add devicePath
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Sep 6, 2021
1 parent ed1c1ea commit 349f6a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/xkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ export class XKeys extends EventEmitter {
return XKEYS_VENDOR_ID
}

constructor(
private device: HIDDevice,
private deviceInfo: DeviceInfo
) {
constructor(private device: HIDDevice, private deviceInfo: DeviceInfo, private _devicePath: string | undefined) {
super()

this.product = this._setupDevice(deviceInfo)
Expand Down Expand Up @@ -547,6 +544,9 @@ export class XKeys extends EventEmitter {
public _getDeviceInfo(): DeviceInfo {
return this.deviceInfo
}
public get devicePath(): string | undefined {
return this._devicePath
}
/** The unique id of the xkeys-panel. Note: This is only available if options.automaticUnitIdMode is set for the Watcher */
public get uniqueId(): string {
return `${this.info.productId}_${this.unitId}`
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function setupXkeysPanel(devicePathOrHIDDevice?: HID.Device | HID.H

const deviceWrap = new NodeHIDDevice(device)

const xkeys = new XKeys(deviceWrap, deviceInfo)
const xkeys = new XKeys(deviceWrap, deviceInfo, devicePath)

// Wait for the device to initialize:
await xkeys.init()
Expand Down
14 changes: 9 additions & 5 deletions packages/webhid/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ export async function setupXkeysPanel(browserDevice: HIDDevice): Promise<XKeys>

const deviceWrap = new WebHIDDevice(browserDevice)

const xkeys = new XKeys(deviceWrap, {
product: browserDevice.productName,
productId: productId,
interface: null, // todo: Check what to use here (collection.usage?)
})
const xkeys = new XKeys(
deviceWrap,
{
product: browserDevice.productName,
productId: productId,
interface: null, // todo: Check what to use here (collection.usage?)
},
undefined
)

// Wait for the device to initialize:
await xkeys.init()
Expand Down

0 comments on commit 349f6a9

Please sign in to comment.