HidInputReport 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
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
- 继承
- 属性
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) |
检索与 usagePage 和 usageId 参数关联的布尔控件,并在给定的输入报告中找到。 |
GetBooleanControlByDescription(HidBooleanControlDescription) |
检索由 controlDescription 参数描述并在给定输入报表中找到的布尔控件。 |
GetNumericControl(UInt16, UInt16) |
检索与 usagePage 和 usageId 参数关联的数字控件,并在给定的输入报告中找到。 |
GetNumericControlByDescription(HidNumericControlDescription) |
检索由 controlDescription 参数描述并在给定输入报表中找到的数字控件。 |