-api-id | -api-type | -api-device-family-note |
---|---|---|
M:Windows.Devices.HumanInterfaceDevice.HidDevice.GetInputReportAsync(System.UInt16) |
winrt method |
xbox |
Asynchronously retrieves an input report, identified by the reportId parameter, from the given HID device.
Identifies the requested input report.
A HidInputReport object.
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.
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);
}