I'm making an application to run in the background on a salespoint to read input from a usb scanner. How can I get the input of the scanner from C#? And can I differentiate between the scanner and a usb keyboard? (Scanner is a HID device)
The USB HID class keyboard is normally designed with an IN endpoint that communicates keystrokes to the computer and an OUT endpoint that communicates the status of the keyboard's LEDs from the computer to the keyboard.
Human Interface Devices (HID) is a device class definition to replace PS/2-style connectors with a generic USB driver to support HID devices such as keyboards, mice, game controllers, and so on.
To open an HID connection, first access a HIDDevice object. For this, you can either prompt the user to select a device by calling navigator. hid. requestDevice() , or pick one from navigator.
As for the difference between HID and USB serial, serial is bulk while HID is control and interrupt. That's fundamental for USB, and means HID has (potentially) lower latency but serial has higher capacity.
I did this successfully before using a “Raw Input” implementation on CodeProject:
It allows you to receive both the input (what “keys” are pressed if it mimics a “keyboard”) as well distinguish which device it came from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With