HidOutputReport Klasse

Definition

Stellt einen HID-Ausgabebericht dar.

Hosts geben Ausgabeberichte aus, um Änderungen auf dem Gerät anzufordern. Beispielsweise könnte ein Host eine Anforderung an eine Tastatur stellen, um eine LED ein- oder auszuschalten.

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
Vererbung
Object Platform::Object IInspectable HidOutputReport
Attribute

Windows-Anforderungen

Gerätefamilie
Windows 10 (eingeführt in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v1.0)

Hinweise

Im folgenden Beispiel wird veranschaulicht, wie eine mit XAML und C# erstellte UWP-App die CreateOutputReport-Methode verwendet, um einen Ausgabebericht zu erstellen. In diesem Beispiel wird dann die SendOutputReportAsync-Methode verwendet, um den Bericht an das Gerät zu senden.

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

Eigenschaften

Data

Ruft die Daten ab, die einem bestimmten Ausgabebericht zugeordnet sind, oder legt sie fest.

Id

Ruft den Bezeichner ab, der einem bestimmten Ausgabebericht zugeordnet ist.

Methoden

GetBooleanControl(UInt16, UInt16)

Ruft das boolesche Steuerelement ab, das der angegebenen usagePage und usageId zugeordnet ist.

GetBooleanControlByDescription(HidBooleanControlDescription)

Ruft das boolesche Steuerelement ab, das dem angegebenen ControlDescription zugeordnet ist.

GetNumericControl(UInt16, UInt16)

Ruft das numerische Steuerelement ab, das der angegebenen usagePage und usageId zugeordnet ist.

GetNumericControlByDescription(HidNumericControlDescription)

Ruft das numerische Steuerelement ab, das dem angegebenen steuerelementDescription zugeordnet ist.

Gilt für:

Weitere Informationen