HidInputReport 类

定义

表示 HID 输入报表

设备发出输入报告来描述状态更改、用户输入和其他特定于设备的数据。 例如,HID 键盘设备将使用输入报告来发出按键信号。 HID 状态传感器将使用输入报告向状态检测事件发出信号。

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

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 应用如何使用 GetInputReportAsync 方法获取输入报告。

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");
            }
        }
    }
}

属性

ActivatedBooleanControls

获取给定 HID 设备的当前激活的布尔控件。

Data

获取与给定输入报表关联的数据。

Id

获取与给定输入报表关联的标识符。

TransitionedBooleanControls

获取给定 HID 设备的最近转换的布尔控件。

方法

GetBooleanControl(UInt16, UInt16)

检索与 usagePageusageId 参数关联的布尔控件,并在给定的输入报告中找到。

GetBooleanControlByDescription(HidBooleanControlDescription)

检索由 controlDescription 参数描述并在给定输入报表中找到的布尔控件。

GetNumericControl(UInt16, UInt16)

检索与 usagePageusageId 参数关联的数字控件,并在给定的输入报告中找到。

GetNumericControlByDescription(HidNumericControlDescription)

检索由 controlDescription 参数描述并在给定输入报表中找到的数字控件。

适用于

另请参阅