fix: compare available devices by vid, pid, interface on linux (#854)
This commit is contained in:
committed by
László Monda
parent
108d60a497
commit
1ed6669ced
@@ -1,6 +1,7 @@
|
|||||||
import { Device, devices, HID } from 'node-hid';
|
import { Device, devices, HID } from 'node-hid';
|
||||||
import { pathExists } from 'fs-extra';
|
import { pathExists } from 'fs-extra';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import { platform } from 'os';
|
||||||
import { CommandLineArgs, DeviceConnectionState, isEqualArray, LogService, UdevRulesInfo } from 'uhk-common';
|
import { CommandLineArgs, DeviceConnectionState, isEqualArray, LogService, UdevRulesInfo } from 'uhk-common';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -272,10 +273,20 @@ export class UhkHidDevice {
|
|||||||
private connectToDevice(): HID {
|
private connectToDevice(): HID {
|
||||||
try {
|
try {
|
||||||
const devs = devices();
|
const devs = devices();
|
||||||
if (!isEqualArray(this._prevDevices, devs)) {
|
let compareDevices = devs as any;
|
||||||
|
|
||||||
|
if (platform() === 'linux') {
|
||||||
|
compareDevices = devs.map(x => ({
|
||||||
|
productId: x.productId,
|
||||||
|
vendorId: x.vendorId,
|
||||||
|
interface: x.interface
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEqualArray(this._prevDevices, compareDevices)) {
|
||||||
this.logService.debug('[UhkHidDevice] Available devices:');
|
this.logService.debug('[UhkHidDevice] Available devices:');
|
||||||
this.logDevices(devs);
|
this.logDevices(devs);
|
||||||
this._prevDevices = devs;
|
this._prevDevices = compareDevices;
|
||||||
} else {
|
} else {
|
||||||
this.logService.debug('[UhkHidDevice] Available devices unchanged');
|
this.logService.debug('[UhkHidDevice] Available devices unchanged');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user