HidOutputReport 类

定义

表示 HID 输出报告

主机问题输出报告,用于请求设备上的更改。 例如,主机可能会向键盘发出打开或关闭 LED 的请求。

public ref class HidOutputReport sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HidOutputReport final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HidOutputReport
Public NotInheritable Class HidOutputReport
继承
Object Platform::Object IInspectable HidOutputReport
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

注解

以下示例演示使用 XAML 和 C# 生成的 UWP 应用如何使用 CreateOutputReport 方法创建输出报告。 然后,此示例使用 SendOutputReportAsync 方法将报表发送到设备。

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 Vendor
    {
        private async void ReadWriteToHidDevice(HidDevice device)
        {
            if (device != null)
            {
                // construct a HID output report to send to the device
                HidOutputReport outReport = device.CreateOutputReport();

                /// Initialize the data buffer and fill it in
                byte[] buffer = new byte[] { 10, 20, 30, 40 };

                DataWriter dataWriter = new DataWriter();
                dataWriter.WriteBytes(buffer);

                outReport.Data = dataWriter.DetachBuffer();

                // Send the output report asynchronously
                await device.SendOutputReportAsync(outReport);

                //
                // Sent output report successfully 
                // Now lets try read an input report 
                //
                HidInputReport inReport = await device.GetInputReportAsync();

                if (inReport != null)
                {
                    UInt16 id = inReport.Id;
                    var bytes = new byte[4];
                    DataReader dataReader = DataReader.FromBuffer(inReport.Data);
                    dataReader.ReadBytes(bytes);
                }
                else
                {
                    this.NotifyUser("Invalid input report received");
                }
            }
            else
            {
                this.NotifyUser("device is NULL");
            }
        }
    }
}

属性

Data

获取或设置与给定输出报表关联的数据。

Id

获取与给定输出报告关联的标识符。

方法

GetBooleanControl(UInt16, UInt16)

检索与给定 usagePageusageId 关联的布尔控件。

GetBooleanControlByDescription(HidBooleanControlDescription)

检索与给定 controlDescription 关联的布尔控件。

GetNumericControl(UInt16, UInt16)

检索与给定 usagePageusageId 关联的数值控件。

GetNumericControlByDescription(HidNumericControlDescription)

检索与给定 controlDescription 关联的数值控件。

适用于

另请参阅