2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
入力ルーティング
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 9 以前は、ディスプレイと入力デバイスを関連付けるメカニズムがなかったため、タップで複数のディスプレイを操作することはできませんでした。たとえば、タッチスクリーン ディスプレイは、HDMI ビデオ出力(Android でディスプレイとして登録)とタッチスクリーン用 USB 出力(入力デバイスとして登録)を提供できましたが、複数のデバイスがこのように接続されている場合、どの入力デバイスがどのディスプレイに属しているかを判断することはできませんでした。複数の内蔵ディスプレイを備えた折りたたみ式デバイスにも同じ問題が当てはまります。
Android 10 では、どの入力デバイスがどのディスプレイに属しているかを指定するメカニズムが追加されました。関連付けはポート番号で行います(このポートはディスプレイが接続されている物理ポートを指します)。
たとえば、Android デバイスに hdmi1
と hdmi2
のラベルが付いた 2 つの HDMI ポートがある場合、ディスプレイ ポートの値は 1
と 2
です。同じ物理 HDMI ポートに別のディスプレイ(ディスプレイ モデルやメーカーが異なるなど)が接続されても、ポートの値は変わりません。これにより、デバイス メーカーはディスプレイのアセンブルとアップグレードの手順を提供できます。
関連付けは /vendor/etc/input-port-associations.xml
で設定します。例:
<ports>
<port display="0" input="usb-xhci-hcd.0.auto-1.1/input0" />
<port display="1" input="usb-xhci-hcd.0.auto-1.2/input0" />
</ports>
上の例では、display="0"
はディスプレイを接続するポートを指定します。input="usb-xhci-hcd.0.auto-1.1/input0"
は、入力デバイスを接続するポートを指定します。特定のデバイスに関連付けられたポートを確認するには、次のターミナル コマンドを使用して、イベントハブ状態のデバイスの location
プロパティを調べます。
adb shell dumpsys input
多くのデバイスが接続されている場合は、特定のデバイスをタップして入力ディスパッチャ状態の RecentQueue
配列を確認し、最新のイベントを生成したデバイスを特定できます。次に、イベントハブ状態の対応するデバイスを見つけます。
接続されたディスプレイに割り当てられているディスプレイ ポートを確認するには、adb shell dumpsys display
を使用してから、Display Devices のディスプレイごとに DisplayDeviceInfo
の address
プロパティを探します。または adb shell dumpsys SurfaceFlinger --display-id
を使用して、接続されているすべてのディスプレイの識別情報をダンプします。静的ディスプレイ ID もご覧ください。
特定の入力デバイスの関連付けが指定されていて、対応するディスプレイがシステムに存在しない場合、入力デバイスはそのディスプレイが表示されるまで無効になります。関連付けは、タッチデバイスに対してのみ実行されます。
動的マルチディスプレイのルーティング
Android 10 では、静的マルチディスプレイ デバイスを設定できます。動的関連付けはまだ有効になっていません。ただし、常に存在するわけではないディスプレイと入力パネルのルーティング情報を指定するか、仮想入力デバイスを使用してそれらの仮想デバイスに追加のルーティング情報を提供することで、一部のユースケースに対処できます。デバイスの実装でのサポートに応じて、以下が行われます。
- ドッキング ステーションによるデスクトップのようなエクスペリエンスがサポートされている場合、ホルダーに接続された入力アクセサリ(ポートによって一意に識別される)から外部ディスプレイ(ポートによって識別される)への入力をターゲットとするルーティング設定が提供されます。
- 外部ディスプレイに接続されたときに入力ソース(タッチパッドなど)として機能するプライマリ画面がサポートされている場合、仮想タッチパネル(一意の仮想 ID で識別される)から外部ディスプレイ(ポートによって識別される)への入力をターゲットとするルーティング設定が提供されます。
実装
- 物理デバイスの場合、入力デバイスが接続されるポートとディスプレイが接続されるポートは、ディスプレイとタッチスクリーンを一致させるために使用されます。
- マッピングは
InputReaderConfiguration
に保存されます。
TouchInputMapper.mViewport
は、InputDevice.location
に指定されたポートに一致するビューポートに設定されます。
- マッピング ファイルで入力デバイスポートが指定されており、一致するディスプレイ ポートを含むビューポートが現在存在しない場合、そのポートの入力デバイスは無効になります。
- 特定の入力デバイスに対してポートが指定されていない場合、ビューポートは既存のルールに従って設定されます。
- 入力ドライバでのカーネルの変更は不要です。
- 入力デバイスポートは、EVIOCGPHYS ioctl を使用して決定されます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Input routing\n\nIn Android 9 and lower, there was no way to interact with multiple displays\nvia touch, because there was no association mechanism between displays and input\ndevices. For example, a touchscreen display could provide an HDMI video output\n(that would register as a display on Android) and a USB output for touchscreen\n(that would register as an input device). If multiple devices were connected in\nthis manner, there would be no way to determine which input device belongs to\nwhich display. The same issue applies to foldable devices with multiple built-in\ndisplays.\n\nAndroid 10 added a mechanism to specify which input\ndevices belong to which displays. The association is done by port numbers where\n*port* refers to the physical port to which a display is connected.\n\nFor example, if an Android device has two HDMI ports labeled `hdmi1`\nand `hdmi2`, then the display port values could be `1` and\n`2`. The port values remain the same even when a different display is\nconnected (such as a different display model or manufacturer) to the same physical\nHDMI port. This enables device manufacturers to provide instructions to assemble\nand upgrade displays.\n\nThe association is configured in `/vendor/etc/input-port-associations.xml`.\nFor example: \n\n \u003cports\u003e\n \u003cport display=\"0\" input=\"usb-xhci-hcd.0.auto-1.1/input0\" /\u003e\n \u003cport display=\"1\" input=\"usb-xhci-hcd.0.auto-1.2/input0\" /\u003e\n \u003c/ports\u003e\n\nIn the example above, `display=\"0\"` specifies the port to which the\ndisplay is connected. `input=\"usb-xhci-hcd.0.auto-1.1/input0\"`\nspecifies the port to which the input device is connected. To determine the ports\nassociated with specific devices, use the following terminal command, and then\nreview the`location` property of those devices in the Event Hub State. \n\n```\nadb shell dumpsys input\n```\n\nIf many devices are connected, tap a specific device to examine the\n`RecentQueue` array in the Input Dispatcher State. You can then identify\nthose devices that generated the most recent event. You can then find the\ncorresponding device in the Event Hub State.\n\nTo determine the display ports assigned to the connected displays, use\n`adb shell dumpsys display` and then look for the `address`\nproperty of `DisplayDeviceInfo` for each display under Display Devices.\nAlternatively, use `adb shell dumpsys SurfaceFlinger --display-id` to dump\nidentification information for all connected displays. See also\n[Static display identifiers](/docs/core/display/multi_display/displays#static).\n\nIf you specify an association for a specific input device and the corresponding\ndisplay isn't present in the system, the input device is disabled until the respective\ndisplay appears. The association is performed only for touch devices.\n\nRouting for dynamic multi-displays\n----------------------------------\n\nAndroid 10 enables you to set up static multi-display\ndevices. Dynamic associations are not yet enabled. However, some use cases can be\naddressed by providing routing information for displays and input panels that aren't\nalways present or using virtual input devices and then providing additional routing\ninformation to those virtual devices. If a device implementation supports a:\n\n- Desktop-like experience with a docking station, then a routing config could be provided to target input from input accessory connected to the dock (identified uniquely by port) to the external display (identified by port).\n- Primary screen acting as an input source (such as a touchpad) when connected to the external display, then a routing config could be provided to target input from virtual touch panel (identified by unique virtual ID) to the external display (identified by port).\n\n### Implementation\n\n- For physical devices, the port to which the input device is connected and the port to which the display is connected, are used to match the displays with touchscreens.\n- The mappings are stored in `InputReaderConfiguration`.\n- `TouchInputMapper.mViewport` is set to the viewport that matches the port specified for `InputDevice.location`.\n- If an input device port is specified in the mapping file, and there currently isn't a viewport that has a matching display port, then the input device on that port is disabled.\n- If a port isn't specified for a particular input device, then viewport is set according to the existing rules.\n- No kernel changes are required in the input drivers.\n- The input device ports are determined using the EVIOCGPHYS ioctl."]]