Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HidDevice class

Represents a top-level collection and the corresponding device.

Syntax


public sealed class HidDevice : IDisposable

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06030000)]

Members

The HidDevice class has these types of members:

Events

The HidDevice class has these events.

EventDescription
InputReportReceived Establishes an event listener which handles input reports issued by the device.

 

Methods

The HidDevice class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Close [C++, JavaScript]Closes the connection between the host and the given HID device.
CreateFeatureReport() Creates the only, or default, feature report that the host will send to the device.
CreateFeatureReport(UInt16) Creates a feature report, identified by the reportId parameter, that the host will send to the device.
CreateOutputReport() Creates the only, or default, output report that the host will send to the device.
CreateOutputReport(UInt16) Creates an output report, identified by the reportId parameter, that the host will send to the device.
Dispose [C#, VB]Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
FromIdAsync Opens a handle to the device identified by the deviceId parameter. The acess type is specified by the accessMode parameter.
GetBooleanControlDescriptions Retrieves the descriptions of the boolean controls for the given HID device.
GetDeviceSelector(UInt16, UInt16) Retrieves an Advanced Query Syntax (AQS) string based on the given usagePage and usageId.
GetDeviceSelector(UInt16, UInt16, UInt16, UInt16) Retrieves an Advanced Query Syntax (AQS) string based on the given usagePage, usageId, vendorId, and productId.
GetFeatureReportAsync() Asynchronously retrieves the first, or default, feature report from the given HID device.
GetFeatureReportAsync(UInt16) Asynchronously retrieves a feature report, identified by the reportId parameter, for the given HID device.
GetInputReportAsync() Asynchronously retrieves the default, or first, input report from the given HID device.
GetInputReportAsync(UInt16) Asynchronously retrieves an input report, identified by the reportId parameter, from the given HID device.
GetNumericControlDescriptions Retrieves the descriptions of the numeric controls for the given HID device.
SendFeatureReportAsync Sends an feature report asynchronously from the host to the device.
SendOutputReportAsync Sends an output report asynchronously from the host to the device.

 

Properties

The HidDevice class has these properties.

PropertyAccess typeDescription

ProductId

Read-onlyGets the product identifier for the given HID device.

UsageId

Read-onlyGets the usage identifier for the given HID device.

UsagePage

Read-onlyGets the usage page of the top-level collection.

VendorId

Read-onlyGets the vendor identifier for the given HID device.

Version

Read-onlyGets the version, or revision, number for the given HID device.

 

Remarks

The following example demonstrates how a Windows Store app built with XAML and C# uses the GetDeviceSelector method to create a selector for a specific HID device and then usesFromIdAsync method to open a connection to that device.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Windows.Devices.Enumeration;
using Windows.Devices.HumanInterfaceDevice;
using Windows.Storage;
using Windows.Storage.Streams;

namespace HidSampleCS
{
    class Enumeration
    {
        // Enumerate HID devices
        private async void EnumerateHidDevices()
        {
            UInt32 vendorId = 0x045E;
            UInt32 productId = 0x078F;
            UInt32 usagePage = 0xFF00;
            UInt32 usageId = 0x0001;

            // Create a selector that gets a HID device using VID/PID and a 
            // VendorDefined usage
            string selector = HidDevice.GetDeviceSelector(usagePage, usageId, 
                              vendorId, productId);

            // Enumerate devices using the selector
            var devices = await DeviceInformation.FindAllAsync(selector);

            if (devices.Count > 0)
            {
                // Open the target HID device
                HidDevice device = await HidDevice.FromIdAsync(devices.ElementAt(0).Id, 
                                   FileAccessMode.ReadWrite);

                // At this point the device is available to communicate with
                // So we can send/receive HID reports from it or 
                // query it for control descriptions
            }
            else
            {
                // There were no HID devices that met the selector criteria
                this.NotifyUser("MUTT HID device not found");
            }
        }
    }
}



Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Devices.HumanInterfaceDevice
Windows::Devices::HumanInterfaceDevice [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8.1 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Devices.HumanInterfaceDevice
Windows::Devices::HumanInterfaceDevice [C++]

Metadata

Windows.winmd

See also

Object
IClosable

 

 

Show:
© 2015 Microsoft