1 | import { ExtendedDevice } from './device';
|
2 | import * as usb from './bindings';
|
3 | interface EventListeners<T> {
|
4 | newListener: keyof T;
|
5 | removeListener: keyof T;
|
6 | }
|
7 | interface DeviceIds {
|
8 | idVendor: number;
|
9 | idProduct: number;
|
10 | }
|
11 | declare module './bindings' {
|
12 | interface Device extends ExtendedDevice {
|
13 | }
|
14 | interface DeviceEvents extends EventListeners<DeviceEvents> {
|
15 | attach: Device;
|
16 | detach: Device;
|
17 | attachIds: DeviceIds;
|
18 | detachIds: DeviceIds;
|
19 | }
|
20 | function addListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
21 | function removeListener<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
22 | function on<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
23 | function off<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
24 | function once<K extends keyof DeviceEvents>(event: K, listener: (arg: DeviceEvents[K]) => void): void;
|
25 | function listeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
26 | function rawListeners<K extends keyof DeviceEvents>(event: K): ((arg: DeviceEvents[K]) => void)[];
|
27 | function removeAllListeners<K extends keyof DeviceEvents>(event?: K): void;
|
28 | function emit<K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]): boolean;
|
29 | function listenerCount<K extends keyof DeviceEvents>(event: K): number;
|
30 | }
|
31 | export = usb;
|