How to use the usb-detection.find function in usb-detection

To help you get started, we’ve selected a few usb-detection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github diefarbe / node-rest-api / src / modules / keyboard.ts View on Github external
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();
github timfish / aurelia-electron-webpack / src / app.ts View on Github external
public async attached() {
    this.devices = await usbDetect.find();

    usbDetect.on('change', async device => {
      this.devices = await usbDetect.find();
    });

    usbDetect.startMonitoring();
  }
}

usb-detection

Listen to USB devices and detect changes on them.

MIT
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis