Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const CHECK_LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: number = usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
const CHECK_LIBUSB_TRANSFER_TYPE_BULK: number = usb.LIBUSB_TRANSFER_TYPE_BULK;
const CHECK_LIBUSB_TRANSFER_TYPE_INTERRUPT: number = usb.LIBUSB_TRANSFER_TYPE_INTERRUPT;
// libusb_iso_sync_type
const CHECK_LIBUSB_ISO_SYNC_TYPE_NONE: number = usb.LIBUSB_ISO_SYNC_TYPE_NONE;
const CHECK_LIBUSB_ISO_SYNC_TYPE_ASYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_ASYNC;
const CHECK_LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: number = usb.LIBUSB_ISO_SYNC_TYPE_ADAPTIVE;
const CHECK_LIBUSB_ISO_SYNC_TYPE_SYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_SYNC;
// libusb_iso_usage_type
const CHECK_LIBUSB_ISO_USAGE_TYPE_DATA: number = usb.LIBUSB_ISO_USAGE_TYPE_DATA;
const CHECK_LIBUSB_ISO_USAGE_TYPE_FEEDBACK: number = usb.LIBUSB_ISO_USAGE_TYPE_FEEDBACK;
const CHECK_LIBUSB_ISO_USAGE_TYPE_IMPLICIT: number = usb.LIBUSB_ISO_USAGE_TYPE_IMPLICIT;
// libusb_transfer_status
const CHECK_LIBUSB_TRANSFER_COMPLETED: number = usb.LIBUSB_TRANSFER_COMPLETED;
const CHECK_LIBUSB_TRANSFER_ERROR: number = usb.LIBUSB_TRANSFER_ERROR;
const CHECK_LIBUSB_TRANSFER_TIMED_OUT: number = usb.LIBUSB_TRANSFER_TIMED_OUT;
const CHECK_LIBUSB_TRANSFER_CANCELLED: number = usb.LIBUSB_TRANSFER_CANCELLED;
const CHECK_LIBUSB_TRANSFER_STALL: number = usb.LIBUSB_TRANSFER_STALL;
const CHECK_LIBUSB_TRANSFER_NO_DEVICE: number = usb.LIBUSB_TRANSFER_NO_DEVICE;
const CHECK_LIBUSB_TRANSFER_OVERFLOW: number = usb.LIBUSB_TRANSFER_OVERFLOW;
// libusb_transfer_flags
const CHECK_LIBUSB_TRANSFER_SHORT_NOT_OK: number = usb.LIBUSB_TRANSFER_SHORT_NOT_OK;
const CHECK_LIBUSB_TRANSFER_FREE_BUFFER: number = usb.LIBUSB_TRANSFER_FREE_BUFFER;
const CHECK_LIBUSB_TRANSFER_FREE_TRANSFER: number = usb.LIBUSB_TRANSFER_FREE_TRANSFER;
// libusb_request_type
const CHECK_LIBUSB_REQUEST_TYPE_STANDARD: number = usb.LIBUSB_REQUEST_TYPE_STANDARD;
const CHECK_LIBUSB_REQUEST_TYPE_CLASS: number = usb.LIBUSB_REQUEST_TYPE_CLASS;
const CHECK_LIBUSB_REQUEST_TYPE_VENDOR: number = usb.LIBUSB_REQUEST_TYPE_VENDOR;
const CHECK_LIBUSB_REQUEST_TYPE_RESERVED: number = usb.LIBUSB_REQUEST_TYPE_RESERVED;
// libusb_request_recipient
const CHECK_LIBUSB_RECIPIENT_DEVICE: number = usb.LIBUSB_RECIPIENT_DEVICE;
const CHECK_LIBUSB_RECIPIENT_INTERFACE: number = usb.LIBUSB_RECIPIENT_INTERFACE;
endpoint.transfer(transferBytes, function(error, data) {
if (error) {
if (error.errno === usb.LIBUSB_TRANSFER_TIMED_OUT) {
setTimeout(poll, argv.i);
} else {
throw new Error(error);
}
} else {
var isPressedNow = data[0] === DATA_WHEN_PRESSED;
if (isPressedNow !== currentlyPressed) {
currentlyPressed = isPressedNow;
if (isPressedNow) {
console.log('PRESSED');
launchCommand();
} else {
console.log('RELEASED');
}
}
setTimeout(poll, argv.i);