HidDevice.InputReportReceived Event

Definition

Establishes an event listener to handle input reports issued by the device when either GetInputReportAsync() or GetInputReportAsync(System.UInt16 reportId) is called.

// Register
event_token InputReportReceived(TypedEventHandler<HidDevice, HidInputReportReceivedEventArgs const&> const& handler) const;

// Revoke with event_token
void InputReportReceived(event_token const* cookie) const;

// Revoke with event_revoker
HidDevice::InputReportReceived_revoker InputReportReceived(auto_revoke_t, TypedEventHandler<HidDevice, HidInputReportReceivedEventArgs const&> const& handler) const;
public event TypedEventHandler<HidDevice,HidInputReportReceivedEventArgs> InputReportReceived;
function onInputReportReceived(eventArgs) { /* Your code */ }
hidDevice.addEventListener("inputreportreceived", onInputReportReceived);
hidDevice.removeEventListener("inputreportreceived", onInputReportReceived);
- or -
hidDevice.oninputreportreceived = onInputReportReceived;
Public Custom Event InputReportReceived As TypedEventHandler(Of HidDevice, HidInputReportReceivedEventArgs) 

Event Type

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

This method waits for the device to interrupt the host when it has data to send. Internally, the HID WinRT API sends a IOCTL read request to a lower driver in the stack.

The IOCTL is translated by the HID minidriver into a protocol-specific request. For a USB device, the minidriver translates this into an INTERRUPT IN request. And, for an I2C device that is running over the Microsoft HID-I2C miniport driver, the minidriver will wait for the device to assert an interrupt.

Applies to

See also