Skip to content

Commit

Permalink
chore: clean & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Sep 6, 2021
1 parent 2887ef7 commit f8b517a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 24 deletions.
6 changes: 2 additions & 4 deletions packages/core/src/xkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class XKeys extends EventEmitter {
}

constructor(
// public readonly devicePath: string,
private device: HIDDevice,
deviceInfo: {
product: string | undefined
Expand Down Expand Up @@ -89,8 +88,8 @@ export class XKeys extends EventEmitter {
// this is a special report that does not correlate to the regular data report, it is created by sending getVersion()

const firmVersion = data.readUInt8(10)
// const dUID = data.readUInt8(0) // the unit ID is the first byte, index 0, used to tell between 2 identical X-keys, UID is set by user
// const dPID = data.readUInt16LE(11) // PID is also in this report as a double check.
// data.readUInt8(0) the unit ID is the first byte, index 0, used to tell between 2 identical X-keys, UID is set by user
// data.readUInt16LE(11) // PID is also in this report as a double check.

this._firmwareVersion = firmVersion // Firmware version

Expand Down Expand Up @@ -122,7 +121,6 @@ export class XKeys extends EventEmitter {
const genData = dd & (1 << 1) ? true : false
if (genData) {
// Note, the generateData is used to get the full state
// this.emit('unitID', UID, PID, productName)

this._unidId = UID

Expand Down
2 changes: 0 additions & 2 deletions packages/node/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export async function setupXkeysPanel(devicePathOrHIDDevice?: HID.Device | HID.H
}
| undefined

// let hidDevices: HID.Device[] | undefined // set later

if (!devicePathOrHIDDevice) {
// Device not provided, will then select any connected device:
const connectedXkeys = listAllConnectedPanels()
Expand Down
17 changes: 1 addition & 16 deletions packages/webhid/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { WebHIDDevice } from './web-hid-wrapper'

/** Prompts the user for which X-keys panel to select */
export async function requestXkeysPanels(): Promise<HIDDevice[]> {
const browserDevices = await navigator.hid.requestDevice({
return navigator.hid.requestDevice({
filters: [
{
vendorId: XKEYS_VENDOR_ID,
},
],
})
// if (!browserDevices.length) throw new Error('No device was selected by user')

return browserDevices
}
/**
* Reopen previously selected devices.
Expand All @@ -24,22 +21,10 @@ export async function getOpenedXKeysPanels(): Promise<HIDDevice[]> {

/** Sets up a connection to a HID device (the X-keys panel) */
export async function setupXkeysPanel(browserDevice: HIDDevice): Promise<XKeys> {
// const browserDevices = await navigator.hid.requestDevice({
// filters: [
// {
// vendorId: XKEYS_VENDOR_ID,
// },
// ],
// })

// if (!browserDevices.length) throw new Error('No device was selected by user')

// const browserDevice = browserDevices[0]
if (!browserDevice?.collections?.length) throw Error(`device collections is empty`)
if (!browserDevice.productId) throw Error(`Device has no productId!`)

const productId = browserDevice.productId
// const collection = browserDevice.collections[0]

if (!browserDevice.opened) {
await browserDevice.open()
Expand Down
2 changes: 0 additions & 2 deletions packages/webhid/src/web-hid-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export class WebHIDDevice extends EventEmitter implements CoreHIDDevice {
this.device.addEventListener('error', this._handleError)
}
public write(data: number[]): void {
// this.device.write(data)

this.reportQueue
.add(async () => {
await this.device.sendReport(data[0], new Uint8Array(data.slice(1)))
Expand Down

0 comments on commit f8b517a

Please sign in to comment.