HidDevice.InputReportReceived イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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 デバイスの場合、ミニドライバーはこれを INTERRUPT IN 要求に変換します。 また、Microsoft HID-I2C ミニポート ドライバーで実行されている I2C デバイスの場合、ミニドライバーはデバイスが割り込みをアサートするまで待機します。