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 參數所描述的數值控制項,並在指定的輸入報告中找到。

適用於

另請參閱