-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This abstracts the method for getting the USB device. Right now we care about HIDUSB but we could use another library at another time.
- Loading branch information
Showing
6 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./locator"; | ||
export * from "./usb"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { UsbHid } from "./hid"; | ||
import { Usb } from "./usb"; | ||
|
||
export function findUsbDevice(vendorId: number, productId: number, deviceInterface: number, usage: number): Usb { | ||
// At some point we will have logic to determine which library to use... | ||
// Right now just use the HID one... | ||
|
||
return new UsbHid(vendorId, productId, deviceInterface, usage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
export abstract class Usb { | ||
public abstract connect(vendorId: number, productId: number, usbInterface: number, usage: number): void; | ||
constructor(protected vendorId: number, protected productId: number, protected deviceInterface: number, protected usage: number) { | ||
|
||
} | ||
|
||
public abstract connect(): void; | ||
public abstract read(): number[]; | ||
public abstract write(data: number[]): void; | ||
public abstract disconnect(): void; | ||
} | ||
} |