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