From 0857fdd2bb011b14843de48e6b6836ba41011cb0 Mon Sep 17 00:00:00 2001 From: wangxuanxuan Date: Tue, 4 Jul 2023 22:18:23 +0800 Subject: [PATCH 1/2] distinguish touch pad and touch screen Signed-off-by: wangxuanxuan --- common/include/input_hub.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 2f85b25..a3d2878 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -211,8 +211,10 @@ size_t InputHub::CollectEvent(RawEvent* buffer, size_t& capacity, Device* device std::vector needFilted(capacity, false); bool isTouchEvent = false; if ((device->classes & INPUT_DEVICE_CLASS_TOUCH_MT) || (device->classes & INPUT_DEVICE_CLASS_TOUCH)) { - isTouchEvent = true; - HandleTouchScreenEvent(readBuffer, count, needFilted); + if (device->identifier.relTypes.size() != 0) { + isTouchEvent = true; + HandleTouchScreenEvent(readBuffer, count, needFilted); + } } RawEvent* event = buffer; -- Gitee From 55d0a6a6d3071663a0919dfcac00b85636c4733e Mon Sep 17 00:00:00 2001 From: wangxuanxuan Date: Wed, 5 Jul 2023 10:13:50 +0800 Subject: [PATCH 2/2] distinguish touch pad and touch screen Signed-off-by: wangxuanxuan --- common/include/constants_dinput.h | 2 ++ common/include/input_hub.cpp | 15 +++++++++++++-- common/include/input_hub.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index 2444c91..fd19bf7 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -182,6 +182,8 @@ namespace DistributedInput { const std::string PROPERTIES = "properties"; + const std::string DH_TOUCH_PAD = "touchpad"; + const std::string DINPUT_LOG_TITLE_TAG = "DINPUT"; constexpr const char* LATENCY_COUNT_THREAD_NAME = "latencyCount"; diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index a3d2878..410e4f4 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -15,6 +15,7 @@ #include "input_hub.h" +#include #include #include #include @@ -28,7 +29,6 @@ #include #include - #include "constants_dinput.h" #include "dinput_context.h" #include "dinput_errcode.h" @@ -205,13 +205,24 @@ size_t InputHub::GetEvents(RawEvent* buffer, size_t bufferSize) return event - buffer; } +bool InputHub::IsTouchPad(const InputDevice& inputDevice) +{ + std::string dhName = inputDevice.name; + DHLOGI("device name is %s.", dhName.c_str()); + transform(dhName.begin(), dhName.end(), dhName.begin(), ::tolower); + if (dhName.find(DH_TOUCH_PAD) == std::string::npos) { + return false; + } + return true; +} + size_t InputHub::CollectEvent(RawEvent* buffer, size_t& capacity, Device* device, struct input_event readBuffer[], const size_t count) { std::vector needFilted(capacity, false); bool isTouchEvent = false; if ((device->classes & INPUT_DEVICE_CLASS_TOUCH_MT) || (device->classes & INPUT_DEVICE_CLASS_TOUCH)) { - if (device->identifier.relTypes.size() != 0) { + if (!IsTouchPad(device->identifier)) { isTouchEvent = true; HandleTouchScreenEvent(readBuffer, count, needFilted); } diff --git a/common/include/input_hub.h b/common/include/input_hub.h index 24fb84e..71ab4a7 100644 --- a/common/include/input_hub.h +++ b/common/include/input_hub.h @@ -126,6 +126,7 @@ private: bool ContainsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint32_t endIndex); int64_t ProcessEventTimestamp(const input_event& event); + bool IsTouchPad(const InputDevice& inputDevice); /* * this macro is used to tell if "bit" is set in "array" -- Gitee