Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 2.31 KB

hiddevice_getinputreportasync_294410273.md

File metadata and controls

57 lines (43 loc) · 2.31 KB
-api-id -api-type -api-device-family-note
M:Windows.Devices.HumanInterfaceDevice.HidDevice.GetInputReportAsync(System.UInt16)
winrt method
xbox

Windows.Devices.HumanInterfaceDevice.HidDevice.GetInputReportAsync

-description

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

-parameters

-param reportId

Identifies the requested input report.

-returns

A HidInputReport object.

-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.

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

-see-also

Reference

GetInputReportAsync, Custom HID device sample