Conversation
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
There was a problem hiding this comment.
Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 5 days and 10 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds a udev-based fallback for I2C touchpads that appear only as event devices, synthesizes hwinfo-compatible mouse metadata, and injects the result into the existing mouse discovery pipeline without changing the normal hwinfo path. Sequence diagram for I2C touchpad discoverysequenceDiagram
participant CmdTool
participant ProcInput as /proc/bus/input/devices
participant Udevadm
participant MouseList as hwinfo_mouse
participant DeviceManager
CmdTool->>ProcInput: loadCatInputDeviceInfo()
ProcInput-->>CmdTool: mapInfo with Handlers and event node
alt handlers contain mouse
CmdTool->>MouseList: use existing hwinfo classification
else handlers lack mouse
CmdTool->>CmdTool: addTouchpadToMouseList(mapInfo)
CmdTool->>Udevadm: isTouchpadDevice(eventNode)
Udevadm-->>CmdTool: ID_INPUT_TOUCHPAD=1
CmdTool->>MouseList: addMouseKeyboardInfoMapInfo(hwinfo_mouse, mouseMapInfo)
end
DeviceManager->>MouseList: getMouseInfoFromHwinfo()
MouseList-->>DeviceManager: touchpad metadata
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 检查 waitForFinished() 返回值,超时时显式调用 process.kill() 清理进程;使用 QRegularExpression 替代 QRegExp 2. 代码质量 ❌评价: 良好 ❌ 不通过 潜在问题:
建议: 将 QRegExp 替换为 QRegularExpression 保持代码风格一致性;考虑在 getMouseInfoFromHwinfo() 中直接处理 I2C 设备的 authorized 检查逻辑,避免通过 Hotplug 字段绕过 3. 代码性能 ✅评价: 良好 ✅ 通过 潜在问题:
建议: 考虑缓存 udevadm 查询结果,或使用非阻塞方式调用 QProcess;对于明确非触摸板的设备类型(如键盘)可提前跳过 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 本次新增代码无安全风险。QProcess 使用参数列表模式调用 udevadm,eventNode 经正则验证仅含 event+数字,无命令注入风险 💡 改进建议代码示例// 改进1: 使用 QRegularExpression 替代 QRegExp
void CmdTool::addTouchpadToMouseList(const QMap<QString, QString> &mapInfo)
{
// 从Handlers中提取event设备节点
QRegularExpression re(".*(event[0-9]{1,2}).*");
QRegularExpressionMatch match = re.match(mapInfo["Handlers"]);
if (!match.hasMatch())
return;
QString eventNode = match.captured(1);
// 通过udevadm检测是否为触摸板
if (!isTouchpadDevice(eventNode))
return;
// ... 后续逻辑不变
}
// 改进2: isTouchpadDevice 增加 waitForFinished 返回值检查和进程清理
bool CmdTool::isTouchpadDevice(const QString &eventNode)
{
if (eventNode.isEmpty())
return false;
QProcess process;
process.start("udevadm", QStringList() << "info" << "--query=property" << "--name=/dev/input/" + eventNode);
bool finished = process.waitForFinished(5000);
if (!finished) {
process.kill();
process.waitForFinished(1000);
return false;
}
QString output = process.readAllStandardOutput();
return output.contains("ID_INPUT_TOUCHPAD=1");
}本报告由 AI 代码审查工具自动生成 |
Root Cause Analysis
I2C touchpads (e.g., elan-clickpad on Huawei L410) only register
/dev/input/eventXwithout/dev/input/mouseX. The device manager relies onhwinfowhich classifies devices as "mouse" only when handlers contain the string "mouse". Since I2C touchpads lack "mouse" in their handlers, they never enter thehwinfo_mouselist, andgetMouseInfoFromHwinfo()never processes them — making the touchpad invisible in the device manager.Key evidence:
CmdTool.cpp:706filters byHardware Class == "mouse", which I2C touchpads never matchCmdTool.cpp:828-852(loadCatInputDeviceInfo) reads the device from/proc/bus/input/devicesbut only stores it inm_InputDeviceInfowithout injecting into the mouse listFix Approach
Added touchpad detection in
loadCatInputDeviceInfo(): when a device's handlers do not contain "mouse", the new methodaddTouchpadToMouseList()usesudevadmto checkID_INPUT_TOUCHPAD=1. If confirmed as a touchpad, it constructs anhwinfo_mouse-compatible map and injects it viaaddMouseKeyboardInfoMapInfo("hwinfo_mouse", ...), making the device visible togetMouseInfoFromHwinfo().Change Safety Assessment
Code Safety
loadCatInputDeviceInfo(); no existing code paths or function signatures are modifiedBusiness Impact Scope
udevadm ID_INPUT_TOUCHPAD=1check only triggers for touchpadsVerification Suggestion
Test on affected I2C touchpad hardware (e.g., Huawei L410) to confirm the touchpad appears in device manager. Verify PS/2 touchpad devices still display correctly without duplication. Confirm other mouse devices are unaffected.
根因分析
I2C 接口触摸板(如华为 L410 的 elan-clickpad)仅注册
/dev/input/eventX,不注册/dev/input/mouseX。设备管理器依赖hwinfo进行设备分类,而hwinfo仅在 handlers 包含 "mouse" 字符串时将设备归类为 mouse。I2C 触摸板 handlers 中无 "mouse",因此无法进入hwinfo_mouse列表,getMouseInfoFromHwinfo()永远遍历不到该设备,导致触摸板在设备管理器中不可见。关键证据:
CmdTool.cpp:706按Hardware Class == "mouse"筛选,I2C 触摸板不匹配CmdTool.cpp:828-852(loadCatInputDeviceInfo)从/proc/bus/input/devices读取到该设备,但仅存入m_InputDeviceInfo,未接入鼠标列表修复方案
在
loadCatInputDeviceInfo()中新增触摸板检测逻辑:当设备 handlers 不含 "mouse" 时,通过新增方法addTouchpadToMouseList()调用udevadm检测ID_INPUT_TOUCHPAD=1。确认为触摸板后,构造hwinfo_mouse兼容格式的 map,通过addMouseKeyboardInfoMapInfo("hwinfo_mouse", ...)注入鼠标列表,使getMouseInfoFromHwinfo()能处理该设备。改动安全评估
代码安全评估
loadCatInputDeviceInfo()末尾新增独立分支,不修改已有代码路径和函数签名业务影响范围
udevadm ID_INPUT_TOUCHPAD=1检测仅对触摸板触发验证建议
在受影响的 I2C 触摸板硬件(如华为 L410)上测试触摸板在设备管理器中的可见性。验证 PS/2 触摸板仍正常显示且不出现重复。确认其他鼠标设备不受影响。
PMS: BUG-209019
Summary by Sourcery
Bug Fixes: