HidDevice.InputReportReceived 이벤트

정의

GetInputReportAsync() 또는 GetInputReportAsync(System.UInt16 reportId)가 호출되면 디바이스에서 발급한 입력 보고서를 처리하는 이벤트 수신기를 설정합니다.

// 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) 

이벤트 유형

예제

여기서는 입력 보고서(inputReport)를 검색하고 비동기 호출이 완료될 때 트리거되는 InputReportReceived 이벤트에 대한 처리기에서 보고서의 콘텐츠를 가져옵니다.

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

설명

이 메서드는 전송할 데이터가 있는 경우 디바이스가 호스트를 중단할 때까지 기다립니다. 내부적으로 HID WinRT API는 IOCTL 읽기 요청을 스택의 하위 드라이버로 보냅니다.

IOCTL은 HID 미니드라이버에 의해 프로토콜별 요청으로 변환됩니다. USB 디바이스의 경우 미니드라이버가 이를 인터럽트 IN 요청으로 변환합니다. 또한 Microsoft HID-I2C 미니포트 드라이버를 통해 실행되는 I2C 디바이스의 경우 미니드라이버가 디바이스가 인터럽트를 어설션할 때까지 기다립니다.

적용 대상

추가 정보