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相關聯的數值控制項。

適用於

另請參閱