一、Android双屏异触-指定触摸为副屏触摸
在双屏异显产品中,有时候主副屏都带有触摸屏,并且要求主副屏触摸各自操作互不干扰。
Android 现有框架中已经支持副输入设备的逻辑,只是默认将所有的外部热插拔设备统一指定为副输入设备,这种逻辑我们如果是一个 I2C 加上一个 USB 触摸那么默认就可以支持,USB 触摸就是副 TP。
但,有时候我们是双 I2C 或双 USB 的搭配,我们就需要改造现有逻辑,方案如下:
通过属性配置副屏 TP 的: 设备名、PID&VID、USB 端口,在 EventHub 中获取输入设备的设备名、PID&VID、USB 端口与属性值进行对比,如果是配置中的设备就将其标记为副输入设备。
实现
diff --git a/frameworks/native/services/inputflinger/EventHub.cpp b/frameworks/native/services/inputflinger/EventHub.cpp
old mode 100644
new mode 100755
index 2bcc5c7..1542a7b
--- a/frameworks/native/services/inputflinger/EventHub.cpp
+++ b/frameworks/native/services/inputflinger/EventHub.cpp
@@ -64,6 +64,11 @@
#define INDENT2 " "
#define INDENT3 " "
+// for multi touch panel
+#define DEVICE_MATCH_METHOD_MAX 10
+#define USB_LOCATION_MATCH_START 13 //"usb-ff540000."
+#define USB_LOCATION_MATCH_LEN 7 //"usb-1.1"
+
namespace android {
static const char *WAKE_LOCK_ID = "KeyEvents";
@@ -1184,17 +1189,17 @@ status_t EventHub::openDeviceLocked(const char *devicePath) {
int32_t deviceId = mNextDeviceId++;
Device* device = new Device(fd, deviceId, String8(devicePath), identifier);
- ALOGV("add device %d: %s\n", deviceId, devicePath);
- ALOGV(" bus: %04x\n"
+ ALOGI("add device %d: %s\n", deviceId, devicePath);
+ ALOGI(" bus: %04x\n"
" vendor %04x\n"
" product %04x\n"
" version %04x\n",
identifier.bus, identifier.vendor, identifier.product, identifier.version);
- ALOGV(" name: \"%s\"\n", identifier.name.string());
- ALOGV(" location: \"%s\"\n", identifier.location.string());
- ALOGV(" unique id: \"%s\"\n", identifier.uniqueId.string());
- ALOGV(" descriptor: \"%s\"\n", identifier.descriptor.string());
- ALOGV(" driver: v%d.%d.%d\n",
+ ALOGI(" name: \"%s\"\n", identifier.name.string());
+ ALOGI(" location: \"%s\"\n", identifier.location.string()