How to use the usb-detection.startMonitoring 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();
        });
github FrogTheFrog / steam-gyro-for-cemuhook / src / backend / lib / steam-device / steam-hid-device.ts View on Github external
public static startMonitoring() {
        if (this.motoringCallCount++ === 0) {
            this.updateDeviceList(0, ...this.allTypes);

            // Dongle devices can be connected using usb events
            usbDetect.on(
                `change:${SteamHidId.Vendor}:${SteamHidId.DongleProduct}`,
                () => this.updateDeviceList(1000, "dongle"),
            );
            usbDetect.on(
                `change:${SteamHidId.Vendor}:${SteamHidId.WiredProduct}`,
                () => this.updateDeviceList(1000, "wired"),
            );

            usbDetect.startMonitoring();
        }
    }
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