ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
การกำหนดเส้นทางอินพุต
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ใน Android 9 และต่ำกว่า ผู้ใช้ไม่สามารถโต้ตอบกับจอแสดงผลหลายจอผ่านการสัมผัสได้ เนื่องจากไม่มีกลไกการเชื่อมโยงระหว่างจอแสดงผลกับอุปกรณ์อินพุต เช่น จอแสดงผลแบบหน้าจอสัมผัสอาจมีเอาต์พุตวิดีโอ HDMI (ซึ่งจะลงทะเบียนเป็นจอแสดงผลใน Android) และเอาต์พุต USB สำหรับหน้าจอสัมผัส (ซึ่งจะลงทะเบียนเป็นอุปกรณ์อินพุต) หากเชื่อมต่ออุปกรณ์หลายเครื่องในลักษณะนี้ จะไม่มีวิธีระบุอุปกรณ์อินพุตของจอแสดงผลแต่ละเครื่อง ปัญหาเดียวกันนี้เกิดขึ้นกับอุปกรณ์แบบพับได้ที่มีจอแสดงผลในตัวหลายจอ
Android 10 เพิ่มกลไกในการระบุอุปกรณ์อินพุตที่เป็นของจอแสดงผลใด การเชื่อมโยงจะดำเนินการตามหมายเลขพอร์ต โดยที่พอร์ตหมายถึงพอร์ตจริงที่เชื่อมต่อกับจอแสดงผล
ตัวอย่างเช่น หากอุปกรณ์ Android มีพอร์ต HDMI 2 พอร์ตที่ติดป้ายกำกับว่า hdmi1
และ hdmi2
ค่าของพอร์ต Display อาจได้แก่ 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
ของอุปกรณ์เหล่านั้นในสถานะ Event Hub
adb shell dumpsys input
หากมีอุปกรณ์หลายเครื่องเชื่อมต่ออยู่ ให้แตะอุปกรณ์ที่ต้องการเพื่อตรวจสอบอาร์เรย์ RecentQueue
ในสถานะตัวจัดเตรียมอินพุต จากนั้นคุณก็จะระบุอุปกรณ์เหล่านั้นที่สร้างเหตุการณ์ล่าสุดได้ จากนั้นคุณจะค้นหาอุปกรณ์ที่เกี่ยวข้องได้ในสถานะ Event Hub
หากต้องการดูพอร์ตแสดงผลที่กำหนดให้กับจอภาพที่เชื่อมต่อ ให้ใช้ adb shell dumpsys display
แล้วมองหาพร็อพเพอร์ตี้ address
ของ DisplayDeviceInfo
สำหรับจอแสดงผลแต่ละเครื่องในส่วนอุปกรณ์แสดงผล
หรือใช้ adb shell dumpsys SurfaceFlinger --display-id
เพื่อแสดงข้อมูลระบุตัวตนของจอแสดงผลที่เชื่อมต่อทั้งหมด ดูตัวระบุการแสดงผลแบบคงที่
หากคุณระบุการเชื่อมโยงสำหรับอุปกรณ์อินพุตที่เฉพาะเจาะจงและระบบไม่มีจอแสดงผลที่เกี่ยวข้อง อุปกรณ์อินพุตจะปิดอยู่จนกว่าจอแสดงผลที่เกี่ยวข้องจะปรากฏขึ้น การเชื่อมโยงจะดำเนินการกับอุปกรณ์แบบสัมผัสเท่านั้น
การกำหนดเส้นทางสำหรับจอภาพแบบหลายจอแบบไดนามิก
Android 10 ช่วยให้คุณตั้งค่าอุปกรณ์แบบหลายจอแสดงผลแบบคงที่ได้ ยังไม่ได้เปิดใช้การเชื่อมโยงแบบไดนามิก อย่างไรก็ตาม กรณีการใช้งานบางอย่างสามารถแก้ไขได้ด้วยการระบุข้อมูลการกำหนดเส้นทางสำหรับจอแสดงผลและแผงอินพุตที่ไม่ได้แสดงอยู่เสมอหรือใช้อุปกรณ์อินพุตเสมือน จากนั้นให้ข้อมูลการกำหนดเส้นทางเพิ่มเติมแก่อุปกรณ์เสมือนเหล่านั้น หากการติดตั้งใช้งานอุปกรณ์รองรับ
- ประสบการณ์การใช้งานแบบเดสก์ท็อปด้วยแท่นชาร์จแบบต่อพ่วง คุณสามารถกำหนดค่าการกำหนดเส้นทางเพื่อกำหนดเป้าหมายอินพุตจากอุปกรณ์เสริมอินพุตที่เชื่อมต่อกับแท่นชาร์จ (ระบุด้วยพอร์ตที่ไม่ซ้ำกัน) ไปยังจอแสดงผลภายนอก (ระบุด้วยพอร์ต)
- หน้าจอหลักทำหน้าที่เป็นแหล่งอินพุต (เช่น ทัชแพด) เมื่อเชื่อมต่อกับจอแสดงผลภายนอก คุณสามารถกำหนดค่าการกำหนดเส้นทางเพื่อกำหนดเป้าหมายอินพุตจากแผงสัมผัสเสมือน (ระบุด้วยรหัสเสมือนที่ไม่ซ้ำกัน) ไปยังจอแสดงผลภายนอก (ระบุด้วยพอร์ต)
การใช้งาน
- สำหรับอุปกรณ์จริง ระบบจะใช้พอร์ตที่เชื่อมต่ออุปกรณ์อินพุตและพอร์ตที่เชื่อมต่อจอแสดงผลเพื่อจับคู่จอแสดงผลกับหน้าจอสัมผัส
- ระบบจะจัดเก็บการแมปไว้ใน
InputReaderConfiguration
TouchInputMapper.mViewport
ได้รับการตั้งค่าเป็นวิวพอร์ตที่ตรงกับพอร์ตที่ระบุสำหรับ InputDevice.location
- หากระบุพอร์ตอุปกรณ์อินพุตในไฟล์การแมป และปัจจุบันไม่มีวิวพอร์ตที่มีพอร์ตจอแสดงผลที่ตรงกัน ระบบจะปิดใช้อุปกรณ์อินพุตในพอร์ตนั้น
- หากไม่ได้ระบุพอร์ตสำหรับอุปกรณ์อินพุตหนึ่งๆ ระบบจะตั้งค่าวิวพอร์ตตามกฎที่มีอยู่
- โดยไม่จำเป็นต้องทำการเปลี่ยนแปลงเคอร์เนลในไดรเวอร์อินพุต
- พอร์ตอุปกรณ์อินพุตจะกำหนดโดยใช้ ioctl EVIOCGPHYS
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 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-07-27 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."]]