Share via


HidDevice.GetInputReportAsync Method

Definition

Overloads

GetInputReportAsync()

Asynchronously retrieves the default, or first, input report from the given HID device.

GetInputReportAsync(UInt16)

Asynchronously retrieves an input report, identified by the reportId parameter, from the given HID device.

GetInputReportAsync()

Asynchronously retrieves the default, or first, input report from the given HID device.

public:
 virtual IAsyncOperation<HidInputReport ^> ^ GetInputReportAsync() = GetInputReportAsync;
/// [Windows.Foundation.Metadata.Overload("GetInputReportAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<HidInputReport> GetInputReportAsync();
[Windows.Foundation.Metadata.Overload("GetInputReportAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<HidInputReport> GetInputReportAsync();
function getInputReportAsync()
Public Function GetInputReportAsync () As IAsyncOperation(Of HidInputReport)

Returns

A HidInputReport object.

Attributes

Examples

Here, we retrieve an input report (inputReport) and get the content of the report in the handler for the InputReportReceived event, triggered when the asynchronous call completes.

HidInputReport inputReport = await device.GetInputReportAsync();
.
.
.
private void InputReportReceived(
    HidDevice sender, 
    HidInputReportReceivedEventArgs args)
    {
        HidInputReport inputReport = args.Report;
        IBuffer buffer = inputReport.Data;
        DataReader dr = DataReader.FromBuffer(buffer);
        byte[] bytes = new byte[inputReport.Data.Length];
        dr.ReadBytes(bytes);

        String inputReportContent = 
           System.Text.Encoding.ASCII.GetString(bytes);
    }

Remarks

When this method completes, the InputReportReceived event is triggered.

To access the content of the input report, you must set up a listener for the InputReportReceived event and get the Report property of HidInputReportReceivedEventArgs object in the event handler.

The device must be opened with either FileAccessMode.Read or FileAccessMode.ReadWrite.

Applies to

GetInputReportAsync(UInt16)

Asynchronously retrieves an input report, identified by the reportId parameter, from the given HID device.

public:
 virtual IAsyncOperation<HidInputReport ^> ^ GetInputReportAsync(unsigned short reportId) = GetInputReportAsync;
/// [Windows.Foundation.Metadata.Overload("GetInputReportByIdAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<HidInputReport> GetInputReportAsync(uint16_t const& reportId);
[Windows.Foundation.Metadata.Overload("GetInputReportByIdAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<HidInputReport> GetInputReportAsync(ushort reportId);
function getInputReportAsync(reportId)
Public Function GetInputReportAsync (reportId As UShort) As IAsyncOperation(Of HidInputReport)

Parameters

reportId
UInt16

unsigned short

uint16_t

Identifies the requested input report.

Returns

A HidInputReport object.

Attributes

Examples

Here, we retrieve an input report (inputReport) and get the content of the report in the handler for the InputReportReceived event, triggered when the asynchronous call completes.

HidInputReport inputReport = await device.GetInputReportAsync();
.
.
.
private void InputReportReceived(
    HidDevice sender, 
    HidInputReportReceivedEventArgs args)
    {
        HidInputReport inputReport = args.Report;
        IBuffer buffer = inputReport.Data;
        DataReader dr = DataReader.FromBuffer(buffer);
        byte[] bytes = new byte[inputReport.Data.Length];
        dr.ReadBytes(bytes);

        String inputReportContent = 
           System.Text.Encoding.ASCII.GetString(bytes);
    }

Remarks

When this method completes, the InputReportReceived event is triggered.

To access the content of the input report, you must set up a listener for the InputReportReceived event and get the Report property of HidInputReportReceivedEventArgs object in the event handler.

The device must be opened with either FileAccessMode.Read or FileAccessMode.ReadWrite.

Applies to