UNPKG

@blackmagic-controller/node

Version:

An npm module for interfacing with the Blackmagic usb/bluetooth controllers in node

43 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeHIDDevice = void 0; const eventemitter3_1 = require("eventemitter3"); /** * The wrapped node-hid HIDDevice. * This translates it into the common format expected by @blackmagic-controller/core */ class NodeHIDDevice extends eventemitter3_1.EventEmitter { device; constructor(device) { super(); this.device = device; this.device.on('error', (error) => this.emit('error', error)); this.device.on('data', (data) => this.emit('input', data)); } async close() { await this.device.close(); } async sendFeatureReport(data) { await this.device.sendFeatureReport(Buffer.from(data)); // Future: avoid re-wrap } async getFeatureReport(reportId, reportLength) { return this.device.getFeatureReport(reportId, reportLength); } async sendReports(buffers) { const ps = []; for (const data of buffers) { ps.push(this.device.write(Buffer.from(data))); // Future: avoid re-wrap } await Promise.all(ps); } async getDeviceInfo() { const info = await this.device.getDeviceInfo(); return { path: info.path, productId: info.productId, vendorId: info.vendorId, }; } } exports.NodeHIDDevice = NodeHIDDevice; //# sourceMappingURL=hid-device.js.map