Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public init() {
this.keyboardEvents.addSettingsListener(this.onSettingsChanged);
this.keyboardEvents.addStateChangeListener(this.onStateChangeRequested);
usbDetect.startMonitoring();
// There's a filtered search, but it seems broken...
usbDetect.find((error: any, devices: any) => {
for (const device of devices) {
if (device.vendorId === 9456) {
this.logger.info("Found a keyboard.");
this.setupKeyboard();
}
}
});
usbDetect.on("remove:9456", (device: any) => {
this.logger.info("Removed a keyboard.");
this.disconnectKeyboard();
});
usbDetect.on("add:9456", (device: any) => {
this.logger.info("Added a keyboard.");
this.setupKeyboard();
public async attached() {
this.devices = await usbDetect.find();
usbDetect.on('change', async device => {
this.devices = await usbDetect.find();
});
usbDetect.startMonitoring();
}
}