اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
توجيه الإدخال
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
في الإصدار 9 من نظام التشغيل Android والإصدارات الأقدم، لم تكن هناك طريقة للتفاعل مع شاشات متعددة
من خلال اللمس، لأنّه لم تكن هناك آلية ربط بين الشاشات وأجهزة input. على سبيل المثال، يمكن أن توفّر شاشة تعمل باللمس مخرج فيديو HDMI
(سيتم تسجيله كشاشة على Android) ومخرج USB للشاشة التي تعمل باللمس
(سيتم تسجيله كجهاز إدخال). في حال ربط أجهزة متعددة بهذه الطريقة، لن يكون هناك طريقة لتحديد جهاز الإدخال الذي ينتمي
إلى الشاشة. تنطبق المشكلة نفسها على الأجهزة القابلة للطي التي تحتوي على عدة شاشة
مدمجة.
أضاف نظام التشغيل Android 10 آلية لتحديد أجهزة الإدخال التي تنتمي إلى الشاشات. يتم إجراء عملية الربط حسب أرقام المنافذ حيث يشير المنفذ إلى المنفذ المادي الذي تم توصيل الشاشة به.
على سبيل المثال، إذا كان جهاز Android مزوّدًا بمنفذَي HDMI يحملان التصنيفَين hdmi1
وhdmi2
، يمكن أن تكون قيم منفذَي العرض 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 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]