Click or drag to resize

UsbHid Class

USB Human Interface Device class.

This class will trigger BaseEvent and OnlineStatusChange events.

Example
The following will show USB how to access the USB Hid ports and register them for use.
C#
//Initialize the USB HID of this control system. 
private void InitializeUSBHID()
{
   CrestronConsole.ConsoleCommandResponse("Supports USB HID {0}\r\n", SupportsUsbHid);
   CrestronConsole.ConsoleCommandResponse("Number of USB HID Ports {0}\r\n", NumberOfUsbHids);

   if (SupportsUsbHid)
   {
       foreach (var usbHid in UsbHids)
       {
           CrestronConsole.ConsoleCommandResponse("\tHID Port {0}\r\n", usbHid.ID);

           if (firsttime)
           {
               usbHid.BaseEvent += UsbHidOnBaseEvent;
               usbHid.OnlineStatusChange += UsbHidOnOnlineStatusChange;
               //Set to some testing value for now.
               usbHid.OutputReport.StringValue = "12";
               usbHid.FeatureReport.StringValue = "56";
           }

           CrestronConsole.ConsoleCommandResponse("\t\t Online: {0}\r\n", usbHid.IsOnline);

           if (usbHid.Registered)
               CrestronConsole.ConsoleCommandResponse("\t\t UnRegister: {0}\r\n", usbHid.UnRegister());
           else
               CrestronConsole.ConsoleCommandResponse("\t\t Register: {0}\r\n", usbHid.Register());

       }
       firsttime = false;
   }
}

//Triggered when the USB HID is connected and online with the system.
private void UsbHidOnOnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
   CrestronConsole.PrintLine("{0} went {1}", currentDevice, args.DeviceOnLine? "Online":"Offline");
}

//Base events for information received from the USB HID.
private void UsbHidOnBaseEvent(GenericBase device, BaseEventArgs args)
{
   var usbHid = device as UsbHid;
   if (usbHid == null)
       return;

   switch (args.EventId)
   {
       case(UsbHid.CountryCodeFeedbackEventId):
           CrestronConsole.PrintLine("{0} Country Code: {1}", usbHid, usbHid.CountryCodeFeedback);
           break;
       case(UsbHid.ManufacturerFeedbackEventId):
           CrestronConsole.PrintLine("{0} Manufacturer: {1}", usbHid, usbHid.ManufacturerFeedback.StringValue);
           break;
       case (UsbHid.ProductFeedbackEventId):
           CrestronConsole.PrintLine("{0} Product: {1}", usbHid, usbHid.ProductFeedback.StringValue);
           break;//SerialNumberFeedbackEventId
       case (UsbHid.SerialNumberFeedbackEventId):
           CrestronConsole.PrintLine("{0} Serial Number: {1}", usbHid, usbHid.SerialNumberFeedback.StringValue);
           break;
       case(UsbHid.FeatureReportFeedbackEventId):
           CrestronConsole.PrintLine("{0} Feature Report {1}", usbHid, usbHid.FeatureReportFeedback.StringValue);
           break;
       case(UsbHid.InputReportFeedbackEventId):
           CrestronConsole.PrintLine("{0} Input Report {1}", usbHid, usbHid.InputReportFeedback.StringValue);
           break;
       case (UsbHid.ReportDescriptorFeedbackEventId):
           CrestronConsole.PrintLine("{0} Report Descriptor = {1}", usbHid, usbHid.ReportDescriptorFeedback.StringValue);
           break;
   }
}
Inheritance Hierarchy

Namespace: Crestron.SimplSharpPro
Assembly: SimplSharpPro (in SimplSharpPro.dll) Version: 2.21.121
Syntax
C#
public class UsbHid : GenericDevice

The UsbHid type exposes the following members.

Properties
 NameDescription
Public propertyConnectedIpList A property containing the list of the ConnectedIpInformation objects which contain information about the devices that are connected to this IP ID. This property is only valid for an ethernet device. If this is not an ethernet device, then this property will return null. If this is an ethernet device, the list will be non-null. It will be empty if no devices are connected. The order of items in this list is not guaranteed.
(Inherited from GenericDevice)
Public propertyCountryCodeFeedback Get the country code specified by the HID attached to the port.

The BaseEvent event will trigger with CountryCodeFeedbackEventId.

Public propertyCode exampleDescription Get/Set the description of this device.
(Inherited from GenericBase)
Public propertyDisposed Property to indicate if the device has been disposed.
(Inherited from GenericDevice)
Public propertyFeatureReport Feature report that can be sent to the HID attached to the port.
Public propertyFeatureReportFeedback Feature reports specified by the HID attached to the port.

The BaseEvent event will trigger with FeatureReportFeedbackEventId.

Public propertyID Property to get the ID of the device.
(Inherited from GenericDevice)
Public propertyInputReportFeedback Input report specified by the HID attached to the port.

The BaseEvent event will trigger with InputReportFeedbackEventId.

Public propertyIsOnline Property to get the current online state of the device.
(Inherited from GenericDevice)
Public propertyManufacturerFeedback Get the manufacturer specified by the HID attached to the port.

The BaseEvent event will trigger with ManufacturerFeedbackEventId.

Public propertyName Get the name of this device.
(Inherited from GenericBase)
Public propertyOutputReport Output report that can be sent to the HID attached to the port.
Public propertyParent The parent that a given object was added to.
(Inherited from GenericBase)
Public propertyPortNumber USB Port Number.
Public propertyProductFeedback Get the product name specified by the HID attached to the port.

The BaseEvent event will trigger with ProductFeedbackEventId.

Public propertyRegisterable Property to indicate that this device can be registered.
(Inherited from GenericDevice)
Public propertyRegistered Property to get the current registration state of the device.
(Inherited from GenericDevice)
Public propertyRegistrationFailureReason Property to get the Registration Failure Reason, this will match the return value from the call to register.
(Inherited from GenericDevice)
Public propertyReportDescriptorFeedback Report descriptor specified by the HID attached to the port.

The BaseEvent event will trigger with ReportDescriptorFeedbackEventId.

Public propertySerialNumberFeedback Get the serial number specified by the HID attached to the port.

The BaseEvent event will trigger with SerialNumberFeedbackEventId.

Protected propertySIMPLDeviceImplementation Internal protected member used for actual device control.
(Inherited from GenericDevice)
Public propertyType Property to determine to type of device this is.
(Inherited from GenericDevice)
Public propertyUnRegistrationFailureReason Property to get the Unregistration Failure Reason, this will match the return value from the call to unregister.
(Inherited from GenericDevice)
Public propertyUserSpecifiedObject Can be assigned anything that user wants.
(Inherited from GenericBase)
Protected propertyXioEndpointStubSIMPLDevice The SIMPL "stub" Device that the XiO Director creates for an endpoint to send the 1C/0E to the correct place in hierarchy.
(Inherited from GenericDevice)
Top
Methods
 NameDescription
Public methodDispose Clean up of resources.
(Inherited from GenericBase)
Protected methodDispose(Boolean) Method to perform the actual disposing of the device.
(Inherited from GenericDevice)
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize Destructor of the device.
(Inherited from GenericDevice)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodOnBaseEvent(Int32) Protected member used to fire the BaseEvent with the default extended information.
(Inherited from GenericBase)
Protected methodOnBaseEvent(Int32, UInt16) Protected member used to fine the BaseEvent with extended event information.
(Inherited from GenericBase)
Public methodRegister Register this device with the system.
(Inherited from GenericDevice)
Public methodToString Return the name of the device.
(Inherited from GenericDevice)
Public methodUnRegister Unregister this device with the system. This function can not be called from the device's own SigChange event handler.

On successful unregistration, if this device supports the OnlineStatusChange event, it will trigger indicating the device when offline.


(Inherited from GenericDevice)
Top
Events
 NameDescription
Public eventBaseEvent Generic base event, triggered when the there are no other handlers available for a specific EventID.
(Inherited from GenericBase)
Public eventIpInformationChange Event that tells what IP Address is connected/disconnected from an IP ID for a non-UDP device. This is only valid for an Ethernet device. An exception will be thrown if it is not.
(Inherited from GenericDevice)
Public eventOnlineStatusChange Event triggered when the Online status of the device changes.
(Inherited from GenericDevice)
Top
Fields
 NameDescription
Public fieldStatic memberCountryCodeFeedbackEventId

The value of CountryCodeFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberFeatureReportFeedbackEventId

The value of one of the FeatureReportFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberInputReportFeedbackEventId

The value of one of the InputReportFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberManufacturerFeedbackEventId

The value of ManufacturerFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberProductFeedbackEventId

The value of ProductFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberReportDescriptorFeedbackEventId

The value of one of the ReportDescriptorFeedback has changed.

The BaseEvent event will trigger for this event id.

Public fieldStatic memberSerialNumberFeedbackEventId

The value of SerialNumberFeedback has changed.

The BaseEvent event will trigger for this event id.

Top

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also