Class HidDeviceListener
A class that provides events for HID device arrival and removal.
public abstract class HidDeviceListener
- Inheritance
-
objectHidDeviceListener
Remarks
This class exposes two events to the caller: Arrived and Removed. As their names suggest, subscribing to these events will inform your code whenever a new HID device is discovered on the system, or one is removed, respectively.
You will only receive events for devices that were added or removed after you subscribed to the event. That is, arrival events will only be raised for devices added after you have subscribed to the Arrived events. All devices already attached to the system will be ignored.
Methods
ClearEventHandlers()
Implementers can call this method to reset the event handlers during cleanup.
protected void ClearEventHandlers()
Create()
Creates an instance of a HidDeviceListener.
public static HidDeviceListener Create()
Returns
- HidDeviceListener
An instance of HidDeviceListener.
Exceptions
- PlatformNotSupportedException
This class depends on operating system specific support being present. If this exception is being raised, the operating system or platform that you are attempting to run this does not have HID device notification support.
OnArrived(IHidDevice)
Implementers should call this method when they have discovered a new HID device on the system.
protected void OnArrived(IHidDevice device)
Parameters
device
IHidDeviceThe device instance that originates this event.
OnRemoved(IHidDevice)
Implementers should call this method when they have discovered that a HID device has been removed from the system.
protected void OnRemoved(IHidDevice device)
Parameters
device
IHidDeviceThe device instance that originates this event.
Events
Arrived
Subscribe to receive an event whenever a Human Interface Device (HID) is added to the computer.
public event EventHandler<HidDeviceEventArgs>? Arrived
Event Type
- EventHandler<HidDeviceEventArgs>
Removed
Subscribe to receive an event whenever a Human Interface Device (HID) is removed from the computer.
public event EventHandler<HidDeviceEventArgs>? Removed
Event Type
- EventHandler<HidDeviceEventArgs>