From 63b85141557e10c703ca0a1bc7dd54f13964c8ca Mon Sep 17 00:00:00 2001 From: runtime Date: Thu, 17 Sep 2026 01:58:40 +0800 Subject: [PATCH] fix: show I2C touchpad in device manager mouse list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: I2C touchpads (e.g. elan-clickpad) only register /dev/input/eventX without /dev/input/mouseX, hwinfo classifies devices as mouse only when handlers contain "mouse", so I2C touchpads never enter hwinfo_mouse list and are invisible 2. Fix: add touchpad detection in loadCatInputDeviceInfo() using udevadm to check ID_INPUT_TOUCHPAD=1, inject detected touchpads into hwinfo_mouse via addMouseKeyboardInfoMapInfo 3. Impact: only affects devices without "mouse" in handlers, PS/2 touchpads are unaffected as they are already classified by hwinfo Log: I2C touchpad now visible in device manager mouse/touchpad area Influence: 1. Test I2C touchpad visibility in device manager on affected hardware 2. Verify PS/2 touchpad still displays correctly without duplication 3. Verify other mouse devices are unaffected fix: I2C触摸板在设备管理器鼠标列表中可见 1. 根因:I2C触摸板(如elan-clickpad)仅注册/dev/input/eventX而不注册 /dev/input/mouseX,hwinfo仅在handlers含"mouse"时分类为mouse, 导致I2C触摸板无法进入hwinfo_mouse列表,设备管理器中不可见 2. 方案:在loadCatInputDeviceInfo()中通过udevadm检测ID_INPUT_TOUCHPAD=1, 将识别到的触摸板通过addMouseKeyboardInfoMapInfo注入hwinfo_mouse列表 3. 影响:仅影响handlers中不含mouse的设备,PS/2触摸板已被hwinfo分类, 不受影响 Log: I2C触摸板在设备管理器鼠标/触摸板区域可见 Influence: 1. 在受影响硬件上测试I2C触摸板在设备管理器中的可见性 2. 验证PS/2触摸板仍正常显示且不出现重复 3. 验证其他鼠标设备不受影响 PMS: BUG-209019 --- .../src/GenerateDevice/CmdTool.cpp | 62 +++++++++++++++++++ .../src/GenerateDevice/CmdTool.h | 13 ++++ 2 files changed, 75 insertions(+) diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp index 5ba9eb435..61bd54003 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.cpp @@ -853,10 +853,72 @@ void CmdTool::loadCatInputDeviceInfo(const QString &key, const QString &debugfil } } + // I2C触摸板兜底:handlers中不含mouse的触摸板不会被hwinfo分类为mouse, + // 此处通过udevadm检测ID_INPUT_TOUCHPAD=1,将其注入hwinfo_mouse列表 + if (!mapInfo["Handlers"].contains("mouse", Qt::CaseInsensitive)) { + addTouchpadToMouseList(mapInfo); + } + addMapInfo(key, mapInfo); } } +bool CmdTool::isTouchpadDevice(const QString &eventNode) +{ + if (eventNode.isEmpty()) + return false; + + QProcess process; + process.start("udevadm", QStringList() << "info" << "--query=property" << "--name=/dev/input/" + eventNode); + process.waitForFinished(5000); + QString output = process.readAllStandardOutput(); + + return output.contains("ID_INPUT_TOUCHPAD=1"); +} + +void CmdTool::addTouchpadToMouseList(const QMap &mapInfo) +{ + // 从Handlers中提取event设备节点 + QRegExp re(".*(event[0-9]{1,2}).*"); + if (!re.exactMatch(mapInfo["Handlers"])) + return; + + QString eventNode = re.cap(1); + + // 通过udevadm检测是否为触摸板 + if (!isTouchpadDevice(eventNode)) + return; + + // 构造兼容hwinfo_mouse格式的mapInfo + QMap mouseMapInfo; + mouseMapInfo["Hardware Class"] = "mouse"; + + QString name = mapInfo["Name"]; + mouseMapInfo["Device"] = name; + mouseMapInfo["name"] = name; + + // 确保Model包含"Touchpad",使DeviceInput能识别为触摸板 + if (name.contains("Touchpad", Qt::CaseInsensitive) || name.contains("clickpad", Qt::CaseInsensitive)) { + mouseMapInfo["Model"] = name; + } else { + mouseMapInfo["Model"] = name + " Touchpad"; + } + + // 映射Sysfs路径 + if (mapInfo.find("Sysfs") != mapInfo.end()) + mouseMapInfo["SysFS ID"] = mapInfo["Sysfs"]; + + // 映射Handlers为Device Files + mouseMapInfo["Device Files"] = mapInfo["Handlers"]; + + // 设置Hotplug为PS/2以绕过getMouseInfoFromHwinfo中的authorized文件检查 + // 实际接口类型由getMouseInfoFromBusDevice()根据Bus类型覆盖为I2C + mouseMapInfo["Hotplug"] = "PS/2"; + + // 注入hwinfo_mouse列表 + addMouseKeyboardInfoMapInfo("hwinfo_mouse", mouseMapInfo); +} + void CmdTool::loadCatAudioInfo(const QString &key, const QString &debugfile) { // 获取设备信息 diff --git a/deepin-devicemanager/src/GenerateDevice/CmdTool.h b/deepin-devicemanager/src/GenerateDevice/CmdTool.h index e04c9ee09..d64509296 100644 --- a/deepin-devicemanager/src/GenerateDevice/CmdTool.h +++ b/deepin-devicemanager/src/GenerateDevice/CmdTool.h @@ -221,6 +221,19 @@ class CmdTool */ void loadCatInputDeviceInfo(const QString &key, const QString &debugfile); + /** + * @brief isTouchpadDevice:通过udevadm检测设备是否为触摸板 + * @param eventNode:事件设备节点名(如event1) + * @return true:是触摸板;false:不是触摸板 + */ + bool isTouchpadDevice(const QString &eventNode); + + /** + * @brief addTouchpadToMouseList:将触摸板设备信息注入hwinfo_mouse列表 + * @param mapInfo:从/proc/bus/input/devices解析的设备信息 + */ + void addTouchpadToMouseList(const QMap &mapInfo); + /** * @brief loadCatAudioInfo:加载cat /proc/asound/card0/codec#0信息 * @param key:cat_audio